:root {
  --navy: #1f3a5f; --navy-2: #2c5282; --bar: #e8eef5; --line: #c9d3df;
  --ink: #1a202c; --muted: #5a6778; --bg: #f4f6f9; --card: #fff;
  --ok: #2f855a; --ok-bg: #e6f4ea; --bad: #c53030; --bad-bg: #fdecec; --mark: #d69e2e; --sel: #dbe8fb;
  --zoom: 1;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); font-size: 16px; }
a { color: var(--navy-2); }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- shared top bar ---------- */
.topbar { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar .sp { flex: 1; }
.topbar a { color: #fff; text-decoration: none; opacity: .9; }
.topbar a:hover { opacity: 1; text-decoration: underline; }
.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.btn { background: var(--navy-2); color: #fff; border: 0; border-radius: 6px; padding: 9px 16px; font-weight: 600; }
.btn:hover { background: var(--navy); }
.btn.ghost { background: #fff; color: var(--navy-2); border: 1px solid var(--navy-2); }
.btn.small { padding: 5px 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: default; }
.muted { color: var(--muted); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--bar); color: var(--navy); }

/* ---------- home ---------- */
.grid-sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 16px; }
.set-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.set-card h3 { margin: 0; font-size: 17px; color: var(--navy); }
.set-card .last { font-size: 13px; color: var(--muted); min-height: 34px; }
.set-card .row { display: flex; gap: 8px; flex-wrap: wrap; }
.student-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.student-row select, .student-row input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; }

/* ---------- test runner (ISEE-style) ---------- */
body.test { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.tbar { background: var(--navy); color: #fff; display: flex; align-items: center; padding: 6px 12px; gap: 10px; min-height: 44px; flex-wrap: wrap; }
.tbar .title { font-weight: 600; font-size: 15px; }
.tbar .sp { flex: 1; }
.tbar .timer { font-variant-numeric: tabular-nums; background: rgba(255,255,255,.12); padding: 4px 10px; border-radius: 4px; cursor: pointer; }
.tbar .timer.low { background: #c53030; }
.tools { background: var(--bar); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 6px; padding: 6px 12px; flex-wrap: wrap; }
.tool { background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 5px 10px; font-size: 14px; color: var(--navy); display: inline-flex; align-items: center; gap: 6px; }
.tool:hover { border-color: var(--navy-2); }
.tool.on { background: var(--navy-2); color: #fff; border-color: var(--navy-2); }
.tool.mark.on { background: var(--mark); border-color: var(--mark); }
.tools .sp { flex: 1; }
.qcount { font-size: 14px; color: var(--navy); font-weight: 600; }
.stage { flex: 1; overflow: hidden; display: flex; font-size: calc(17px * var(--zoom)); }
.pane { overflow-y: auto; padding: 22px 26px; }
.pane.passage { flex: 1 1 52%; border-right: 3px solid var(--line); background: #fff; line-height: 1.65; }
.pane.question { flex: 1 1 48%; background: #fff; }
.pane.full { flex: 1; display: flex; justify-content: center; }
.pane.full > .inner { width: 100%; max-width: 760px; }
.passage h2 { font-size: 1.15em; margin: 0 0 12px; text-align: center; }
.passage .para { display: flex; gap: 12px; margin: 0 0 12px; }
.passage .pn { color: var(--muted); font-size: .8em; min-width: 18px; padding-top: 3px; text-align: right; }
.passage .poem { margin: 0 0 14px; }
.passage .pl { display: flex; gap: 12px; }
.passage .ln { color: var(--muted); font-size: .75em; min-width: 18px; text-align: right; padding-top: 4px; }
.passage .hint { font-size: .85em; color: var(--muted); text-align: center; margin-bottom: 12px; }
.stem { font-size: 1.05em; line-height: 1.55; margin: 0 0 16px; }
.stem table { border-collapse: collapse; margin: 10px 0; }
.stem td, .stem th { border: 1px solid #999; padding: 4px 12px; text-align: center; }
.figure { margin: 6px 0 16px; text-align: center; }
.figure svg { max-width: 100%; height: auto; max-height: calc(260px * var(--zoom)); color: #111; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; background: #fff; text-align: left; font-size: 1em; color: var(--ink); width: 100%; }
.choice:hover { border-color: var(--navy-2); }
.choice .letter { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--navy-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--navy-2); flex: none; }
.choice.sel { background: var(--sel); border-color: var(--navy-2); }
.choice.sel .letter { background: var(--navy-2); color: #fff; }
.choice.struck .ctext { text-decoration: line-through; color: #9aa5b1; }
.choice.struck .letter { opacity: .4; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: 1em; line-height: 1.1; margin: 0 3px; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 2px; }
.navbar { background: var(--bar); border-top: 1px solid var(--line); display: flex; gap: 8px; padding: 8px 12px; align-items: center; }
.navbar .sp { flex: 1; }

/* intro / review / report screens inside the runner */
.screen { flex: 1; overflow-y: auto; padding: 28px 16px; }
.screen .inner { max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
.screen h2 { margin-top: 0; color: var(--navy); }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; margin: 16px 0; }
.rv { border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: #fff; text-align: left; font-size: 14px; }
.rv.unans { background: #fff8e1; border-color: #e5c07b; }
.rv.marked { box-shadow: inset 4px 0 0 var(--mark); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.notepad { position: fixed; right: 18px; bottom: 70px; width: min(340px, calc(100vw - 36px)); background: #fffef2; border: 1px solid #d8cf8a; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.18); z-index: 20; }
.notepad header { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-bottom: 1px solid #e9e1a8; font-weight: 600; font-size: 14px; }
.notepad textarea { width: 100%; height: 180px; border: 0; background: transparent; padding: 10px; font: inherit; font-size: 15px; resize: vertical; outline: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; }
.modal { background: #fff; border-radius: 8px; padding: 22px; max-width: 420px; width: 100%; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ---------- results ---------- */
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); font-size: 15px; }
table.list th, table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.list th { background: var(--bar); color: var(--navy); font-size: 13px; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover { background: #f7fafc; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; margin: 10px 0 18px; }
.skill { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 14px; }
.bar { height: 7px; background: #e2e8f0; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--navy-2); }
.qrev { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--ok); border-radius: 6px; padding: 14px 16px; margin: 10px 0; }
.qrev.wrong { border-left-color: var(--bad); }
.qrev.skip { border-left-color: var(--mark); }
.qrev .meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.qrev .choice { cursor: default; padding: 7px 12px; }
.qrev .choice.key { background: var(--ok-bg); border-color: var(--ok); }
.qrev .choice.picked-wrong { background: var(--bad-bg); border-color: var(--bad); }
.qrev .tag { font-size: 12px; font-weight: 700; margin-left: auto; }
.qrev .explain { margin-top: 10px; font-size: 15px; background: #f7fafc; border-radius: 6px; padding: 10px 12px; line-height: 1.5; }
.qrev .explain .ko { color: var(--muted); margin-top: 6px; }
details.psg { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; margin: 14px 0 6px; }
details.psg summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }

@media (max-width: 760px) {
  .stage { flex-direction: column; overflow-y: auto; }
  .pane.passage { border-right: 0; border-bottom: 3px solid var(--line); flex: none; max-height: 45vh; }
  .pane.question { flex: none; }
  .pane { padding: 16px; }
  .tool .lbl { display: none; }
}

/* test-center check-in */
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.setup-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; color: var(--navy); }
.setup-grid input { font: inherit; font-weight: 400; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; }
.mode-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 12px; cursor: pointer; font-size: 15px; }
.mode:has(input:checked) { border-color: var(--navy-2); background: var(--sel); }
.badge-draft { background: #fff3cd; color: #8a6100; }
@media (max-width: 560px) { .setup-grid, .mode-pick { grid-template-columns: 1fr; } }
.qchip { border: 1px solid var(--bad); background: var(--bad-bg); color: var(--bad); border-radius: 5px; padding: 2px 8px; font-size: 13px; font-weight: 700; margin: 2px 0; }
.qchip.skip { border-color: #a0aec0; background: #edf2f7; color: #4a5568; }
.qchip:hover { filter: brightness(.95); }
.qrev.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px #f6e05e; } 100% { box-shadow: none; } }

/* grammar & vocab */
details.gtopic { background: #fff; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; }
details.gtopic > summary { padding: 12px 14px; cursor: pointer; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
details.gtopic[open] > summary { border-bottom: 1px solid var(--line); }
.gbody { padding: 6px 16px 14px; line-height: 1.55; }
.gbody h4 { margin: 14px 0 6px; color: var(--navy); }
.gbody .ko, .ex .ko { color: var(--muted); font-size: 14px; }
.pattern { background: var(--bar); border-left: 4px solid var(--navy-2); padding: 8px 12px; border-radius: 4px; font-family: Consolas, monospace; font-size: 14px; }
ul.ex li { margin: 6px 0; }
.watch { background: #fff8e1; border: 1px solid #f0d58a; border-radius: 6px; padding: 8px 12px; margin-top: 12px; }
.gq { margin: 10px 0 14px; }
.gchoices { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.gchoices .choice { padding: 6px 10px; }
.gchoices .choice.key { background: var(--ok-bg); border-color: var(--ok); }
.gchoices .choice.picked-wrong { background: var(--bad-bg); border-color: var(--bad); }
.gfeedback { margin-top: 6px; font-size: 14px; }
table.vocab td { vertical-align: top; }
.pos { font-style: italic; color: var(--navy-2); }
.exs b { color: var(--navy); }
.hidemean td.mean { color: transparent; background: #edf2f7; cursor: pointer; border-radius: 4px; }
.hidemean td.mean div { visibility: hidden; }
.hidemean td.mean.show { color: inherit; background: none; }
.hidemean td.mean.show div { visibility: visible; }
@media (max-width: 560px) { .gchoices { grid-template-columns: 1fr; } }
