:root {
  --ink: #1a1a1a;
  --muted: #666;
  --accent: #1e4a8a;
  --bg: #f4f4f0;
  --paper: #ffffff;
  --rule: #d8d8d4;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }

.controls { max-width: 760px; margin: 24px auto; padding: 20px 24px;
  background: var(--paper); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.controls h1 { margin: 0 0 12px; font-size: 20px; color: var(--accent); }
.controls .row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.controls label { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.controls select { padding: 6px 10px; font-size: 14px; min-width: 220px; }
.controls button { padding: 8px 16px; font-size: 14px; background: var(--accent); color: white;
  border: none; border-radius: 6px; cursor: pointer; }
.controls button:disabled { background: #aaa; cursor: not-allowed; }
.controls button:hover:not(:disabled) { background: #163864; }
.status { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 18px; }

main#worksheet { max-width: 760px; margin: 24px auto 80px; padding: 40px 56px;
  background: var(--paper); box-shadow: 0 1px 3px rgba(0,0,0,0.08); min-height: 200px; }
main#worksheet:empty::before { content: "Pick a lesson and click Generate.";
  color: var(--muted); font-style: italic; }

.ws-title { text-align: center; font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.ws-subtitle { text-align: center; font-size: 16px; margin: 0 0 16px; color: var(--muted); }
.ws-meta { display: flex; justify-content: space-between; font-size: 14px;
  border-bottom: 1px solid var(--rule); padding-bottom: 8px; margin-bottom: 12px; }
.ws-meta span { border-bottom: 1px solid var(--ink); display: inline-block; min-width: 200px; padding: 0 4px; }
.ws-rule { font-style: italic; font-size: 13px; margin: 8px 0 20px; color: var(--ink); }

.ws-section { margin: 24px 0 8px; font-size: 16px; font-weight: 700; color: var(--accent); }
.ws-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
.ws-grid .ws-item { padding: 8px 0 70px 0; }
.ws-list .ws-item { padding: 8px 0 60px 0; }
.ws-num { font-weight: 700; margin-right: 8px; }
.ws-text { display: inline; }

/* Answer key (separate page) */
.ws-answers { page-break-before: always; padding-top: 0; }
.ws-answers h2 { text-align: center; font-size: 20px; margin: 0 0 12px; }
.ws-ak-section { font-size: 14px; font-weight: 700; color: var(--accent); margin: 16px 0 6px; }
.ws-ak-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 12px; font-size: 13px; }
.ws-ak-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 13px; }

/* Print */
@media print {
  @page { size: letter; margin: 0.75in; }
  html, body { background: white; }
  .no-print { display: none !important; }
  main#worksheet { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .ws-grid .ws-item { padding-bottom: 70px; break-inside: avoid; }
  .ws-list .ws-item { padding-bottom: 60px; break-inside: avoid; }
  .ws-section { break-after: avoid; }
}
