/* SAT practice — Bluebook-adjacent, deliberately restrained.
   One stylesheet for the exam, the dashboard, review, and the teacher console. */

:root {
  --bg: #ffffff;
  --panel: #f7f8fa;
  --ink: #14181f;
  --muted: #5c6673;
  --line: #d8dde5;
  --line-strong: #b6bfcc;
  --accent: #1e4fd8;
  --accent-soft: #e8eeff;
  --good: #1a7f4b;
  --good-soft: #e6f5ec;
  --bad: #c02626;
  --bad-soft: #fdeaea;
  --warn: #a86400;
  --warn-soft: #fdf3e0;
  --mark: #f5c518;
  --hl: #fff2a8;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(20, 24, 31, .10), 0 6px 20px rgba(20, 24, 31, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    --bg: #14171c;
    --panel: #1c2027;
    --ink: #e6e9ee;
    --muted: #9aa4b2;
    --line: #2c323b;
    --line-strong: #3d4550;
    --accent: #7ea2ff;
    --accent-soft: #1e2740;
    --good: #57c98a;
    --good-soft: #16301f;
    --bad: #f08585;
    --bad-soft: #331a1a;
    --warn: #e0a94a;
    --warn-soft: #33270f;
    --hl: #6b5b12;
    --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 6px 20px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.55 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

button {
  font: inherit;
  font-weight: 550;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: .45em 1.1em;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
button.primary:hover:not(:disabled) { filter: brightness(1.08); color: #fff; }
button.ghost { border-color: transparent; }
button.small { padding: .25em .8em; font-size: .85rem; }
button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: .5em .7em;
  width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
label { display: block; font-size: .85rem; color: var(--muted); margin: 0 0 .3em; font-weight: 550; }
.field { margin-bottom: .9rem; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.grow { flex: 1; }
.stack > * + * { margin-top: 1rem; }
.hidden { display: none !important; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.pill {
  display: inline-block; padding: .1em .6em; border-radius: 999px;
  font-size: .75rem; font-weight: 650; letter-spacing: .01em;
  background: var(--line); color: var(--muted); white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad  { background: var(--bad-soft);  color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------- app chrome */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: .7rem 1.25rem;
  border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 30;
}
.topbar .brand { font-weight: 700; letter-spacing: -.01em; }
.topbar nav { display: flex; gap: .3rem; }

/* ---------------------------------------------------------------- sign-in */
.signin { max-width: 380px; margin: 12vh auto; padding: 0 1.25rem; text-align: center; }
.signin .card { text-align: left; }
.notice { padding: .7rem .9rem; border-radius: var(--radius); font-size: .9rem; }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.notice.bad  { background: var(--bad-soft);  color: var(--bad); }
.notice.good { background: var(--good-soft); color: var(--good); }

/* ------------------------------------------------------------- exam shell */
body.exam-mode { overflow: hidden; }
.exam { display: flex; flex-direction: column; height: 100dvh; }

.exam-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 1rem; padding: .55rem 1.1rem;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.exam-head .title { font-weight: 650; }
.clock { text-align: center; }
.clock .time { font: 650 1.35rem/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.clock.low .time { color: var(--bad); }
.clock .sub { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.exam-tools { display: flex; gap: .4rem; justify-content: flex-end; }

.exam-body { flex: 1; display: flex; min-height: 0; }
.exam-body.split .pane { width: 50%; }
.exam-body:not(.split) .pane-q { width: 100%; max-width: 780px; margin: 0 auto; }
.pane { overflow-y: auto; padding: 1.4rem 1.6rem 3rem; }
.pane-s { border-right: 1px solid var(--line); }

.qnum {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.9rem; height: 1.9rem; border-radius: 4px;
  background: var(--ink); color: var(--bg); font-weight: 700; font-size: .95rem;
}
.qhead { display: flex; align-items: center; gap: .7rem; margin-bottom: 1rem;
         padding-bottom: .7rem; border-bottom: 1px solid var(--line); }

.stem, .stimulus { font-size: 1.02rem; }
.stimulus p:first-child, .stem p:first-child { margin-top: 0; }

.choices { list-style: none; margin: 1.2rem 0 0; padding: 0; }
.choice-row { display: flex; align-items: flex-start; gap: .5rem; margin-bottom: .6rem; }
.choice {
  flex: 1; display: flex; gap: .7rem; align-items: flex-start;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: .7rem .85rem; cursor: pointer; background: var(--bg);
  text-align: left; font-weight: 400; border-radius: var(--radius);
}
.choice:hover { border-color: var(--accent); color: inherit; }
.choice.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice .letter {
  flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  border: 1.5px solid var(--line-strong); display: flex;
  align-items: center; justify-content: center; font-weight: 650; font-size: .85rem;
}
.choice.sel .letter { border-color: var(--accent); background: var(--accent); color: #fff; }
.choice .body { flex: 1; }
.choice .body p { margin: 0; }
.choice.struck { opacity: .45; }
.choice.struck .body { text-decoration: line-through; }
.strike {
  flex: none; border-radius: 50%; width: 1.7rem; height: 1.7rem; padding: 0;
  font-size: .75rem; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.spr-input { max-width: 260px; }

/* ------------------------------------------------------------- exam foot */
.exam-foot {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 1rem; padding: .6rem 1.1rem;
  border-top: 1px solid var(--line); background: var(--panel);
}
.exam-foot .who { font-weight: 600; font-size: .9rem; }
.exam-foot .nav-btns { display: flex; gap: .5rem; justify-content: flex-end; }

.navigator {
  position: absolute; left: 50%; bottom: 3.6rem; transform: translateX(-50%);
  width: min(560px, 92vw); background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; z-index: 40;
}
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr)); gap: .45rem; margin: .8rem 0; }
.nav-cell {
  position: relative; aspect-ratio: 1; border-radius: 4px; padding: 0;
  border: 1px dashed var(--line-strong); background: var(--bg);
  font-size: .85rem; font-weight: 600;
}
.nav-cell.answered { background: var(--accent); border: 1px solid var(--accent); color: #fff; }
.nav-cell.cur { outline: 2px solid var(--ink); outline-offset: 1px; }
.nav-cell .flag { position: absolute; top: -.35rem; right: -.2rem; font-size: .7rem; color: var(--mark); }
.nav-legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--muted); flex-wrap: wrap; }

mark.hl { background: var(--hl); color: inherit; padding: 0 .05em; border-radius: 2px; cursor: pointer; }

/* ---------------------------------------------------------------- desmos */
.desmos-panel {
  position: absolute; right: 1.2rem; top: 4.2rem; z-index: 45;
  width: min(520px, 46vw); height: min(560px, 62vh);
  background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; resize: both;
}
.desmos-panel .bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .35rem .35rem .35rem .8rem; border-bottom: 1px solid var(--line);
  background: var(--panel); font-size: .85rem; font-weight: 650; cursor: move;
}
.desmos-panel .calc { flex: 1; min-height: 0; }

/* ---------------------------------------------------------------- review */
.score-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem; }
.score-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.score-tile .n { font: 700 2rem/1.1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.score-tile .k { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.score-tile.total .n { color: var(--accent); }

.bar-row { display: grid; grid-template-columns: 1fr 4.5rem; gap: .7rem; align-items: center; margin-bottom: .45rem; }
.bar-track { height: .5rem; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--good); border-radius: 999px; }
.bar-fill.mid { background: var(--warn); }
.bar-fill.low { background: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.table-scroll { overflow-x: auto; }

details.qrev { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .5rem; background: var(--panel); }
details.qrev > summary { padding: .6rem .8rem; cursor: pointer; display: flex; gap: .7rem; align-items: center; }
details.qrev > summary::-webkit-details-marker { display: none; }
details.qrev .inner { padding: 0 .9rem 1rem; border-top: 1px solid var(--line); }
.rev-badge { flex: none; width: 1.7rem; height: 1.7rem; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.rev-badge.ok { background: var(--good-soft); color: var(--good); }
.rev-badge.no { background: var(--bad-soft); color: var(--bad); }
.rev-badge.blank { background: var(--line); color: var(--muted); }
.rev-choice { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .7rem; margin-bottom: .35rem; display: flex; gap: .6rem; }
.rev-choice.key { border-color: var(--good); background: var(--good-soft); }
.rev-choice.picked { border-color: var(--bad); background: var(--bad-soft); }
.rev-choice.key.picked { border-color: var(--good); background: var(--good-soft); }

/* ------------------------------------------------- question content: paper

   College Board's HTML hardcodes `stroke:#000000` and `fill:#ffffff` in its
   SVG figures — around 1,900 of them across the bank — and assumes a white
   page throughout. Rendered on a dark background, every geometry diagram and
   scatterplot turns into an invisible black-on-black smudge, and the inline
   MathML goes to near-zero contrast.

   So question content always renders on paper, in both themes, by
   redefining the palette tokens on these containers: everything nested
   inside (choices, borders, tables) follows automatically. Real Bluebook is
   light-only for the same reason. The surrounding chrome still follows the
   viewer's theme. */
.exam-body,
details.qrev .inner {
  --bg: #ffffff;
  --panel: #f7f8fa;
  --ink: #14181f;
  --muted: #5c6673;
  --line: #d8dde5;
  --line-strong: #b6bfcc;
  --accent: #1e4fd8;
  --accent-soft: #e8eeff;
  --good: #1a7f4b;
  --good-soft: #e6f5ec;
  --bad: #c02626;
  --bad-soft: #fdeaea;
  --hl: #fff2a8;
  background: var(--bg);
  color: var(--ink);
}

/* ------------------------------------------------------------------ misc */
math { font-size: 1.05em; }
.rev-choice > .grow > p:first-child { margin-top: 0; }
.rev-choice > .grow > p:last-child { margin-bottom: 0; }
svg, img { max-width: 100%; height: auto; }
table.sat-table { width: auto; min-width: 40%; margin: .8rem 0; border: 1px solid var(--line-strong); }
table.sat-table th, table.sat-table td { border: 1px solid var(--line); }

.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: .6rem 1.1rem;
  border-radius: 999px; font-size: .9rem; z-index: 100; box-shadow: var(--shadow);
}

@media (max-width: 820px) {
  .exam-body.split { flex-direction: column; }
  .exam-body.split .pane { width: 100%; height: 50%; }
  .pane-s { border-right: none; border-bottom: 1px solid var(--line); }
  .exam-head, .exam-foot { grid-template-columns: auto 1fr; }
  .exam-head .title { display: none; }
  .desmos-panel { width: 94vw; right: 3vw; }
}
