:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1d1d1b;
  --muted: #66655f;
  --line: #dcdad2;
  --accent: #1f5f8b;
  --accent-text: #ffffff;
  --good: #2f7d4a;
  --good-bg: #e6f2ea;
  --bad: #a33a2b;
  --bad-bg: #f7e6e2;
  --warn: #8a5a00;
  --warn-bg: #fff1d1;
  --fig-on: #4a4a46;
  --fig-off: #ffffff;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171716;
    --card: #222220;
    --text: #ecebe6;
    --muted: #a3a29b;
    --line: #3a3936;
    --accent: #6aa9d6;
    --accent-text: #0f1a22;
    --good: #7cc795;
    --good-bg: #1f3326;
    --bad: #ec8b7b;
    --bad-bg: #3a221d;
    --warn: #f0c060;
    --warn-bg: #3a2e14;
    --fig-on: #d8d7d0;
    --fig-off: #222220;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
code { font-size: .9em; }
button, select, input, .button { font: inherit; color: inherit; }
button, .button {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .5em 1em; cursor: pointer;
}
button:hover, .button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.big { font-size: 1.15rem; padding: .7em 1.6em; }
button.link { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; }
button.link.danger { color: var(--bad); }
select, input { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: .4em .5em; max-width: 100%; }
input[type="number"] { width: 5.5em; }
.mono { font-family: ui-monospace, Menlo, monospace; letter-spacing: .08em; width: 100%; }

.app-head {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .75rem 1rem;
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2;
}
.brand { font-weight: 700; }
.student-switch { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.student-switch button { border: none; border-radius: 0; padding: .4em 1.1em; }
.student-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.tabs { display: flex; gap: .25rem; margin-left: auto; }
.tabs a { color: var(--text); text-decoration: none; padding: .4em .8em; border-radius: 6px; }
.tabs a.active { background: var(--bg); font-weight: 600; }
.warning { background: var(--warn-bg); color: var(--warn); padding: .6rem 1rem; }

main { max-width: 960px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.lede { margin-top: 0; }
.muted, .hint { color: var(--muted); font-size: .92rem; }
.hint { margin-left: .75rem; }
.note { background: var(--warn-bg); color: var(--warn); padding: .5em .75em; border-radius: 6px; }
.form-error { color: var(--bad); min-height: 1em; }
.plan { font-size: 1.05rem; }
.form-grid { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; margin: .5rem 0 1rem; }
.form-grid label, label.block { display: flex; flex-direction: column; gap: .25rem; font-size: .92rem; color: var(--muted); }
.form-grid label select, .form-grid label input { color: var(--text); }
label.block { margin: .5rem 0; }
label.inline { font-size: .92rem; color: var(--muted); }
.actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.tag { font-size: .75rem; border: 1px solid var(--line); border-radius: 4px; padding: 0 .3em; color: var(--muted); }
.scroll { overflow-x: auto; }

table.data { border-collapse: collapse; width: 100%; font-size: .93rem; }
table.data th, table.data td { text-align: left; padding: .35em .5em; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-weight: 600; color: var(--muted); font-size: .85rem; }
table.log .group-row th { color: var(--text); background: var(--bg); font-size: .95rem; padding-top: .6em; }
table.log .sec-row td:first-child { font-weight: 600; }
table.log .sub-row td:first-child, .entry-table .sub-row td:first-child { padding-left: 1.5em; color: var(--muted); }
.entry-table input { width: 4.5em; }
details.entry { margin-top: 1rem; }
details.entry summary { cursor: pointer; color: var(--accent); font-weight: 600; }

/* ---- drill ---- */
.drill { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem 1.25rem; }
.drill-bar { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.qnum { color: var(--muted); }
.clock { font-size: 2rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.clock.low { color: var(--bad); }
.qtime { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 4.5em; text-align: right; }
.pacebar { position: relative; height: 8px; background: var(--bg); border-radius: 4px; margin: .5rem 0; overflow: hidden; }
.pacebar div { height: 100%; width: 0; background: var(--accent); }
.pacemark { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--muted); }
.drill.over .pacebar div { background: var(--warn); }
.cue { min-height: 2.2em; font-weight: 700; color: var(--warn); }
.drill.over .cue { background: var(--warn-bg); padding: .4em .7em; border-radius: 6px; }
.drill .stem { font-size: 1.35rem; margin: .5rem 0 1rem; }
.stem .hint { display: block; margin: .4rem 0 0; font-size: .95rem; }
.stem .exprs { margin-top: .5rem; display: grid; gap: .2rem; }
.logic-q { display: inline-block; margin-top: .5em; color: var(--muted); }
ol.choices { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.choice { width: 100%; text-align: left; display: flex; gap: .9em; align-items: center; font-size: 1.2rem; padding: .7em 1em; }
.choice:focus-visible { outline: 3px solid var(--accent); }
.letter { font-weight: 700; color: var(--muted); min-width: 1.2em; }
.drill-foot { display: flex; justify-content: space-between; margin-top: 1rem; }
.figs { display: flex; gap: 1.5rem; margin: .25rem 0 1rem; flex-wrap: wrap; }
figure.geo { margin: 0; text-align: center; }
figure.geo figcaption { color: var(--muted); font-size: .9rem; }
.fig-on { fill: var(--fig-on); stroke: var(--text); stroke-width: 1; }
.fig-off { fill: var(--fig-off); stroke: var(--text); stroke-width: 1; }

/* ---- results ---- */
.scoreline { display: flex; gap: 2rem; flex-wrap: wrap; margin: 1rem 0; }
.scoreline > div { display: flex; flex-direction: column; }
.big-num { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.scoreline .label { color: var(--muted); font-size: .9rem; }
table.results tr.wrong td:nth-child(3) { color: var(--bad); font-weight: 600; }
table.results tr.right td:nth-child(3) { color: var(--good); font-weight: 600; }
table.results tr.stuck td.flag, table.results td.flag { color: var(--warn); }
table.results td.flag { min-width: 10em; }
table.results td:nth-child(5) { white-space: nowrap; }
.paceline { margin: -.25rem 0 1rem; }
.verdict { display: inline-block; font-size: .8rem; font-weight: 600; border-radius: 4px; padding: 0 .35em; white-space: nowrap; }
.verdict.v-too-slow, .verdict.v-rushing { background: var(--warn-bg); color: var(--warn); }
.verdict.v-on-pace { background: var(--good-bg); color: var(--good); }
.pacing-note { font-size: .85rem; }
ol.review, ol.pending { padding-left: 1.5rem; }
ol.review > li, ol.pending > li { padding: .75rem 0; border-bottom: 1px solid var(--line); }
ol.review .stem, ol.pending .stem { font-size: 1.05rem; margin-bottom: .4rem; }
ol.choices.static { gap: .2rem; }
ol.choices.static li { padding: .15em .5em; border-radius: 4px; }
ol.choices.static li.key { background: var(--good-bg); color: var(--good); font-weight: 600; }
ol.choices.static li.picked { background: var(--bad-bg); color: var(--bad); text-decoration: line-through; }
.expl { margin: .5rem 0 0; color: var(--muted); }

@media (max-width: 600px) {
  .tabs { margin-left: 0; width: 100%; }
  .drill .stem { font-size: 1.15rem; }
  .choice { font-size: 1.05rem; }
  .card, .drill { padding: .9rem; }
}

/* ---- print ---- */
@media screen { #print-root { display: none; } }
@media print {
  @page { margin: 0.55in; }
  :root { --text: #000; --muted: #333; --line: #999; --fig-on: #555; --fig-off: #fff; color-scheme: light; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .no-print, .app-head { display: none !important; }
  #print-root { display: block; }
  .print-page { page-break-after: always; break-after: page; }
  .print-page:last-child { page-break-after: auto; break-after: auto; }
  .booklet-head { border-bottom: 2px solid #000; margin-bottom: 10pt; }
  .booklet-head h1, .sheet-head h1, .key h1 { font-size: 15pt; margin: 0 0 4pt; }
  .booklet-head p { margin: 2pt 0; font-size: 10pt; }
  ol.pqs { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24pt; }
  li.pq { break-inside: avoid; page-break-inside: avoid; display: flex; gap: 6pt; margin-bottom: 10pt; }
  .pq-num { font-weight: 700; min-width: 1.8em; }
  .pq-body .stem { margin-bottom: 3pt; }
  .pq-body .stem .hint { font-size: 9pt; color: #333; margin: 2pt 0 0; display: block; }
  ol.pchoices { list-style: none; padding: 0; margin: 0; }
  ol.pchoices li { margin: 1pt 0; }
  ol.pchoices .letter { color: #000; font-weight: 400; }
  .figs { display: flex; gap: 10pt; margin: 4pt 0; }
  figure.geo svg { width: 54pt; height: 54pt; }
  .sheet-head { display: flex; justify-content: space-between; gap: 12pt; border-bottom: 2px solid #000; padding-bottom: 6pt; margin-bottom: 6pt; }
  .sheet-head p { margin: 0; }
  .sheet-fields { display: grid; grid-template-columns: auto auto; gap: 4pt 14pt; font-size: 10pt; }
  .sheet-fields span { display: flex; gap: 4pt; align-items: flex-end; }
  .sheet-fields i { display: inline-block; width: 70pt; border-bottom: 1px solid #000; }
  .sheet-rules { font-size: 9.5pt; margin: 4pt 0 8pt; }
  .sheet-section { break-inside: auto; margin-bottom: 8pt; }
  .sheet-section h2 { font-size: 11pt; margin: 6pt 0 3pt; break-after: avoid; }
  .bubbles { columns: 4; column-gap: 14pt; }
  .bub-block { break-inside: avoid; page-break-inside: avoid; }
  .bub-row { display: flex; align-items: center; gap: 4pt; height: 16pt; break-inside: avoid; flex-wrap: wrap; }
  .bub-row.check { border-bottom: 1.5px solid #000; margin-bottom: 3pt; }
  .bub-num { width: 2.2em; text-align: right; font-weight: 700; font-size: 9.5pt; }
  .bub { width: 13pt; height: 13pt; border: 1px solid #000; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 7pt; }
  .bub-check { display: none; }
  .key-cols { display: flex; gap: 24pt; }
  .key table.data td { padding: 1pt 6pt; border-bottom: 1px solid #ccc; }
}

/* ---- section mode (item 5), review tags (items 8, 9), Today card (item 11) ---- */
.drill-bar .mark { padding: .35em .9em; }
.drill-bar .mark.on { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); font-weight: 700; }
.section-mode .cue { color: var(--muted); font-weight: 400; }
.section-mode .cue:not(:empty) { background: var(--bg); padding: .4em .7em; border-radius: 6px; }
.choice.chosen { border-color: var(--accent); background: var(--bg); box-shadow: inset 0 0 0 1px var(--accent); }
.choice.chosen .letter { color: var(--accent); }
.nav { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }
.nav .primary { margin-left: auto; }
.strip { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: 1rem; }
.qbtn { width: 2.2em; height: 2.2em; padding: 0; font-size: .85rem; font-variant-numeric: tabular-nums; border-radius: 6px; }
.qbtn.answered { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.qbtn.marked { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.qbtn.current { outline: 3px solid var(--accent); outline-offset: 1px; }
.why { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.why button { font-size: .9rem; padding: .3em .8em; }
.why button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.primary .hint { color: var(--accent-text); opacity: .75; }
.strategy { margin-top: 1rem; display: grid; gap: .4rem; }
.strategy-card { border: 1px solid var(--line); border-radius: 6px; padding: .4em .8em; font-size: .95rem; }
.strategy-card summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.strategy-card ol { margin: .4em 0; padding-left: 1.4em; }
.strategy-card p { margin: .3em 0; }
.resume { border-color: var(--warn); }
.card.today .actions { margin-top: .5rem; }

/* ---- Words tab (item 2) ---- */
.wcard { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; text-align: center; cursor: pointer; min-height: 11em; display: flex; flex-direction: column; justify-content: center; gap: .5rem; }
.wcard:focus-visible { outline: 3px solid var(--accent); }
.wcard .word { font-size: 2rem; font-weight: 700; }
.wcard .def { font-size: 1.1rem; }
.wcard .pair { color: var(--muted); }
.wcard .flip-hint { color: var(--muted); font-size: .9rem; }
.wstats { display: flex; gap: 1.5rem; flex-wrap: wrap; color: var(--muted); font-size: .92rem; margin: .5rem 0; }
.wlist { columns: 3; column-gap: 1.5rem; font-size: .95rem; }
@media (max-width: 600px) { .wlist { columns: 2; } .qbtn { width: 2em; height: 2em; } }
/* Word lesson (Words tab and Today) and word notes in the review */
.wstats .lesson-btn { margin-left: auto; font-size: .95rem; padding: .3em .8em; }
.lesson .lprog { color: var(--muted); margin: .25rem 0 .75rem; }
.lesson .row-between h2 { margin-bottom: 0; }
.wordnote { margin: .6rem 0 0; padding: .5em .75em; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 6px 6px 0; font-size: .95rem; overflow-wrap: anywhere; }
.wordnote p { margin: .2em 0; }
.wordnote .pos { color: var(--muted); font-style: italic; }
.wordnote .others .sep { color: var(--muted); }
.added { background: var(--good-bg); color: var(--good); padding: .5em .75em; border-radius: 6px; }

/* ---- trend (item 10) ---- */
.trend svg { width: 100%; max-width: 480px; height: auto; display: block; margin-bottom: .5rem; }
.trend .axis { stroke: var(--line); }
.trend .target { stroke: var(--muted); stroke-dasharray: 4 3; }
.trend .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.trend .dot { fill: var(--accent); }
.trend text { fill: var(--muted); font-size: 11px; }
/* ---- parent toggle (item 11): Bank and Print tabs are hidden until the parent switches it on ---- */
.parent-toggle { font-size: .85rem; padding: .3em .8em; color: var(--muted); }
.parent-toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
body:not(.parent) .parent-only { display: none; }

/* ---- Reading passages: a scroll box on wide screens (passage, question and choices fit one screen),
   natural page flow at phone width so the text is never a small box inside a scrolling page ---- */
.passage { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .4em 1em; margin: .5rem 0 1rem;
  max-height: 50vh; overflow-y: auto; font-size: 1.05rem; line-height: 1.6; }
.passage p { margin: .6em 0; }
.passage:focus-visible { outline: 3px solid var(--accent); }
details.passage-again { margin: .25rem 0 .5rem; }
details.passage-again summary { cursor: pointer; color: var(--accent); font-size: .92rem; }
ol.pending .actions { margin-top: .5rem; }
ol.pending.approved > li { padding: .4rem 0; }
@media (max-width: 600px) { .passage { max-height: none; overflow: visible; padding: .2em .8em; } }
@media print { .passage { max-height: none; overflow: visible; border: none; background: none; padding: 0; font-size: 10.5pt; line-height: 1.45; } }
/* ---- printed Reading booklet: each passage once, full width, right above its questions (which stay
   in two columns); the directions line and passage stay with the first question ---- */
@media print {
  .pgroup { margin: 0 0 12pt; }
  .pgroup + .pgroup, .pgroup + ol.pqs { border-top: 1px solid #999; padding-top: 8pt; }
  .pdir { font-weight: 700; margin: 0 0 4pt; break-after: avoid; page-break-after: avoid; }
  .pgroup .passage { margin: 0 0 8pt; break-after: avoid; page-break-after: avoid; }
  .pgroup .passage p { margin: 0 0 4pt; text-indent: 1.5em; orphans: 3; widows: 3; }
}
/* a long option (Print → Blank answer sheet) must not push the page wider than a phone */
.form-grid label { min-width: 0; max-width: 100%; }
/* ---- Bank review list: grouped by section and type, keyboard approval (A / U / J / K) ---- */
.bkeys { font-size: .92rem; }
kbd { font: inherit; font-size: .85em; font-weight: 700; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; background: var(--bg); }
h4.bgroup-head { margin: 1.5rem 0 .25rem; padding-bottom: .25rem; border-bottom: 2px solid var(--line); }
h4.bgroup-head .muted { font-weight: 400; margin-left: .5em; }
ol.bitems { list-style: none; padding: 0; margin: 0; }
.bitem { padding: .6rem .75rem; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; border-radius: 4px;
  scroll-margin-top: calc(var(--head-h, 3.5rem) + .75rem); scroll-margin-bottom: 3.5rem; }
.bitem:focus { outline: 3px solid var(--accent); outline-offset: 1px; }
.bitem .stem { font-size: 1.05rem; margin: .25rem 0 .4rem; }
.bitem .actions { margin-top: .5rem; }
.bitem.is-approved { border-left-color: var(--good); }
.bmeta { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.bstatus { color: var(--good); font-weight: 700; font-size: .9rem; }
.bprogress { position: sticky; bottom: 0; margin: 1rem -1.25rem -1.1rem; padding: .5rem 1.25rem; background: var(--card); border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius); font-weight: 600; font-variant-numeric: tabular-nums; }
/* comprehension: the passage stays in view beside its questions on a wide screen; at phone width it sits
   above them and each question can unfold it again */
.bpassage-group { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; margin-top: .5rem; }
.bpassage-group > .passage { position: sticky; top: calc(var(--head-h, 3.5rem) + .5rem); max-height: calc(100vh - var(--head-h, 3.5rem) - 4.5rem); margin: 0; }
.bpassage-group details.passage-again { display: none; }
@media (max-width: 760px) {
  .bpassage-group { display: block; }
  .bpassage-group > .passage { position: static; max-height: none; }
  .bpassage-group details.passage-again { display: block; }
  .bprogress { margin: 1rem -.9rem -.9rem; padding: .5rem .9rem; }
}
/* ---- print fixes from a real PDF check: a passage group (directions, passage, its questions) stays on one
   page; vocabulary directions print once; answer-sheet blocks sit in a grid read down each column, and a
   section never splits across pages ---- */
@media print {
  .pgroup { break-inside: avoid; page-break-inside: avoid; }
  .pgroup .passage p { break-inside: avoid; }
  .pgroup + .vgroup { border-top: 1px solid #999; padding-top: 8pt; }
  .vgroup .pq-body .stem .hint { display: none; }
  .vgroup .pdir { break-after: avoid; page-break-after: avoid; }
  .bubbles { columns: auto; display: grid; grid-auto-flow: column; grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(var(--brows, 1), auto); column-gap: 14pt; row-gap: 3pt; align-content: start; }
  .bub-block { align-self: start; }
  .sheet-section { break-inside: avoid; page-break-inside: avoid; }
}
/* ---- Log: both students side by side; ▼ + bold + title mark the weaker number (not color alone) ---- */
.compare-table td.cmp { white-space: nowrap; font-variant-numeric: tabular-nums; position: relative; } /* keeps .sr-only inside the scroll box */
.compare-table th { white-space: nowrap; }
.compare-table .weaker { color: var(--bad); }
.compare-table .sep { color: var(--muted); padding: 0 .15em; }
.compare .needs p { margin: .3em 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
