/* Layout concept: a quiet exam room — a fixed instrument bar on top, two reading panes in the middle, a navigation rail at the bottom. Home and results pages are a calm single column. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --sunken: #eef1f6;
  --fg: #18202e;
  --muted: #586274;
  --line: #d6dce6;
  --accent: #1f4f8f;
  --accent-soft: #e3ebf7;
  --accent-ink: #ffffff;
  --mark: #b45309;
  --mark-soft: #fdf0e1;
  --good: #1d7448;
  --good-soft: #e3f3ea;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --hl: #fff1a8;
  --c1: #1f4f8f;
  --c2: #b45309;
  --c3: #1d7448;
  --c4: #7a3e9d;
  --shadow: 0 1px 2px rgba(20, 32, 54, .06), 0 6px 20px rgba(20, 32, 54, .08);
  --font-ui: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-read: "Literata", "Georgia", "Times New Roman", serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-display: "Fraunces", "Georgia", serif;
  --bar-h: 56px;
  --foot-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10141b; --surface: #171c25; --sunken: #1d2330; --fg: #e5e9f0; --muted: #9aa4b5; --line: #2b3342;
    --accent: #86abe3; --accent-soft: #1f2c42; --accent-ink: #0c1320; --mark: #f0a04b; --mark-soft: #3a2a17;
    --good: #61c48f; --good-soft: #17301f; --bad: #f2867c; --bad-soft: #3a1c1a; --hl: #4d4520;
    --c1: #86abe3; --c2: #f0a04b; --c3: #61c48f; --c4: #c79be6;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #10141b; --surface: #171c25; --sunken: #1d2330; --fg: #e5e9f0; --muted: #9aa4b5; --line: #2b3342;
  --accent: #86abe3; --accent-soft: #1f2c42; --accent-ink: #0c1320; --mark: #f0a04b; --mark-soft: #3a2a17;
  --good: #61c48f; --good-soft: #17301f; --bad: #f2867c; --bad-soft: #3a1c1a; --hl: #4d4520;
  --c1: #86abe3; --c2: #f0a04b; --c3: #61c48f; --c4: #c79be6;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font-ui); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
a { color: var(--accent); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- generic pieces ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--fg);
  font-weight: 700; font-size: 15px; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 700; background: var(--sunken); color: var(--muted);
}
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- home ---------- */
.page { min-height: 100%; display: flex; flex-direction: column; }
.wrap {
  width: 100%; max-width: 1080px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.site-head { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-family: var(--font-num); font-size: 14px; font-weight: 700;
}
.theme-toggle { min-height: 36px; padding: 0 12px; }
.hero { padding-block: 44px 28px; }
.hero h1 {
  font-family: var(--font-display); font-weight: 600; font-size: clamp(30px, 5vw, 46px);
  line-height: 1.1; letter-spacing: -.02em; margin: 0 0 12px; text-wrap: balance; max-width: 22ch;
}
.hero p { margin: 0; color: var(--muted); font-size: 18px; max-width: 60ch; }
.exam-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; padding-block: 8px 32px; }
.exam-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px;
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.exam-card header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.exam-card h2 { margin: 0; font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: -.01em; }
.exam-card .sub { color: var(--muted); font-size: 15px; margin: 0; }
.spec { width: 100%; border-collapse: collapse; font-size: 14px; }
.spec td { padding: 7px 0; border-top: 1px solid var(--line); vertical-align: top; }
.spec td:last-child { text-align: right; color: var(--muted); white-space: nowrap; padding-left: 10px; }
.spec tr.opt td:first-child::after { content: " · optional"; color: var(--muted); font-size: 12px; }
.exam-card .actions { margin-top: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.resume-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px; padding: 14px 18px; margin-top: 8px;
}
.section-title { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin: 8px 0 12px; }
.history { display: grid; gap: 8px; padding-bottom: 32px; }
.hist-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
}
.hist-row .score { font-family: var(--font-num); font-weight: 700; font-size: 18px; }
.hist-row .when { color: var(--muted); font-size: 13px; }
.empty-note { color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 16px; }
.site-foot { margin-top: auto; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.site-foot .wrap { padding-block: 18px 28px; }

/* ---------- setup / intro screens ---------- */
.setup { max-width: 760px; margin: 0 auto; padding-block: 32px 48px; display: grid; gap: 20px; }
.setup h1 { font-family: var(--font-display); font-size: clamp(28px, 4vw, 38px); margin: 0; font-weight: 600; text-wrap: balance; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.panel h3 { margin: 0 0 8px; font-size: 17px; }
.opt-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.opt-row:first-of-type { border-top: 0; }
.opt-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.opt-row label { cursor: pointer; }
.opt-row small { display: block; color: var(--muted); }
.plan-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0; }
.plan-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.plan-list li:first-child { border-top: 0; }
.plan-list .t { color: var(--muted); white-space: nowrap; }
.directions { font-family: var(--font-read); font-size: 16.5px; line-height: 1.65; }
.directions p { margin: 0 0 12px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- test shell ---------- */
.test { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--surface); padding-top: env(safe-area-inset-top, 0px); }
.tbar {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  min-height: var(--bar-h); border-bottom: 2px dashed var(--line); background: var(--surface);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.tbar .left { min-width: 0; }
.tbar .part-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbar .dir-btn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 700; font-size: 13.5px; display: inline-flex; align-items: center; gap: 4px; }
.timer { display: flex; flex-direction: column; align-items: center; gap: 0; }
.timer .clock { font-family: var(--font-num); font-size: 21px; font-weight: 700; letter-spacing: .02em; line-height: 1.2; }
.timer .clock.warn { color: var(--bad); }
.timer .hide { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; font-size: 12px; padding: 0 10px; min-height: 22px; }
.tools { display: flex; justify-content: flex-end; gap: 4px; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 1px; border: 0; background: none;
  font-size: 11.5px; font-weight: 700; color: var(--fg); padding: 4px 8px; border-radius: 8px;
}
.tool:hover { background: var(--sunken); }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

.tmain { flex: 1; min-height: 0; display: flex; }
.pane { min-width: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pane.left { flex: 1 1 50%; border-right: 4px solid var(--sunken); padding: 28px 32px 40px; }
.pane.right { flex: 1 1 50%; padding: 28px 32px 40px; }
.tmain.single .pane.right { flex: 1 1 100%; }
.tmain.single .qwrap { max-width: 720px; margin: 0 auto; }

.passage { font-family: var(--font-read); font-size: 17px; line-height: 1.75; max-width: 68ch; }
.passage p { margin: 0 0 14px; }
.passage h4 { font-family: var(--font-ui); font-size: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
.passage .p-title { font-family: var(--font-ui); font-weight: 700; font-size: 15px; margin: 0 0 4px; }
.passage .p-src { font-family: var(--font-ui); color: var(--muted); font-size: 14px; font-style: italic; margin: 0 0 16px; line-height: 1.5; }
.passage.numbered { counter-reset: para; }
.passage.numbered > p:not(.p-title):not(.p-src) { counter-increment: para; position: relative; }
.passage.numbered > p:not(.p-title):not(.p-src)::before {
  content: counter(para); position: absolute; left: -26px; top: 3px;
  font-family: var(--font-num); font-size: 11px; color: var(--muted);
}
.passage ul, .stim ul { margin: 0 0 14px; padding-left: 22px; }
.passage li, .stim li { margin-bottom: 6px; }
.ul { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; border-radius: 3px; cursor: pointer; }
.ul .qn, .qbox {
  display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 4px; margin-right: 4px;
  border: 1.5px solid var(--fg); border-radius: 4px; font-family: var(--font-num); font-size: 11.5px; font-weight: 700;
  text-decoration: none; vertical-align: 2px; line-height: 1; background: var(--surface);
}
.ul.cur { background: var(--hl); }
.ul.cur .qn, .qbox.cur { background: var(--fg); color: var(--surface); }
.stim { font-family: var(--font-read); font-size: 17px; line-height: 1.75; max-width: 68ch; }
.stim p { margin: 0 0 14px; }
.blank { display: inline-block; min-width: 70px; border-bottom: 1.5px solid currentColor; }

.figure { margin: 6px 0 18px; max-width: 100%; overflow-x: auto; }
.figure figcaption { font-family: var(--font-ui); font-size: 13.5px; font-weight: 700; margin-bottom: 6px; }
table.data { border-collapse: collapse; font-family: var(--font-ui); font-size: 14.5px; line-height: 1.35; margin: 4px 0 18px; }
table.data th, table.data td { border: 1px solid var(--line); padding: 6px 10px; text-align: center; }
table.data th { background: var(--sunken); font-weight: 700; }
table.data td { font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; max-width: 100%; }
svg.chart { width: 100%; max-width: 560px; height: auto; display: block; font-family: var(--font-ui); }
svg.chart .ax { stroke: var(--fg); stroke-width: 1.2; fill: none; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; fill: none; }
svg.chart text { fill: var(--fg); font-size: 12px; }
svg.chart text.lab { font-size: 12.5px; font-weight: 700; }
svg.chart text.tt { font-size: 13px; font-weight: 700; }
svg.chart .s0 { stroke: var(--c1); fill: var(--c1); }
svg.chart .s1 { stroke: var(--c2); fill: var(--c2); }
svg.chart .s2 { stroke: var(--c3); fill: var(--c3); }
svg.chart .s3 { stroke: var(--c4); fill: var(--c4); }
svg.chart path.line { fill: none; stroke-width: 2.2; }
svg.chart .bg { fill: var(--surface); stroke: var(--line); }
svg.geo { max-width: 300px; width: 100%; height: auto; display: block; margin: 4px auto 16px; }
svg.geo .ln { stroke: var(--fg); stroke-width: 1.6; fill: none; }
svg.geo .fill { fill: var(--accent-soft); stroke: var(--fg); stroke-width: 1.6; }
svg.geo .dash { stroke: var(--fg); stroke-width: 1.3; stroke-dasharray: 5 4; fill: none; }
svg.geo text { fill: var(--fg); font-family: var(--font-read); font-size: 15px; font-style: italic; }
svg.geo text.up { font-style: normal; font-family: var(--font-ui); font-size: 13px; }
svg.geo .dot { fill: var(--fg); }
.note-scale { font-size: 13px; color: var(--muted); font-style: italic; text-align: center; margin: -8px 0 14px; }

/* question */
.qhead {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--sunken); border-radius: 8px 8px 0 0; padding: 0 8px 0 0; border-bottom: 2px dashed var(--line);
  margin-bottom: 18px;
}
.qnum { background: var(--fg); color: var(--surface); font-family: var(--font-num); font-weight: 700; padding: 6px 12px; border-radius: 8px 0 0 0; font-size: 15px; }
.mark-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; font-weight: 700; font-size: 14px; padding: 6px 8px; border-radius: 6px; }
.mark-btn[aria-pressed="true"] { color: var(--mark); }
.mark-btn[aria-pressed="true"] .icon { fill: currentColor; }
.qhead .grow { flex: 1; display: flex; align-items: center; gap: 6px; }
.abc-btn { border: 1.5px solid var(--line); background: var(--surface); border-radius: 6px; font-weight: 700; font-size: 12px; padding: 3px 8px; position: relative; }
.abc-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.abc-btn s { text-decoration-thickness: 2px; }
.stem { font-family: var(--font-read); font-size: 17px; line-height: 1.7; margin-bottom: 18px; }
.stem p { margin: 0 0 12px; }
.choices { display: grid; gap: 12px; }
.choice-row { display: flex; align-items: stretch; gap: 8px; }
.choice {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); padding: 12px 14px;
  font-family: var(--font-read); font-size: 16.5px; line-height: 1.5; position: relative;
}
.choice:hover { border-color: var(--accent); }
.choice .letter {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--fg);
  display: grid; place-items: center; font-family: var(--font-ui); font-weight: 700; font-size: 14px;
}
.choice .ctext { min-width: 0; overflow-x: auto; }
.choice.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.choice.sel .letter { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice.struck .ctext, .choice.struck .letter { opacity: .4; }
.choice.struck::after { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; border-top: 2px solid var(--fg); opacity: .7; }
.strike {
  flex: none; width: 40px; border: 0; background: none; color: var(--muted); font-weight: 700; font-size: 13px; border-radius: 8px;
  display: grid; place-items: center;
}
.strike:hover { background: var(--sunken); color: var(--fg); }
.strike .letter-s { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid currentColor; display: grid; place-items: center; position: relative; }
.strike .letter-s::after { content: ""; position: absolute; left: -4px; right: -4px; top: 50%; border-top: 2px solid currentColor; }
.spr { display: grid; gap: 14px; max-width: 360px; }
.spr input {
  font-family: var(--font-num); font-size: 22px; padding: 10px 14px; border: 1.5px solid var(--fg); border-radius: 8px;
  background: var(--surface); width: 100%; border-bottom-width: 3px;
}
.spr .preview { color: var(--muted); font-size: 14px; }
.spr .preview b { color: var(--fg); font-family: var(--font-num); font-size: 18px; }
.spr-help { font-size: 14px; color: var(--muted); background: var(--sunken); border-radius: 10px; padding: 12px 14px; line-height: 1.55; }
.spr-help ul { margin: 6px 0 0; padding-left: 20px; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.1; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 3px; }

.tfoot {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  min-height: var(--foot-h); border-top: 2px dashed var(--line); background: var(--surface);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tfoot .who { color: var(--muted); font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qnav-btn { background: var(--fg); color: var(--surface); border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 700; font-size: 14.5px; display: inline-flex; align-items: center; gap: 8px; }
.tfoot .nav { display: flex; justify-content: flex-end; gap: 8px; }

/* popover / modal */
.scrim { position: fixed; inset: 0; background: rgba(10, 16, 28, .45); z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal {
  background: var(--surface); color: var(--fg); border-radius: 14px; box-shadow: var(--shadow); width: min(640px, 100%);
  max-height: min(84vh, 760px); overflow: auto; padding: 22px; border: 1px solid var(--line);
}
.modal h2 { margin: 0 0 12px; font-size: 20px; }
.modal .row-actions { margin-top: 18px; }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 10px; margin: 14px 0; }
.qcell {
  height: 42px; border: 1.5px dashed var(--muted); border-radius: 6px; background: var(--surface); font-weight: 700;
  font-family: var(--font-num); position: relative; color: var(--accent);
}
.qcell.ans { border: 1.5px solid var(--accent); background: var(--accent); color: var(--accent-ink); }
.qcell.mk::after { content: ""; position: absolute; top: -6px; right: -5px; width: 12px; height: 12px; border-radius: 0 0 2px 2px; background: var(--mark); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }
.qcell.cur::before { content: ""; position: absolute; left: 50%; top: -10px; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--fg); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; display: inline-block; border-radius: 3px; }
.lg-un { border: 1.5px dashed var(--muted); }
.lg-an { background: var(--accent); }
.lg-mk { background: var(--mark); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }

.review-page { max-width: 820px; margin: 0 auto; padding: 32px 0 40px; text-align: center; }
.review-page h1 { font-family: var(--font-display); font-weight: 600; font-size: 32px; margin: 0 0 6px; }
.review-page p { color: var(--muted); margin: 0 0 20px; }
.review-page .panel { text-align: left; }

.break-screen { max-width: 640px; margin: 0 auto; padding: 48px 0; display: grid; gap: 18px; text-align: center; justify-items: center; }
.break-clock { font-family: var(--font-num); font-size: 56px; font-weight: 700; }

.calc-panel {
  position: fixed; z-index: 30; left: max(12px, env(safe-area-inset-left, 0px)); top: calc(var(--bar-h) + 10px);
  width: min(460px, calc(100vw - 24px)); height: min(520px, calc(100vh - var(--bar-h) - var(--foot-h) - 30px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.calc-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; background: var(--fg); color: var(--surface); font-weight: 700; font-size: 14px; cursor: move; user-select: none; touch-action: none; }
.calc-head button { background: none; border: 0; color: inherit; font-size: 20px; line-height: 1; padding: 2px 8px; }
.calc-body { flex: 1; min-height: 0; }
.calc-fallback { padding: 18px; display: grid; gap: 12px; font-size: 15px; }

.ref-sheet { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.ref-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.ref-item b { display: block; margin-bottom: 4px; }
.ref-notes { font-size: 14px; color: var(--muted); margin-top: 12px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--foot-h) + 16px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--fg); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-weight: 700; font-size: 14px; z-index: 50; box-shadow: var(--shadow);
}

/* ---------- results ---------- */
.results { padding-block: 28px 56px; display: grid; gap: 22px; }
.score-hero { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: grid; gap: 18px; }
.score-hero .big { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.score-hero .big .v { font-family: var(--font-num); font-size: clamp(48px, 9vw, 72px); font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.score-hero .big .r { color: var(--muted); font-size: 15px; }
.score-hero h1 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 24px; }
.sec-scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.sec-score { border-top: 3px solid var(--accent); padding-top: 10px; }
.sec-score .n { font-size: 14px; color: var(--muted); font-weight: 700; }
.sec-score .v { font-family: var(--font-num); font-size: 30px; font-weight: 700; }
.sec-score .d { font-size: 13px; color: var(--muted); }
.disclaimer { font-size: 13px; color: var(--muted); }
.skills { display: grid; gap: 6px; }
.skill-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 54px; gap: 12px; align-items: center; font-size: 14.5px; padding: 6px 0; border-top: 1px solid var(--line); }
.skill-row .dom { font-size: 12px; color: var(--muted); }
.bar { height: 8px; border-radius: 99px; background: var(--sunken); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.skill-row .pct { font-family: var(--font-num); text-align: right; font-size: 13.5px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .chipbtn { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 13.5px; }
.filters .chipbtn[aria-pressed="true"] { background: var(--fg); color: var(--surface); border-color: var(--fg); }
.filters select { border: 1.5px solid var(--line); border-radius: 999px; padding: 5px 10px; background: var(--surface); font-weight: 700; font-size: 13.5px; }
.rv-list { display: grid; gap: 8px; }
.rv { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.rv > button {
  width: 100%; display: grid; grid-template-columns: 34px 52px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  border: 0; background: none; padding: 10px 14px; text-align: left;
}
.rv .st { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.rv .st.ok { background: var(--good-soft); color: var(--good); }
.rv .st.no { background: var(--bad-soft); color: var(--bad); }
.rv .st.na { background: var(--sunken); color: var(--muted); }
.rv .qn2 { font-family: var(--font-num); font-weight: 700; font-size: 14px; }
.rv .sk { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv .yr { font-family: var(--font-num); font-size: 13.5px; white-space: nowrap; }
.rv-body { border-top: 1px solid var(--line); padding: 16px 18px 20px; display: grid; gap: 14px; }
.rv-body .choice { cursor: default; }
.rv-body .choice.right { border-color: var(--good); box-shadow: 0 0 0 2px var(--good) inset; }
.rv-body .choice.right .letter { background: var(--good); border-color: var(--good); color: var(--surface); }
.rv-body .choice.wrong { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad) inset; }
.rv-body .choice.wrong .letter { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.exp { background: var(--sunken); border-radius: 10px; padding: 14px 16px; font-size: 15.5px; line-height: 1.6; }
.exp b.h { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.exp p { margin: 0 0 8px; }
.rv-passage { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; max-height: 360px; overflow: auto; background: var(--bg); }
.rv-passage .passage.numbered > p:not(.p-title):not(.p-src)::before { left: -20px; }
.rv-passage .passage.numbered { padding-left: 18px; }
.meta-line { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .tmain.split { flex-direction: column; }
  .tmain.split .pane.left { flex: 0 0 auto; max-height: 44%; border-right: 0; border-bottom: 4px solid var(--sunken); padding: 16px 18px 22px 36px; }
  .tmain.split .pane.right { flex: 1 1 auto; padding: 16px 18px 28px; }
  .pane.right { padding: 18px 16px 28px; }
  .tbar { grid-template-columns: minmax(0, 1fr) auto auto; }
  .tool .lbl { display: none; }
  .tool { padding: 6px; }
  .tfoot { grid-template-columns: auto 1fr; }
  .tfoot .who { display: none; }
  .tfoot .center { justify-self: start; }
  .passage, .stim, .stem { font-size: 16px; }
  .choice { font-size: 15.5px; padding: 10px 12px; gap: 10px; }
  .skill-row { grid-template-columns: minmax(0, 1fr) 80px 46px; }
  .rv > button { grid-template-columns: 30px 44px minmax(0, 1fr); }
  .rv .yr { grid-column: 3; }
}
@media (max-width: 480px) {
  .btn { padding: 0 14px; }
  .tfoot .nav .btn { padding: 0 12px; min-height: 38px; }
  .hist-row { grid-template-columns: 1fr auto; }
  .hist-row .acts { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
@media print { .tbar, .tfoot { display: none; } }

/* ---------- multiple tests on the home page ---------- */
.test-list { margin-top: auto; display: grid; gap: 8px; }
.test-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.test-row .tl { display: flex; flex-direction: column; min-width: 0; }
.test-row .best { font-size: 13px; color: var(--good); font-weight: 700; }
.test-row .best.muted { color: var(--muted); font-weight: 400; }
.directions .tip { font-family: var(--font-ui); font-size: 14.5px; color: var(--muted); background: var(--sunken); border-radius: 10px; padding: 10px 12px; margin: 6px 0 0; }

/* ---------- highlights and notes ---------- */
:root { --hl-y: #fff0a1; --hl-b: #cfe2ff; --hl-p: #ffd3e6; --hl-u: #1f4f8f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --hl-y: #5c5220; --hl-b: #23406b; --hl-p: #5e2a43; --hl-u: #86abe3; } }
:root[data-theme="dark"] { --hl-y: #5c5220; --hl-b: #23406b; --hl-p: #5e2a43; --hl-u: #86abe3; }
mark.hl { color: inherit; border-radius: 2px; cursor: pointer; padding: 0; }
mark.hl-y { background: var(--hl-y); }
mark.hl-b { background: var(--hl-b); }
mark.hl-p { background: var(--hl-p); }
mark.hl-u { background: transparent; text-decoration: underline; text-decoration-color: var(--hl-u); text-decoration-thickness: 2.5px; text-underline-offset: 4px; }
mark.hl.has-note { box-shadow: 0 2px 0 var(--mark); }
mark.hl.has-note + mark.hl.has-note { box-shadow: none; }
.hl-bar {
  position: fixed; z-index: 45; display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 12px;
  background: var(--fg); color: var(--surface); box-shadow: var(--shadow);
}
.hl-bar button { border: 0; background: none; color: inherit; border-radius: 8px; min-height: 34px; }
.hl-bar button:hover { background: rgba(255, 255, 255, .14); }
.hl-sw { width: 34px; display: grid; place-items: center; }
.hl-sw span { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .7); display: block; }
.sw-y span { background: #ffe066; }
.sw-b span { background: #8fbaff; }
.sw-p span { background: #ff9cc6; }
.sw-u span { background: none; border-radius: 0; border: 0; border-bottom: 3px solid currentColor; height: 14px; width: 18px; }
.hl-act { display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; font-weight: 700; font-size: 13px; }
.hl-act .icon { width: 17px; height: 17px; }
.note-quote { margin: 0 0 12px; padding: 8px 12px; border-left: 3px solid var(--mark); background: var(--sunken); font-family: var(--font-read); font-size: 15px; border-radius: 0 8px 8px 0; }
.note-ta { width: 100%; margin-top: 6px; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; background: var(--surface); color: var(--fg); resize: vertical; }
.note-ta:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* ---------- pacing ---------- */
.pacing .pace-intro { margin: -4px 0 10px; color: var(--muted); font-size: 14.5px; max-width: 70ch; }
.pace-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.pace-legend span { display: inline-flex; align-items: center; gap: 6px; }
.pace-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.pk-ok { background: var(--good); } .pk-no { background: var(--bad); } .pk-na { background: var(--line); }
.pk-tg { height: 0 !important; border-top: 2px dashed var(--fg); border-radius: 0 !important; width: 16px !important; }
.pace-part { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.pace-part h3 { margin: 0 0 6px; font-size: 15.5px; display: flex; gap: 8px; align-items: center; }
.pace-scroll { overflow-x: auto; max-width: 100%; }
.pace-chart { display: block; width: 100%; min-width: 560px; height: auto; font-family: var(--font-num); }
.pace-chart text { fill: var(--muted); font-size: 12px; }
.pace-chart .pg { stroke: var(--line); stroke-width: 1; }
.pace-chart .ptg { stroke: var(--fg); stroke-width: 1.5; stroke-dasharray: 5 4; }
.pace-chart .pb-ok { fill: var(--good); } .pace-chart .pb-no { fill: var(--bad); } .pace-chart .pb-na { fill: var(--line); }
.pace-notes { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--muted); display: grid; gap: 2px; }
.rv .tm { color: var(--muted); }

/* ---------- explanation language ---------- */
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface); }
.seg button { border: 0; background: none; border-radius: 999px; padding: 5px 12px; font-weight: 700; font-size: 13.5px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.exp.zh { font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", var(--font-ui); line-height: 1.75; }

/* ---------- site navigation ---------- */
.site-nav, .pr-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.site-nav a, .pr-nav a { color: var(--fg); text-decoration: none; font-weight: 700; font-size: 14.5px; padding: 6px 10px; border-radius: 999px; }
.site-nav a:hover, .pr-nav a:hover { background: var(--sunken); }
.site-nav a[aria-current="page"], .pr-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.hero-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- practice page ---------- */
.pr-main { padding-block: 22px 48px; display: grid; gap: 16px; }
.pr-intro h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 4vw, 34px); margin: 0 0 4px; text-wrap: balance; }
.pr-intro p { margin: 0; color: var(--muted); max-width: 70ch; }
.pr-controls { display: grid; gap: 14px; }
.pr-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.pr-field { display: grid; gap: 4px; min-width: 0; }
.pr-field.grow { flex: 1 1 260px; }
.pr-field select { border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--surface); font-weight: 700; font-size: 14.5px; max-width: 100%; }
.pr-exam button { padding: 7px 16px; }
.pr-stats { justify-content: space-between; align-items: center; }
.pr-score { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.pr-score b { color: var(--fg); }
.pr-tools { align-items: flex-start; }
.pr-ref { flex: 1 1 100%; }
.pr-ref summary { list-style: none; display: inline-flex; }
.pr-ref summary::-webkit-details-marker { display: none; }
.pr-ref .panel { margin-top: 10px; }
.pr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.pr-cell { height: 36px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface); font-family: var(--font-num); font-weight: 700; font-size: 13.5px; color: var(--fg); }
.pr-cell.st-ok { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.pr-cell.st-no { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.pr-cell.st-rev { background: var(--mark-soft); border-color: var(--mark); color: var(--mark); }
.pr-cell.cur { outline: 3px solid var(--accent); outline-offset: 1px; }
.pr-cell.dim { opacity: .35; cursor: default; }
.pr-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pr-stage.solo { grid-template-columns: minmax(0, 760px); justify-content: center; }
.pr-passage { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; padding: 22px 24px; }
.pr-passage .passage.numbered { padding-left: 22px; }
.pr-passage .passage.numbered > p:not(.p-title):not(.p-src)::before { left: -24px; }
.pr-q { display: grid; gap: 14px; padding: 20px 22px; min-width: 0; }
.pr-qhead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pr-qhead .qnum { border-radius: 8px; }
.pr-meta { font-size: 13.5px; color: var(--muted); font-weight: 700; flex: 1; }
.pr-time { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; color: var(--muted); }
.pr-q .stem { margin: 0; }
.pr-q .choice[disabled] { cursor: default; opacity: 1; }
.pr-q .choice.right { border-color: var(--good); box-shadow: 0 0 0 2px var(--good) inset; }
.pr-q .choice.right .letter { background: var(--good); border-color: var(--good); color: var(--surface); }
.pr-q .choice.wrong { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad) inset; }
.pr-q .choice.wrong .letter { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.pr-verdict { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; padding: 12px 14px; border-radius: 10px; font-size: 15px; }
.pr-verdict b:first-child { font-size: 16px; }
.pr-verdict.ok { background: var(--good-soft); color: var(--good); }
.pr-verdict.no { background: var(--bad-soft); color: var(--bad); }
.pr-verdict.rev { background: var(--mark-soft); color: var(--mark); }
.pr-verdict span { color: var(--fg); }
.pr-actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding-top: 4px; border-top: 1px solid var(--line); }
.pr-actions .btn .icon { width: 16px; height: 16px; }
.pr-pos { margin: 0; font-size: 12.5px; color: var(--muted); text-align: center; }
@media (max-width: 860px) {
  .pr-stage { grid-template-columns: minmax(0, 1fr); }
  .pr-passage { position: static; max-height: 46vh; padding: 16px 16px 16px 18px; }
  .pr-q { padding: 16px; }
}
@media (max-width: 600px) {
  .pr-intro p { display: none; }
  .pr-grid { grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 5px; }
  .pr-cell { height: 32px; font-size: 12.5px; }
  .pr-controls { gap: 10px; padding: 16px; }
  .pr-stats { gap: 8px; }
}
