/* SHSAT Simulation styles: the test player's layout (toolbar, breadcrumb bar, question
   card, tools) in the A.C.K. Academy website's look. Tokens, fonts and the graph-paper
   grid are copied from ackacademy-next/app/globals.css; keep them in step with it. */

@font-face { font-family: "CMU Serif"; src: url("fonts/cmu-serif-roman.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "CMU Serif"; src: url("fonts/cmu-serif-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "CMU Serif"; src: url("fonts/cmu-serif-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

/* ---------- design tokens (from the website) ---------- */
:root {
  --paper: #fbf8f1;
  --paper-raised: #f4efe3;
  --paper-sunk: #efe8d8;
  --ink: #24211d;
  --ink-soft: #4a453d;
  --muted: #6f695f;
  --rule: #e2dac8;
  /* Apricot is the highlight (fills, underlines, never text); sienna is the colored text. */
  --accent: #f2b400;
  --accent-soft: #fcecb8;
  --accent-ink: #b54a1a;
  --sienna: #c9541e;
  --blue: #2b2f8c;
  --green: #138a78;
  --on-ink: #fbf8f1;
  --art-filter: none;
  --grid-line: rgb(36 33 29 / 0.032);
  --shadow: 0 1px 0 var(--rule), 0 18px 40px -24px rgb(36 33 29 / 0.35);
  --serif: "Newsreader", ui-serif, Georgia, serif;
  --display: "CMU Serif", "Latin Modern Roman", ui-serif, Georgia, serif;
  --sans: "Inter", ui-sans-serif, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  /* Deep plum, not black: cream ink on violet paper, as on the website. */
  :root {
    --paper: #241a38;
    --paper-raised: #2e2346;
    --paper-sunk: #1c142d;
    --ink: #f7efe2;
    --ink-soft: #ddd2e3;
    --muted: #ada1c2;
    --rule: #3f325a;
    --accent: #f7c65a;
    --accent-soft: #4a3746;
    --accent-ink: #ff9e7a;
    --sienna: #ff9e7a;
    --blue: #aab0ff;
    --green: #63dcc4;
    --on-ink: #241a38;
    --art-filter: invert(0.93) hue-rotate(180deg);
    --grid-line: rgb(247 239 226 / 0.045);
    --shadow: 0 1px 0 var(--rule), 0 18px 40px -20px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 1.0625rem; line-height: 1.5;
  font-optical-sizing: auto; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: var(--sans); color: inherit; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
a { color: inherit; }
.graph-paper {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(to right, var(--grid-line) 1px, transparent 1px), linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px; background-position: -1px -1px;
}
.eyebrow { font-family: var(--sans); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-ink); margin: 0 0 12px; }
.display { font-family: var(--display); font-weight: 400; letter-spacing: -0.01em; line-height: 1.08; margin: 0; }
.display em { font-style: italic; }
.lead { font-size: 1.25rem; line-height: 1.55; color: var(--ink-soft); max-width: 40rem; margin: 18px 0 0; }
.small { font-family: var(--sans); font-size: 0.8125rem; color: var(--muted); margin: 0; }
.center { text-align: center; }

/* ---------- buttons (the website's Button.tsx) ---------- */
.btn-primary, .btn-ghost, .btn-accent {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 3px; padding: 12px 20px; font-family: var(--sans); font-size: 0.875rem; font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer; transition: background 0.2s, filter 0.2s, transform 0.1s; text-decoration: none;
}
.btn-primary { background: var(--ink); color: var(--on-ink); border: 1px solid var(--ink); }
.btn-primary:hover { background: var(--ink-soft); }
.btn-ghost { background: var(--paper); color: var(--ink); border: 1px solid color-mix(in srgb, var(--ink) 80%, transparent); }
.btn-ghost:hover { background: var(--paper-raised); }
.btn-primary:active, .btn-ghost:active { transform: scale(0.98); }
.big { padding: 16px 28px; font-size: 1rem; }

/* ---------- toolbar ---------- */
.header {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper); border-bottom: 1px solid var(--rule);
  background-image: linear-gradient(to right, var(--grid-line) 1px, transparent 1px), linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px; background-position: -1px -1px; background-attachment: fixed;
}
.header-in { max-width: 76rem; margin: 0 auto; display: flex; align-items: center; gap: 14px; padding: 10px 16px; min-height: 64px; }
.header .spacer { flex: 1; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand .mark { width: 40px; height: 40px; filter: var(--art-filter); }
.brand .wordmark { font-family: var(--display); font-size: 1.35rem; line-height: 1; white-space: nowrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; position: relative;
  height: 40px; min-width: 42px; padding: 0 12px; border-radius: 3px;
  border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 0.875rem; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.btn:hover:not(:disabled) { background: var(--paper-raised); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.navgroup, .toolgroup { display: flex; }
.navgroup .btn { width: 48px; border-radius: 0; height: 42px; }
.navgroup .btn:first-child { border-radius: 3px 0 0 3px; }
.navgroup .btn:last-child { border-radius: 0 3px 3px 0; margin-left: -1px; }
.btn.next:not(:disabled) { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.btn.next:hover:not(:disabled) { background: var(--ink-soft); }
.toolgroup .btn { border-radius: 0; width: 42px; padding: 0; margin-left: -1px; }
.toolgroup .btn:first-child { border-radius: 3px 0 0 3px; margin-left: 0; }
.toolgroup .btn:last-child { border-radius: 0 3px 3px 0; }
.btn.pressed, .btn.pressed:hover { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.timerbox { display: flex; align-items: center; }
.timertext {
  height: 40px; display: flex; align-items: center; padding: 0 12px;
  font-family: var(--sans); font-size: 0.9375rem; font-weight: 600; font-variant-numeric: tabular-nums;
  border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); border-right: 0; border-radius: 3px 0 0 3px; background: var(--paper-raised);
}
.timertext + .btn { border-radius: 0 3px 3px 0; }
.timertext.low { color: var(--sienna); }
.username { font-family: var(--sans); font-size: 0.875rem; font-weight: 600; color: var(--ink-soft); }
@media (hover: hover) {
  [data-tip]:hover::after {
    content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    background: var(--ink); color: var(--on-ink); font-family: var(--sans); font-size: 0.75rem; font-weight: 600;
    padding: 5px 8px; border-radius: 3px; white-space: nowrap; z-index: 200; pointer-events: none;
  }
}

/* ---------- breadcrumb bar ---------- */
.crumbs { background: var(--paper-raised); border-bottom: 1px solid var(--rule); }
.crumbs-in {
  max-width: 76rem; margin: 0 auto; min-height: 38px; padding: 0 16px; display: flex; align-items: center; flex-wrap: wrap;
  font-family: var(--sans); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-ink);
}
.crumbs .sep { margin: 0 12px; color: var(--muted); }
.crumbs .spacer { flex: 1; }
.battery { width: 26px; height: 13px; border: 1.5px solid var(--ink-soft); border-radius: 3px; position: relative; padding: 1px; }
.battery::after { content: ""; position: absolute; right: -4px; top: 3px; width: 2px; height: 4px; background: var(--ink-soft); border-radius: 0 2px 2px 0; }
.battery i { display: block; height: 100%; background: var(--ink-soft); border-radius: 1px; }

/* ---------- pages ---------- */
.stage { position: relative; max-width: 76rem; margin: 0 auto; padding: 36px 16px 96px; }
.card {
  position: relative; max-width: 760px; margin: 0 auto;
  background: var(--card-bg, var(--paper)); color: var(--card-fg, var(--ink));
  border: 1px solid var(--rule); border-radius: 6px; box-shadow: var(--shadow); padding: 28px 32px 30px;
}
.card.wide { max-width: 960px; }
.qnum { font-family: var(--sans); font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 14px; }
.item-body { font-size: 1.1875rem; line-height: 1.55; }
.item-body p { margin: 0 0 14px; }
.item-body img.fig, .modal img.fig { display: block; margin: 8px auto 16px; max-width: 100%; height: auto; filter: var(--art-filter); }
.katex { font-size: 1.08em; }
.choices { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.choice {
  position: relative; display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 8px 16px 8px 10px;
  width: fit-content; min-width: min(100%, 300px); max-width: 100%;
  border: 1px solid var(--rule); border-radius: 4px; cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.choice:hover { background: var(--paper-raised); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .letter {
  flex: none; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border: 1.5px solid color-mix(in srgb, currentColor 70%, transparent); border-radius: 50%;
  font-family: var(--sans); font-size: 0.8125rem; font-weight: 600;
}
.choice.picked { border-color: var(--accent); background: var(--accent-soft); }
.choice.picked .letter { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.choice input:focus-visible + .letter { outline: 2px solid var(--accent); outline-offset: 2px; }
.choice .content p { margin: 0; }
.choice .content img.fig { margin: 4px 0; }
.choice.eliminated { cursor: default; }
.choice.eliminated .content, .choice.eliminated .letter { opacity: 0.4; }
.choice .xmark { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.answer-prompt { font-family: var(--sans); font-size: 0.875rem; font-weight: 600; color: var(--ink-soft); margin: 18px 0 8px; }
.text-answer {
  width: 150px; height: 46px; padding: 4px 12px; font-size: 1.125rem; font-weight: 500;
  background: var(--paper); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 3px;
}
.text-answer:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
mark.hl-blue, .hl-pop i.hl-blue { background: color-mix(in srgb, var(--blue) 24%, transparent); color: inherit; }
mark.hl-pink, .hl-pop i.hl-pink { background: color-mix(in srgb, var(--accent) 45%, transparent); color: inherit; }

/* ---------- welcome ---------- */
.welcome { padding-top: 56px; }
.welcome h1 { font-size: clamp(2.75rem, 7vw, 4.75rem); }
.welcome-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; margin-top: 40px; align-items: start; }
.facts { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.facts div { padding: 22px 16px 22px 0; }
.facts div + div { padding-left: 16px; border-left: 1px solid var(--rule); }
.facts dt { font-family: var(--display); font-size: 2rem; line-height: 1.1; }
.facts dd { margin: 6px 0 0; font-family: var(--sans); font-size: 0.8125rem; color: var(--muted); }
.signin { display: flex; flex-direction: column; gap: 12px; padding: 24px; background: var(--paper-raised); border: 1px solid var(--rule); border-radius: 6px; }
.field-label { font-family: var(--sans); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent-ink); }
.signin input { height: 48px; padding: 0 14px; font-size: 1rem; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 3px; }
.signin input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
.rules { list-style: none; margin: 48px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.rules li { border-top: 2px solid var(--accent); padding-top: 14px; color: var(--ink-soft); }
.rules b { display: block; font-family: var(--display); font-weight: 400; font-size: 1.35rem; color: var(--ink); margin-bottom: 4px; }
.site-foot { max-width: 76rem; margin: 0 auto; padding: 22px 16px 34px; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; font-family: var(--sans); font-size: 0.8125rem; color: var(--muted); }
.site-foot a { color: var(--ink); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }

/* ---------- mode choice ---------- */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 6px; }
.mode {
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; text-align: left;
  padding: 14px; border: 1.5px solid var(--rule); border-radius: 6px; background: var(--paper); color: var(--ink); cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.mode svg { grid-row: span 2; color: var(--muted); }
.mode b { font-family: var(--display); font-weight: 400; font-size: 1.5rem; line-height: 1.1; }
.mode span { grid-column: 2; font-size: 0.8125rem; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.mode:hover { border-color: color-mix(in srgb, var(--ink) 45%, transparent); }
.mode.on { border-color: var(--ink); background: var(--accent-soft); box-shadow: inset 0 -3px 0 var(--accent); }
.mode.on svg { color: var(--ink); }
.mode.on span { color: var(--ink-soft); }

/* ---------- Prep ---------- */
.prep-setup h2 { font-size: clamp(2rem, 5vw, 2.75rem); }
.prep-setup .intro { color: var(--ink-soft); margin: 10px 0 22px; }
.strand-list { display: grid; gap: 8px; }
.topic { border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); }
.topic[open] { background: var(--paper-raised); }
.topic summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; }
.topic summary::-webkit-details-marker { display: none; }
.topic summary::after { content: ""; width: 8px; height: 8px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); margin: -4px 4px 0 0; transition: transform 0.15s; }
.topic[open] summary::after { transform: rotate(225deg); margin-top: 4px; }
.topic summary label { flex: 1; display: flex; align-items: center; gap: 10px; font-family: var(--sans); font-size: 0.9375rem; cursor: pointer; }
.topic summary b { font-weight: 600; }
.topic ul { list-style: none; margin: 0; padding: 2px 14px 12px 40px; }
.topic li { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 1rem; }
.topic li label { flex: 1; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.topic input[type=checkbox], .pace input { width: 17px; height: 17px; accent-color: var(--ink); flex: none; }
.acc { font-family: var(--sans); font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.prep-options { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px; margin: 22px 0 6px; }
.count-pick { display: flex; align-items: center; gap: 8px; }
.count-pick .field-label { margin-right: 6px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 38px; padding: 0 12px; border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent); border-radius: 999px; font-family: var(--sans); font-size: 0.875rem; font-weight: 600; cursor: pointer; }
.chip input:checked + span { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pace { display: flex; align-items: center; gap: 10px; font-family: var(--sans); font-size: 0.875rem; color: var(--ink-soft); cursor: pointer; }
.prep-error { font-family: var(--sans); font-size: 0.875rem; font-weight: 600; color: var(--sienna); min-height: 1.2em; margin: 6px 0 0; }
.bd-header { max-width: 760px; margin: 0 auto 12px; padding: 10px 14px; border: 1px solid var(--rule); border-left: 3px solid var(--accent); border-radius: 4px; background: var(--paper-raised); font-family: var(--sans); font-size: 0.875rem; color: var(--ink-soft); }
.bd-header b { color: var(--ink); margin-right: 6px; }
.prep-panel { max-width: 760px; margin: 16px auto 0; }
.prep-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin: 0; }
.feedback { border-radius: 6px; padding: 12px 16px; margin-bottom: 12px; font-size: 1.0625rem; line-height: 1.5; border: 1px solid; }
.feedback b { font-family: var(--sans); font-size: 0.9375rem; margin-right: 4px; }
.feedback.right { background: color-mix(in srgb, var(--green) 12%, var(--paper)); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.feedback.right b { color: var(--green); }
.feedback.hint { background: var(--accent-soft); border-color: var(--accent); }
.feedback.wrong { background: color-mix(in srgb, var(--sienna) 10%, var(--paper)); border-color: color-mix(in srgb, var(--sienna) 45%, transparent); }
.feedback.wrong b { color: var(--sienna); }
.solution-card { margin: 0 0 12px; max-width: none; }
.choice.is-right { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--paper)); }
.choice.is-right .letter { background: var(--green); border-color: var(--green); color: var(--paper); }
.choice.is-wrong { border-color: var(--sienna); background: color-mix(in srgb, var(--sienna) 10%, var(--paper)); }
.choice.is-wrong .letter { background: var(--sienna); border-color: var(--sienna); color: var(--paper); }
.choice.is-right, .choice.is-wrong { cursor: default; }
.prep-done .muted { color: var(--muted); }

/* ---------- section start, loading ---------- */
.section-start { max-width: 420px; margin: 40px auto; text-align: center; background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; box-shadow: var(--shadow); padding: 34px 28px 30px; }
.section-start h2 { font-size: 2.75rem; }
.section-start .count { font-family: var(--sans); font-size: 0.875rem; color: var(--muted); margin: 14px 0 26px; }
.section-start .count b { color: var(--ink); }
.loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--paper) 55%, transparent); z-index: 400; }
.loading .box { width: 280px; background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; box-shadow: var(--shadow); text-align: center; padding: 18px 18px 16px; font-family: var(--sans); font-size: 0.875rem; font-weight: 600; }
.loading .bar { height: 3px; background: var(--rule); margin-top: 16px; position: relative; overflow: hidden; border-radius: 2px; }
.loading .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); animation: load 1.2s ease-out forwards; }
@keyframes load { to { width: 100%; } }

/* ---------- directions ---------- */
.directions { text-align: center; }
.directions h1 { font-size: clamp(2rem, 5vw, 2.75rem); }
.directions .sub { font-family: var(--sans); color: var(--muted); margin: 8px 0 0; }
.directions .panel { text-align: left; border-top: 1px solid var(--rule); margin-top: 26px; padding: 22px 8px 0; font-size: 1.125rem; }
.directions .panel h4 { font-family: var(--display); font-weight: 400; font-size: 1.6rem; margin: 0 0 12px; }
.directions .part { margin-left: 16px; line-height: 1.6; }
.directions .part .q { margin: 10px 0 0 28px; color: var(--ink-soft); }
.directions li { margin-bottom: 10px; }
.directions li::marker, .math-notes li::marker { color: var(--accent-ink); }
.math-notes { font-size: 1.125rem; line-height: 1.6; }
.math-notes h3 { font-family: var(--display); font-weight: 400; font-size: 1.6rem; margin: 0 0 12px; }
.math-notes h3 + p { margin-top: 0; }
.math-notes ol { margin: 0 0 26px; padding-left: 22px; }
.math-notes li { margin-bottom: 12px; }
.end-section h2 { font-size: 2.25rem; margin-bottom: 14px; }
.review-list { list-style: none; padding: 0; margin: 14px 0 0; columns: 2; font-family: var(--sans); font-size: 0.9375rem; }
.review-list li { padding: 5px 0; break-inside: avoid; }
.review-list a { color: var(--ink); cursor: pointer; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--sienna); margin-left: 6px; vertical-align: 1px; }

/* ---------- results ---------- */
.results h1, .prep-done h1 { font-size: clamp(2.5rem, 6vw, 4rem); }
.strands { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 30px 0 26px; }
.strand { position: relative; padding: 14px 14px 18px; background: var(--paper-raised); border: 1px solid var(--rule); border-radius: 6px; font-family: var(--sans); font-size: 0.8125rem; color: var(--muted); overflow: hidden; }
.strand b { display: block; font-family: var(--display); font-weight: 400; font-size: 1.6rem; color: var(--ink); margin-top: 4px; }
.strand i { position: absolute; left: 0; bottom: 0; height: 4px; width: var(--p); background: var(--accent); }
.table-wrap { overflow-x: auto; }
.results table, .prep-done table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.875rem; }
.results th, .prep-done th { text-align: left; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); padding: 0 10px 10px; border-bottom: 1px solid var(--rule); }
.results td, .prep-done td { padding: 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.results tr:last-child td, .prep-done tr:last-child td { border-bottom: 0; }
.results .ok, .prep-done .ok { color: var(--green); font-weight: 600; }
.results .no, .prep-done .no { color: var(--sienna); font-weight: 600; }
.results .why { font-family: var(--serif); font-style: italic; color: var(--ink-soft); font-size: 0.9375rem; min-width: 200px; }
.linkbtn { border: 0; background: none; color: var(--ink); cursor: pointer; font-weight: 600; padding: 0; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }

/* ---------- dropdowns ---------- */
.dropdown { position: absolute; z-index: 120; background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; box-shadow: var(--shadow); font-family: var(--sans); }
.usermenu { right: 16px; top: 62px; min-width: 300px; padding: 6px 0; }
.usermenu a { display: block; padding: 9px 16px; font-size: 0.875rem; font-weight: 500; cursor: pointer; color: var(--ink); }
.usermenu a:hover { background: var(--paper-raised); }
.usermenu hr { border: 0; border-top: 1px solid var(--rule); margin: 6px 0; }
.reviewmenu { width: 520px; top: 60px; overflow: hidden; }
.reviewtabs { display: flex; border-bottom: 1px solid var(--rule); background: var(--paper-raised); }
.reviewtabs button { flex: 1; border: 0; border-right: 1px solid var(--rule); background: transparent; padding: 12px 6px; cursor: pointer; font-size: 0.8125rem; font-weight: 600; color: var(--ink-soft); }
.reviewtabs button:last-child { border-right: 0; }
.reviewtabs button.on { background: var(--paper); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.reviewtabs .num { display: block; margin: 0 auto 6px; width: 40px; height: 40px; line-height: 38px; font-family: var(--display); font-size: 1.25rem; font-weight: 400; border: 1px solid var(--rule); border-radius: 6px; background: var(--paper); color: var(--ink); }
.reviewtabs .num.na { border-radius: 50%; border-color: var(--sienna); color: var(--sienna); }
.reviewtabs .num.bm { background: var(--accent); color: #24211d; border: 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%); border-radius: 0; }
.reviewlist { list-style: none; margin: 0; padding: 6px 0; min-height: 320px; max-height: 60vh; overflow: auto; }
.reviewlist li { padding: 10px 20px 10px 58px; font-size: 0.9375rem; font-weight: 500; cursor: pointer; position: relative; }
.reviewlist li.current { background: var(--ink); color: var(--on-ink); }
.reviewlist li:hover:not(.current) { background: var(--paper-raised); }
.reviewlist li .mk { position: absolute; left: 22px; top: 12px; display: flex; gap: 4px; align-items: center; }

/* ---------- modals ---------- */
.backdrop { position: fixed; inset: 0; background: rgb(36 33 29 / 0.28); z-index: 300; }
.modal { position: fixed; z-index: 310; background: var(--paper); color: var(--ink); border: 1px solid var(--rule); border-radius: 8px; box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.45); overflow: hidden; }
.modal .mhead { display: flex; align-items: center; padding: 14px 18px 12px; border-bottom: 1px solid var(--rule); cursor: move; }
.modal .mhead h3 { margin: 0; flex: 1; font-family: var(--display); font-weight: 400; font-size: 1.4rem; }
.modal .mclose { border: 0; background: none; font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 4px; color: var(--muted); }
.modal .mclose:hover { color: var(--ink); }
.modal .mbody { padding: 16px 18px; font-size: 1.0625rem; }
.modal .mfoot { padding: 0 18px 18px; display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.modal.notepad textarea { display: block; width: 100%; height: 380px; resize: none; font-size: 0.9375rem; line-height: 1.5; padding: 10px; background: var(--paper-raised); border: 1px solid var(--rule); border-radius: 4px; }
.modal.solution .tabs { border-bottom: 1px solid var(--rule); margin-bottom: 14px; }
.modal.solution .tabs span { display: inline-block; padding: 8px 2px; font-family: var(--sans); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-ink); box-shadow: inset 0 -2px 0 var(--accent); }
.modal.solution .mbody { max-height: 62vh; overflow: auto; line-height: 1.6; }
.contrast-list label { display: flex; align-items: center; gap: 10px; padding: 7px 4px; font-family: var(--sans); font-size: 0.875rem; cursor: pointer; }
.contrast-list .sample { display: inline-block; border: 1px solid var(--muted); padding: 0 6px; font-weight: 700; border-radius: 2px; }

/* ---------- pencil and highlighter ---------- */
.pencil-canvas { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.pencil-canvas.on { pointer-events: auto; cursor: crosshair; }
.pencil-bar { position: fixed; right: 6px; top: 240px; z-index: 60; display: flex; flex-direction: column; border-radius: 6px; overflow: visible; box-shadow: var(--shadow); }
.pencil-bar button { width: 44px; height: 44px; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--on-ink) 18%, transparent); background: var(--ink); color: var(--on-ink); cursor: pointer; display: flex; align-items: center; justify-content: center; position: relative; }
.pencil-bar button:first-child { border-radius: 6px 6px 0 0; }
.pencil-bar button:last-child { border-radius: 0 0 6px 6px; border-bottom: 0; }
.pencil-bar button.active { background: var(--accent); color: #24211d; }
.pencil-bar button:disabled { opacity: 0.45; cursor: default; }
.pencil-bar svg { width: 19px; height: 19px; }
.pencil-bar [data-tip]:hover::after { top: 50%; left: auto; right: calc(100% + 8px); transform: translateY(-50%); }
.hl-pop { position: absolute; z-index: 130; display: flex; gap: 3px; padding: 4px; background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; box-shadow: var(--shadow); }
.hl-pop button { width: 38px; height: 30px; border: 1px solid var(--rule); border-radius: 4px; background: var(--paper); color: var(--ink-soft); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.hl-pop button:hover { background: var(--paper-raised); }
.hl-pop i { display: block; width: 16px; height: 16px; border-radius: 3px; }

/* ---------- magnifier and line reader ---------- */
.magnifier { position: fixed; width: 202px; height: 202px; border: 1px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--paper); z-index: 250; cursor: move; box-shadow: var(--shadow); }
.magnifier .magcontent { position: absolute; left: 0; top: 0; transform-origin: 0 0; transform: scale(2); pointer-events: none; background: var(--paper); }
.linereader { position: fixed; z-index: 240; display: grid; grid-template-columns: 20px 1fr 20px; grid-template-rows: 20px var(--view, 30px) 25px 1fr; }
.linereader > div { background: color-mix(in srgb, #24211d 78%, transparent); }
.linereader .lr-top { grid-column: 1 / 4; border-radius: 6px 6px 0 0; }
.linereader .lr-view { background: transparent; outline: 2px solid var(--accent); }
.linereader .lr-ctrl { grid-column: 2; display: flex; align-items: center; justify-content: center; position: relative; color: #fbf8f1; }
.linereader .lr-bottom { grid-column: 1 / 4; position: relative; border-radius: 0 0 6px 6px; }
.linereader .lr-move { cursor: move; }
.linereader .lr-resize { position: absolute; right: 3px; bottom: 3px; cursor: nwse-resize; color: #fbf8f1; }
.linereader .lr-vresize { position: absolute; right: 4px; cursor: ns-resize; color: #fbf8f1; }

/* ---------- contrast settings (from the online test) ---------- */
body.c-black-cream { --card-bg: #fffacd; --card-fg: #000; }
body.c-black-lblue { --card-bg: #add8e6; --card-fg: #000; }
body.c-black-lmagenta { --card-bg: #ee82ee; --card-fg: #000; }
body.c-white-black { --card-bg: #000; --card-fg: #fff; }
body.c-yellow-blue { --card-bg: #0000cc; --card-fg: #f5e727; }
body.c-dgray-pgreen { --card-bg: #a3ad9e; --card-fg: #6e6e6e; }
body[class*="c-"] .card img.fig { filter: none; }
body.c-white-black .card img.fig, body.c-yellow-blue .card img.fig { filter: invert(1); }
body[class*="c-"] .choice { border-color: var(--card-fg); }
body[class*="c-"] .choice:hover { background: transparent; }
body[class*="c-"] .choice.picked { background: transparent; outline: 3px solid var(--card-fg); }
body[class*="c-"] .choice.picked .letter { background: var(--card-fg); border-color: var(--card-fg); color: var(--card-bg); }
body[class*="c-"] .qnum, body[class*="c-"] .answer-prompt { color: var(--card-fg); }
body[class*="c-"] .text-answer { background: #fff; color: #000; border-color: #000; }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .header-in { gap: 8px; flex-wrap: wrap; padding: 8px 12px; }
  .brand.compact { display: none; }
  .username, .battery { display: none; }
  .stage { padding: 24px 16px 88px; }
  .card { padding: 20px 18px 22px; }
  .welcome { padding-top: 32px; }
  .welcome-grid, .rules { grid-template-columns: 1fr; }
  .signin { order: -1; }
  .welcome-grid { margin-top: 28px; gap: 22px; }
  .modes { grid-template-columns: 1fr 1fr; }
  .mode { grid-template-columns: 1fr; padding: 12px; }
  .mode svg { grid-row: auto; margin-bottom: 4px; }
  .mode span { grid-column: 1; }
  .prep-buttons { justify-content: stretch; }
  .prep-buttons > * { flex: 1 1 auto; }
  .topic .acc { display: none; }
  .facts { grid-template-columns: 1fr 1fr 1fr; }
  .facts dt { font-size: 1.5rem; }
  .reviewmenu { width: calc(100vw - 24px); left: 12px !important; }
  .review-list { columns: 1; }
  .site-foot { flex-direction: column; gap: 6px; }
}
