/* ============================================================
   Econ Mock Exam — one-page quiz app
   Zero dependencies. System fonts only.
   ============================================================ */

:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #15171c;
  --muted: #5f6672;
  --line: #e4dfd6;
  --line-strong: #cfc8bb;
  --grid: rgba(21, 23, 28, 0.045);

  --accent: #1b4dd8;
  --accent-ink: #ffffff;
  --accent-soft: #e9eefc;
  --accent-line: #b9c8f5;

  --ok: #0b6b4f;
  --ok-soft: #e6f4ee;
  --ok-line: #9ed6c1;

  --bad: #a8231b;
  --bad-soft: #fbeae8;
  --bad-line: #f0b6b1;

  --warn: #9a5a00;

  --radius: 20px;
  --radius-sm: 13px;
  --shadow: 0 1px 2px rgba(21, 23, 28, .05), 0 12px 32px -14px rgba(21, 23, 28, .18);
  --shadow-sm: 0 1px 2px rgba(21, 23, 28, .06);

  --font: system-ui, -apple-system, "Segoe UI", "PingFang HK", "Noto Sans HK", "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Songti TC", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #0f1116;
  --surface: #171a21;
  --surface-2: #1b1f27;
  --ink: #eef1f6;
  --muted: #a3abb9;
  --line: #333a47;
  --line-strong: #3a4150;
  --grid: rgba(255, 255, 255, 0.045);

  --accent: #8ba4ff;
  --accent-ink: #0e1220;
  --accent-soft: #1d2540;
  --accent-line: #38477a;

  --ok: #63dbaf;
  --ok-soft: #122a23;
  --ok-line: #235043;

  --bad: #ff958c;
  --bad-soft: #2c1a1a;
  --bad-line: #57302d;

  --warn: #f0b464;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 40px -18px rgba(0, 0, 0, .8);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
}

*, *::before, *::after { box-sizing: border-box; }

/* Any display rule outranks the UA's [hidden] rule — force it everywhere. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, var(--grid) 0 1px, transparent 1px 30px),
    repeating-linear-gradient(90deg, var(--grid) 0 1px, transparent 1px 30px);
  -webkit-mask-image: radial-gradient(120% 70% at 50% -10%, #000 25%, transparent 78%);
  mask-image: radial-gradient(120% 70% at 50% -10%, #000 25%, transparent 78%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 18px calc(28px + env(safe-area-inset-bottom));
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  display: grid;
  place-items: center;
  inline-size: 30px;
  block-size: 30px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--surface);
  font: 700 15px/1 var(--font-display);
  letter-spacing: .02em;
}

.brand-text {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
}
.brand-text .dot { color: var(--muted); font-weight: 400; }

.icon-btn {
  appearance: none;
  display: grid;
  place-items: center;
  inline-size: 38px;
  block-size: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .15s ease, transform .12s ease;
}
.icon-btn:hover { border-color: var(--line-strong); }
.icon-btn:active { transform: scale(.96); }

/* ---------- views ---------- */

main { flex: 1; }

.view { animation: rise .34s cubic-bezier(.2, .7, .2, 1) both; }
.view[hidden] { display: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- start ---------- */

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: clamp(40px, 11vw, 60px);
  line-height: .98;
  letter-spacing: -.02em;
  font-weight: 600;
}

.lead {
  margin: 0 0 26px;
  max-width: 54ch;
  font-size: 16px;
  color: var(--muted);
  line-height: 1.55;
}
.lead b, .lead strong { color: var(--ink); font-weight: 620; }

#view-start { padding-top: 22px; }

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0 0 20px;
  padding: 0;
}
.facts > div {
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.facts dt {
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.facts dd {
  margin: 0;
  font-size: 20px;
  font-weight: 640;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}
.chips li {
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 520;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 13px;
  font: 600 15px/1 var(--font);
  letter-spacing: .01em;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s ease, border-color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 1px 2px rgba(21, 23, 28, .12), 0 10px 22px -12px var(--accent);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-dark { background: var(--ink); color: var(--surface); }
.btn-dark:hover { opacity: .9; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--surface); }

.btn-quiet {
  min-height: 40px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 560;
  font-size: 13.5px;
}
.btn-quiet:hover { color: var(--ink); background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.actions .btn-quiet { flex: 1 1 100%; justify-content: flex-start; padding-inline: 2px; }

.btn-lg {
  min-height: 54px;
  padding: 0 26px;
  font-size: 16px;
  border-radius: 15px;
}
.btn-lg svg { transition: transform .18s ease; }
.btn-lg:hover svg { transform: translateX(3px); }

#startBtn { width: 100%; max-width: 330px; margin-bottom: 16px; }

.chips-label {
  margin: 0 0 8px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
}
.chips { margin-bottom: 26px; }

/* ---------- paper picker ---------- */

.paper-pick { margin: 0 0 20px; }

.paper-pick label {
  display: block;
  margin-bottom: 7px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
}

.select-wrap { position: relative; }

.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 50px;
  padding: 13px 44px 13px 15px;
  font: 550 15px/1.35 var(--font);
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  touch-action: manipulation;
}
.select-wrap select:hover { border-color: var(--muted); }
.select-wrap select:focus-visible { border-color: var(--accent); }

.select-caret {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted);
}

.fineprint {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 52ch;
}

.last-attempt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.last-attempt p { margin: 0; font-size: 13.5px; color: var(--muted); }
.last-attempt strong { color: var(--ink); font-size: 17px; font-variant-numeric: tabular-nums; }
.last-attempt button {
  appearance: none;
  border: 0;
  background: none;
  padding: 6px 2px;
  font: 600 13.5px var(--font);
  color: var(--accent);
  cursor: pointer;
}

.source-note {
  margin: 26px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.source-note code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* ---------- exam ---------- */

#view-exam { padding-top: 8px; }

.exam-bar {
  position: sticky;
  top: 62px;
  z-index: 15;
  padding: 10px 0 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.bar-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.qcount {
  margin: 0;
  font-size: 22px;
  font-weight: 680;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.qcount .sep { color: var(--line-strong); font-weight: 400; margin: 0 2px; }
#qTotal { font-size: 15px; color: var(--muted); font-weight: 560; }

.timer {
  margin: 0;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 560;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#timerText { color: var(--ink); font-weight: 680; letter-spacing: .01em; }
.timer.is-low { border-color: var(--bad-line); background: var(--bad-soft); }
.timer.is-low #timerText, .timer.is-low { color: var(--bad); }

.progress {
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--ink);
  transition: width .3s cubic-bezier(.2, .7, .2, 1), background .2s ease;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.question-card { padding: 22px 20px 24px; }

.chapter {
  display: inline-block;
  margin: 0 0 14px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}

.stem {
  margin: 0 0 20px;
  font-size: clamp(17px, 4.4vw, 19.5px);
  font-weight: 590;
  line-height: 1.45;
  letter-spacing: -.005em;
}
.stem em { font-style: italic; }
.stem sub { font-size: .72em; }

.options { display: grid; gap: 9px; }

/* data table and (1)(2)(3) statements, as used in DSE Paper 1 */
.qtable {
  margin: 0 0 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.qtable table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.qtable th, .qtable td {
  padding: 6px 9px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  line-height: 1.35;
}
.qtable th:first-child, .qtable td:first-child {
  text-align: left;
  padding-left: 11px;
}
.qtable th { vertical-align: bottom; }
.qtable thead th {
  background: var(--surface-2);
  font-weight: 650;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .02em;
}
.qtable tr:last-child td { border-bottom: 0; }

.stmts {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  counter-reset: stmt;
  display: grid;
  gap: 7px;
}
.stmts li {
  counter-increment: stmt;
  position: relative;
  padding-left: 32px;
  font-size: 14.5px;
  line-height: 1.5;
}
.stmts li::before {
  content: "(" counter(stmt) ")";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--muted);
  font-weight: 620;
  font-variant-numeric: tabular-nums;
}

.stmt-explain {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}
.stmt-explain li {
  padding: 8px 12px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}
.stmt-explain b { color: var(--ink); }

.opt {
  appearance: none;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 13px 15px;
  text-align: left;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: 450 15px/1.45 var(--font);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .14s ease, background .14s ease, transform .12s ease;
}
.opt:hover { border-color: var(--line-strong); }
.opt:active { transform: scale(.995); }

.opt .letter {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  inline-size: 26px;
  block-size: 26px;
  margin-top: 1px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 12.5px;
  font-weight: 680;
  color: var(--muted);
  transition: inherit;
}
.opt .txt { flex: 1; min-width: 0; }

.opt.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.opt.is-selected .letter {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.opt.is-correct {
  background: var(--ok-soft);
  border-color: var(--ok);
}
.opt.is-correct .letter { background: var(--ok); border-color: var(--ok); color: var(--surface); }

.opt.is-wrong {
  background: var(--bad-soft);
  border-color: var(--bad);
}
.opt.is-wrong .letter { background: var(--bad); border-color: var(--bad); color: var(--surface); }

.opt .mark {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  align-self: center;
  color: var(--muted);
}

.exam-nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
  flex-wrap: wrap;
}
.dots button {
  appearance: none;
  inline-size: 20px;
  block-size: 20px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: transparent;
  cursor: pointer;
  font: 600 9.5px/1 var(--font);
  color: transparent;
  transition: background .15s ease, border-color .15s ease;
}
.dots button.is-answered { background: var(--ink); border-color: var(--ink); color: transparent; }
.dots button.is-current { border-color: var(--accent); box-shadow: 0 0 0 2.5px var(--accent-soft); }
.dots button.is-current.is-answered { background: var(--accent); border-color: var(--accent); }

.kbd-hint {
  margin: 16px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}
kbd {
  display: inline-block;
  min-width: 17px;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  font: 600 10.5px/1.4 var(--font-mono);
  color: var(--muted);
}

/* No hardware keyboard, no keyboard hint. */
@media (hover: none) and (pointer: coarse) {
  .kbd-hint { display: none; }
}

/* ---------- result ---------- */

#view-result { padding-top: 22px; }

.result-sheet { padding: 24px 20px 22px; }

.score-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 4px 0 20px;
}

.donut { position: relative; flex: 0 0 auto; display: grid; place-items: center; }
.donut svg { display: block; transform: rotate(-90deg); }
.donut .track { stroke: var(--line-strong); }
.donut .value {
  stroke: var(--ok);
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset .9s cubic-bezier(.2, .7, .2, 1), stroke .3s ease;
}
.donut.is-mid .value { stroke: var(--accent); }
.donut.is-low .value { stroke: var(--bad); }

.donut-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1;
}
.donut-label strong {
  display: block;
  font-size: 34px;
  font-weight: 660;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.donut-label span {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.score-copy { min-width: 0; }
.band {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.1;
}
.band-note { margin: 0 0 8px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.meta-line {
  margin: 0;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.actions .btn { flex: 1 1 auto; }

/* ---------- per-chapter breakdown ---------- */

.chapters {
  margin: 0 0 4px;
  padding: 14px 0 2px;
  border-top: 1px solid var(--line);
}

.chapters-title {
  margin: 0 0 9px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
}

.ch-row {
  display: grid;
  grid-template-columns: 1fr 46px auto;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
}

.ch-name {
  min-width: 0;
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ch-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.ch-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--ok);
}
.ch-row.is-none .ch-bar span { background: var(--bad); }
.ch-row.is-full .ch-bar span { background: var(--ok); }

.ch-score {
  font-size: 11.5px;
  font-weight: 620;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ch-row.is-none .ch-score { color: var(--bad); }

.review-heading {
  margin: 34px 0 12px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.review { display: grid; gap: 9px; }

.rev {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.rev[open] { border-color: var(--line-strong); }

.rev summary {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  cursor: pointer;
  list-style: none;
  touch-action: manipulation;
}
.rev summary::-webkit-details-marker { display: none; }
.rev summary:hover { background: var(--surface-2); }

.chev {
  flex: 0 0 auto;
  color: var(--muted);
  transition: transform .2s ease;
}
.rev[open] .chev { transform: rotate(180deg); }

.rev-num {
  display: grid;
  place-items: center;
  inline-size: 26px;
  block-size: 26px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font: 680 11.5px/1 var(--font);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.rev.is-wrong .rev-num { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.rev.is-right .rev-num { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }

.rev-stem {
  min-width: 0;
  font-size: 14px;
  font-weight: 540;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.rev.is-blank .rev-stem::after {
  content: "No answer given";
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--bad);
  margin-top: 3px;
}

.rev-tag {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.rev.is-right .rev-tag { background: var(--ok-soft); color: var(--ok); }
.rev.is-wrong .rev-tag, .rev.is-blank .rev-tag { background: var(--bad-soft); color: var(--bad); }

.rev-body {
  padding: 4px 15px 18px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
  padding-top: 15px;
}
.rev-body .stem-full {
  margin: 0 0 15px;
  font-size: 15px;
  font-weight: 560;
  line-height: 1.45;
}
.rev-chapter {
  margin: 0 0 6px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.rev-body .stem-full em { font-style: italic; }

.rev-answers { display: grid; gap: 7px; margin-bottom: 15px; }

.ans {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.45;
}
.ans b { font-weight: 700; font-variant-numeric: tabular-nums; }
.ans.is-right { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-line); }
.ans.is-bad { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-line); }
.ans .k {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  opacity: .8;
}
.ans .v { min-width: 0; color: var(--ink); }
.ans.is-right .v, .ans.is-bad .v { color: inherit; }

.why {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.58;
  color: var(--ink);
}
.why::before {
  content: "Why";
  display: block;
  margin-bottom: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ok);
}
.rev.is-wrong .why::before, .rev.is-blank .why::before { color: var(--accent); }

.distract {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.distract li {
  position: relative;
  padding-left: 30px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}
.distract li b {
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  inline-size: 21px;
  block-size: 21px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
}

.rev-src {
  margin: 0;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* ---------- footer ---------- */

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 34px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.foot-build { font-family: var(--font-mono); letter-spacing: 0; text-transform: none; }

/* ---------- dialog ---------- */

.dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(12, 14, 18, .42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade .18s ease both;
}
.dialog[hidden] { display: none !important; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.dialog-panel {
  width: 100%;
  max-width: 420px;
  padding: 22px 20px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .5);
  animation: pop .22s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

.dialog-panel h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.dialog-panel p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}
.dialog-actions { display: flex; gap: 9px; }
.dialog-actions .btn { flex: 1; }

/* ---------- focus ---------- */

:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
.opt:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, .dots button:focus-visible {
  outline-offset: 3px;
}

/* ---------- phone ---------- */

@media (max-width: 560px) {
  /* The dots get their own full-width row: squeezed between the two buttons
     they wrapped 5 + 5 and read as a broken indicator. */
  .exam-nav {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "dots dots" "back next";
    gap: 10px;
  }
  .dots { grid-area: dots; flex-wrap: nowrap; }
  #prevBtn { grid-area: back; }
  #nextBtn { grid-area: next; }
}

@media (max-width: 430px) {
  .app { padding-inline: 14px; }
  .question-card { padding: 18px 15px 20px; }
  .result-sheet { padding: 20px 16px 18px; }
  .score-row { gap: 14px; }
  .donut svg { width: 112px; height: 112px; }
  .donut-label strong { font-size: 29px; }
  .band { font-size: 22px; }
  .exam-nav { gap: 8px; }
  .exam-nav .btn { padding: 0 14px; min-height: 44px; }
  .dots { gap: 4px; }
  .dots button { inline-size: 22px; block-size: 22px; border-radius: 7px; }
  .actions .btn { flex: 1 1 100%; }
  .rev summary { padding: 12px 13px; gap: 9px; }
  .rev-body { padding-inline: 13px; }
  .rev-stem { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
