/* ------------------------------------------------------------------ *
 * Sunflower Institute for Autism — Mock Exam Runner
 * Palette follows the sunflower brand: warm gold on a soft cream ground,
 * with a stem green used sparingly for confirmation states.
 * ------------------------------------------------------------------ */

:root {
  --sun-100: #fff3d4;
  --sun-200: #ffe3a3;
  --sun-400: #f7c246;
  --sun-500: #eda92a;
  --sun-600: #c9821b;
  --sun-700: #9c6212;

  --stem-100: #e2f2e7;
  --stem-500: #2f8a52;
  --stem-600: #24693f;

  --clay-100: #fde8e4;
  --clay-500: #c9452f;
  --clay-600: #a63523;

  --ink-900: #24211c;
  --ink-700: #4a443b;
  --ink-500: #756d61;
  --ink-300: #b3ab9e;

  --surface: #ffffff;
  --surface-2: #fffaf0;
  --page: #fdf8ee;
  --line: #ece2cf;

  --shadow-sm: 0 1px 2px rgba(60, 45, 15, .07);
  --shadow-md: 0 6px 20px -6px rgba(60, 45, 15, .18);

  --radius: 14px;
  --radius-sm: 9px;
  --wrap: 1120px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"],
:root:not([data-theme="light"]) {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink-900: #f6f1e7;
    --ink-700: #ddd5c6;
    --ink-500: #a49b8b;
    --ink-300: #6d6558;

    --surface: #221f1a;
    --surface-2: #2b271f;
    --page: #191713;
    --line: #3b3529;

    --sun-100: #43371c;
    --sun-200: #5c4820;
    --stem-100: #1e3a28;
    --clay-100: #43231d;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 6px 20px -6px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --ink-900: #f6f1e7;
  --ink-700: #ddd5c6;
  --ink-500: #a49b8b;
  --ink-300: #6d6558;

  --surface: #221f1a;
  --surface-2: #2b271f;
  --page: #191713;
  --line: #3b3529;

  --sun-100: #43371c;
  --sun-200: #5c4820;
  --stem-100: #1e3a28;
  --clay-100: #43231d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 20px -6px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

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

/* The `hidden` attribute is only `display: none` in the UA stylesheet, so any
   author rule that sets `display` silently defeats it. Several components here
   are flex, so make hidden authoritative once rather than per-component. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink-900);
  background: var(--page);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.9rem); }
h2 { font-size: 1.2rem; }
p { margin: 0; }

a { color: var(--sun-700); }
:root[data-theme="dark"] a { color: var(--sun-400); }

.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }
.muted { color: var(--ink-500); }
.stack { display: grid; gap: 1.5rem; }
.stack-sm { display: grid; gap: 1rem; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--sun-400); color: var(--ink-900);
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

:where(button, input, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--sun-500);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ------------------------------- header ------------------------------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .75rem 0;
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: inherit; }
.brand-text { display: grid; line-height: 1.25; }
.brand-text strong { font-size: .98rem; }
.brand-text small { color: var(--ink-500); font-size: .78rem; }
.header-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.whoami {
  font-size: .82rem; color: var(--ink-500); max-width: 15rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 620px) { .whoami { display: none; } }

/* ------------------------------- sign in -------------------------------- */

.login-panel { max-width: 27rem; display: grid; gap: 1rem; }
.login-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.code-input {
  font-size: 1.6rem; font-weight: 800; letter-spacing: .35em;
  text-align: center; font-variant-numeric: tabular-nums;
}
.login-message {
  margin: 0; font-size: .9rem; padding: .7rem .9rem; border-radius: var(--radius-sm);
  background: var(--clay-100); border: 1px solid var(--clay-500); color: var(--clay-600);
}
.login-message.ok { background: var(--stem-100); border-color: var(--stem-500); color: var(--stem-600); }
:root[data-theme="dark"] .login-message { color: #f0a294; }
:root[data-theme="dark"] .login-message.ok { color: #7fd6a0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-message { color: #f0a294; }
  :root:not([data-theme="light"]) .login-message.ok { color: #7fd6a0; }
}

/* ------------------------------ backoffice ------------------------------ */

.admin-head { padding-top: 2rem; align-items: flex-start; }
.admin-head h1 { font-size: 1.8rem; }
.allow-add {
  display: grid; gap: .8rem; align-items: end;
  grid-template-columns: minmax(0, 2fr) minmax(0, 2fr) auto;
}
@media (max-width: 640px) { .allow-add { grid-template-columns: minmax(0, 1fr); } }
.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; font-size: .9rem; }
.data-table code, .admin-list code {
  font-size: .85rem; background: var(--surface-2); padding: .1rem .4rem;
  border-radius: 4px; border: 1px solid var(--line);
}

/* -------------------------------- hero -------------------------------- */

.hero {
  background: linear-gradient(160deg, var(--sun-100), var(--surface-2) 70%);
  border-bottom: 1px solid var(--line);
  padding: 3rem 0 2.75rem;
  margin-bottom: 2rem;
}
.eyebrow {
  text-transform: uppercase; letter-spacing: .1em; font-size: .74rem;
  font-weight: 700; color: var(--sun-700); margin-bottom: .6rem;
}
:root[data-theme="dark"] .eyebrow { color: var(--sun-400); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .eyebrow { color: var(--sun-400); }
}
.lede { max-width: 60ch; color: var(--ink-700); margin-top: .9rem; font-size: 1.05rem; }

/* ------------------------------- panels ------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
}
fieldset.panel { margin: 0; }
.panel legend {
  font-weight: 700; font-size: 1.05rem; padding: 0 .5rem; margin-left: -.5rem;
  display: flex; align-items: center; gap: .6rem;
}
.step {
  display: grid; place-items: center;
  width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--sun-400); color: #2b2109;
  font-size: .82rem; font-weight: 800;
}
.hint { color: var(--ink-500); font-size: .88rem; margin: .5rem 0 1rem; max-width: 62ch; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.panel-details summary { font-weight: 700; cursor: pointer; }
.panel-details[open] summary { margin-bottom: 1rem; }

/* ------------------------------- banner ------------------------------- */

.banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  background: var(--sun-100); border: 1px solid var(--sun-200);
  border-radius: var(--radius); padding: 1rem 1.25rem;
}
.banner-error { background: var(--clay-100); border-color: var(--clay-500); }
.banner-actions { display: flex; gap: .5rem; }

/* ------------------------------ selection ----------------------------- */

.card-grid {
  display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.select-card {
  position: relative; display: block; cursor: pointer;
  border: 2px solid var(--line); border-radius: var(--radius);
  padding: 1rem; background: var(--surface-2);
  transition: border-color .15s, background .15s, transform .1s;
}
.select-card:hover { border-color: var(--sun-400); }
.select-card:active { transform: translateY(1px); }
.select-card input { position: absolute; opacity: 0; pointer-events: none; }
.select-card:has(input:checked) { border-color: var(--sun-500); background: var(--sun-100); }
.select-card:has(input:focus-visible) { outline: 3px solid var(--sun-500); outline-offset: 2px; }
.select-card h3 { font-size: .98rem; margin-bottom: .3rem; }
.select-card p { font-size: .85rem; color: var(--ink-500); }
.select-card .meta {
  margin-top: .6rem; font-size: .78rem; font-weight: 700; color: var(--sun-700);
  display: flex; gap: .75rem; flex-wrap: wrap;
}
:root[data-theme="dark"] .select-card .meta { color: var(--sun-400); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .select-card .meta { color: var(--sun-400); }
}

.chip-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  position: relative; cursor: pointer;
  border: 2px solid var(--line); border-radius: 999px;
  padding: .45rem 1rem; font-size: .88rem; background: var(--surface-2);
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { border-color: var(--sun-500); background: var(--sun-100); font-weight: 700; }
.chip:has(input:focus-visible) { outline: 3px solid var(--sun-500); outline-offset: 2px; }

.field { display: grid; gap: .35rem; font-size: .9rem; font-weight: 600; }
.field input {
  font: inherit; font-weight: 400; padding: .6rem .75rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: inherit;
}
.field .hint { margin: 0; font-weight: 400; }
.checkbox { display: flex; gap: .6rem; align-items: flex-start; font-size: .9rem; cursor: pointer; }
.checkbox input { margin-top: .3rem; accent-color: var(--sun-500); }

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

.primary-btn, .ghost-btn, .chip-btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border-radius: var(--radius-sm); padding: .6rem 1.1rem;
  border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.primary-btn { background: var(--sun-400); color: #2b2109; }
.primary-btn:hover { background: var(--sun-500); }
.primary-btn.big { padding: .85rem 2rem; font-size: 1.02rem; }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }
.ghost-btn { background: transparent; color: var(--ink-700); border-color: var(--line); }
.ghost-btn:hover { background: var(--surface-2); border-color: var(--ink-300); }
.ghost-btn.small, .chip-btn { padding: .35rem .8rem; font-size: .82rem; }
.chip-btn { background: var(--surface-2); border-color: var(--line); color: var(--ink-700); }
.chip-btn.is-active { background: var(--sun-400); color: #2b2109; border-color: var(--sun-500); }

.start-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.5rem; flex-wrap: wrap;
}
.paper-summary { font-size: .92rem; color: var(--ink-700); max-width: 60ch; }
.paper-summary strong { color: var(--ink-900); }

/* -------------------------------- tables ------------------------------ */

.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 560px; }
.data-table th, .data-table td {
  text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--line);
}
.data-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-500); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700; }
.tag-pass { background: var(--stem-100); color: var(--stem-600); }
.tag-fail { background: var(--clay-100); color: var(--clay-600); }
:root[data-theme="dark"] .tag-pass { color: #7fd6a0; }
:root[data-theme="dark"] .tag-fail { color: #f0a294; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tag-pass { color: #7fd6a0; }
  :root:not([data-theme="light"]) .tag-fail { color: #f0a294; }
}

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

.exam-bar {
  position: sticky; top: 0; z-index: 30;
  background: var(--surface); border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.exam-bar-inner {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .8rem 0;
}
.exam-meta { display: grid; margin-right: auto; }
.exam-meta strong { font-size: .98rem; }
.exam-meta span { font-size: .82rem; }
.exam-status { display: flex; align-items: center; gap: 1.25rem; }
.timer {
  font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 800;
  padding: .1rem .7rem; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid var(--line);
}
.timer.is-warning { background: var(--sun-100); border-color: var(--sun-500); color: var(--sun-700); }
.timer.is-critical { background: var(--clay-100); border-color: var(--clay-500); color: var(--clay-600); }
:root[data-theme="dark"] .timer.is-warning { color: var(--sun-400); }
:root[data-theme="dark"] .timer.is-critical { color: #f0a294; }
.progress-text { font-size: .85rem; color: var(--ink-500); }
.progress-track { height: 4px; background: var(--line); }
.progress-fill { height: 100%; width: 0; background: var(--sun-400); transition: width .25s; }

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

/* The site header is redundant once an exam is running — the exam bar carries
   everything, so the screen holds one horizontal band, not two. */
body[data-view="exam"] .site-header,
body[data-view="exam"] .site-footer { display: none; }

/* Room for the fixed footer. */
body[data-view="exam"] { padding-bottom: 6.5rem; }

.exam-layout { padding: 1.75rem 0 1rem; }

/* --------------------------- question status --------------------------- */
/* Deliberately greyscale. The question card is the only thing on screen
   allowed to use the brand gold, so status never competes with content. */

.navigator-grid {
  display: grid; gap: .3rem;
  grid-template-columns: repeat(auto-fill, minmax(2.1rem, 1fr));
  max-height: 34vh; overflow-y: auto;
}
.nav-cell {
  position: relative;
  font: inherit; font-size: .76rem; font-weight: 700; cursor: pointer;
  aspect-ratio: 1; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 7px;
  background: transparent; color: var(--ink-300);
  transition: background .12s, color .12s, border-color .12s;
}
.nav-cell:hover { border-color: var(--ink-300); color: var(--ink-700); }
.nav-cell[data-state="seen"] { color: var(--ink-500); border-color: var(--ink-300); }
.nav-cell[data-state="answered"] {
  background: var(--ink-500); border-color: var(--ink-500); color: var(--page);
}
/* Flagged is a small corner mark rather than a fill — visible when scanned for,
   invisible otherwise. */
.nav-cell[data-flagged="true"]::after {
  content: ""; position: absolute; top: 3px; right: 3px;
  width: .34rem; height: .34rem; border-radius: 50%; background: var(--clay-500);
}
.nav-cell[aria-current="true"] {
  outline: 2px solid var(--ink-900); outline-offset: 1px;
  color: var(--ink-900); border-color: var(--ink-900);
}
.nav-cell[data-state="answered"][aria-current="true"] { color: var(--page); }

.legend { display: flex; gap: 1rem; margin: 0; font-size: .74rem; color: var(--ink-500); flex-wrap: wrap; }
.legend > div { display: flex; align-items: center; gap: .4rem; }
.legend dd { margin: 0; }
.dot { width: .7rem; height: .7rem; border-radius: 4px; border: 1px solid var(--ink-300); }
.dot-answered { background: var(--ink-500); border-color: var(--ink-500); }
.dot-flagged { background: var(--clay-500); border-color: var(--clay-500); border-radius: 50%; }
.dot-unseen { background: transparent; border-color: var(--line); }

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

.exam-footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 35;
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px -8px rgba(60, 45, 15, .22);
}
:root[data-theme="dark"] .exam-footer { box-shadow: 0 -4px 20px -8px rgba(0, 0, 0, .6); }
.exam-footer-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .75rem 0;
}
/* Check and Next swap places, so the slot must not collapse or jump width. */
.footer-actions { display: flex; align-items: center; gap: .6rem; min-width: 8.5rem; justify-content: flex-end; }
.footer-actions [hidden] { display: none; }
.check-btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border-radius: var(--radius-sm); padding: .6rem 1.1rem;
  background: transparent; color: var(--stem-600);
  border: 1px solid var(--stem-500);
}
.check-btn:hover:not(:disabled) { background: var(--stem-100); }
.check-btn:disabled { opacity: .45; cursor: not-allowed; }
:root[data-theme="dark"] .check-btn { color: #7fd6a0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .check-btn { color: #7fd6a0; }
}

.nav-strip-wrap { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.nav-strip { display: flex; gap: .3rem; }
.nav-strip .nav-cell { width: 2.1rem; }
.nav-expand { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.nav-expand .chevron { font-size: .6rem; transition: transform .15s; }
.nav-expand[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.nav-sheet { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.nav-sheet-inner { padding: 1rem 0; }
.nav-sheet .panel-head { margin-bottom: .75rem; }
.nav-sheet .panel-head h2 { font-size: .95rem; }

@media (max-width: 620px) {
  .exam-footer-inner { flex-wrap: wrap; justify-content: center; }
  .nav-strip-wrap { order: -1; width: 100%; justify-content: center; }
  #prev-btn { flex: 1 1 auto; }
  .footer-actions { flex: 1 1 auto; }
  .footer-actions .primary-btn, .footer-actions .check-btn { flex: 1 1 auto; }
  body[data-view="exam"] { padding-bottom: 9rem; }

  /* Keep the bar to two lines on a phone — the paper id and question count are
     reference detail, not something to spend vertical space on. */
  .exam-bar-inner { gap: .5rem .75rem; padding: .6rem 0; }
  #exam-subtitle { display: none; }
  .exam-meta { flex: 1 1 100%; }
  .exam-status { gap: .8rem; }
  .timer { font-size: 1.25rem; }
  #submit-btn, #zen-btn { padding: .45rem .8rem; }
}

/* -------------------------------- zen ---------------------------------- */
/* Everything but the question and the two movement buttons goes away. */

body[data-zen="on"] .exam-bar,
body[data-zen="on"] .nav-strip-wrap,
body[data-zen="on"] .nav-sheet,
body[data-zen="on"] .question-head,
body[data-zen="on"] .q-number { display: none; }

body[data-zen="on"] .exam-footer {
  background: transparent; border-top: 0; box-shadow: none;
}
body[data-zen="on"] .exam-footer-inner { justify-content: center; gap: 1.25rem; }
body[data-zen="on"] .exam-layout { padding-top: 3.5rem; }
body[data-zen="on"] .question-card { border-color: transparent; box-shadow: none; background: transparent; }
body[data-zen="on"] .q-stem { font-size: 1.3rem; }

.zen-exit {
  position: fixed; top: 1rem; right: 1rem; z-index: 40;
  font: inherit; font-size: .78rem; cursor: pointer;
  padding: .35rem .8rem; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid var(--line); color: var(--ink-300);
}
.zen-exit:hover { color: var(--ink-700); border-color: var(--ink-300); }

/* ----------------------------- question card -------------------------- */

.question-card { display: grid; gap: 1rem; }
.question-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.pill {
  display: inline-block; padding: .18rem .7rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; background: var(--sun-100); color: var(--sun-700);
  text-transform: uppercase; letter-spacing: .04em;
}
.pill-quiet { background: var(--surface-2); color: var(--ink-500); border: 1px solid var(--line); }
:root[data-theme="dark"] .pill { color: var(--sun-400); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill { color: var(--sun-400); }
}
.question-tools { display: flex; gap: .5rem; flex-wrap: wrap; }
#flag-btn[aria-pressed="true"] { background: var(--clay-100); border-color: var(--clay-500); color: var(--clay-600); }
#note-btn[aria-pressed="true"] { background: var(--sun-100); border-color: var(--sun-500); color: var(--sun-700); }
:root[data-theme="dark"] #note-btn[aria-pressed="true"] { color: var(--sun-400); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #note-btn[aria-pressed="true"] { color: var(--sun-400); }
}

/* ------------------------------- notes --------------------------------- */

.notes-list { display: grid; gap: .9rem; }
.note-item {
  border: 1px solid var(--line); border-left: 4px solid var(--sun-400);
  border-radius: var(--radius-sm); padding: 1rem 1.2rem; background: var(--surface-2);
}
.note-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem;
}
.note-meta { font-size: .78rem; margin-top: .6rem; }
.q-number { font-size: .82rem; font-weight: 700; color: var(--ink-500); text-transform: uppercase; letter-spacing: .05em; }
.q-stem { font-size: 1.15rem; line-height: 1.5; }

.options { display: grid; gap: .6rem; }
.option {
  display: flex; gap: .85rem; align-items: flex-start; cursor: pointer;
  border: 2px solid var(--line); border-radius: var(--radius-sm);
  padding: .8rem 1rem; background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.option:hover { border-color: var(--sun-400); }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option:has(input:checked) { border-color: var(--sun-500); background: var(--sun-100); }
.option:has(input:focus-visible) { outline: 3px solid var(--sun-500); outline-offset: 2px; }
.option-letter {
  flex: 0 0 auto; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  display: grid; place-items: center; font-size: .8rem; font-weight: 800;
  background: var(--surface); border: 1px solid var(--line);
}
.option:has(input:checked) .option-letter { background: var(--sun-400); border-color: var(--sun-500); color: #2b2109; }

/* Scoped to .options so these beat `.option:has(input:checked)` — `:has()` takes
   the specificity of its most specific argument, which makes the plain
   `.option.is-correct` form lose to it. */
.options .option.is-correct { border-color: var(--stem-500); background: var(--stem-100); }
.options .option.is-correct .option-letter { background: var(--stem-500); border-color: var(--stem-500); color: #fff; }
.options .option.is-wrong { border-color: var(--clay-500); background: var(--clay-100); }
.options .option.is-wrong .option-letter { background: var(--clay-500); border-color: var(--clay-500); color: #fff; }
.options .option.is-locked { cursor: default; }
.options .option.is-locked:hover { border-color: var(--line); }
.options .option.is-locked.is-correct:hover { border-color: var(--stem-500); }
.options .option.is-locked.is-wrong:hover { border-color: var(--clay-500); }

.feedback { border-radius: var(--radius-sm); padding: .9rem 1.1rem; font-size: .92rem; border: 1px solid; }
.feedback.correct { background: var(--stem-100); border-color: var(--stem-500); }
.feedback.incorrect { background: var(--clay-100); border-color: var(--clay-500); }
.feedback strong { display: block; margin-bottom: .25rem; }

/* -------------------------------- hint --------------------------------- */

.hint-btn {
  font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .35rem .8rem; border-radius: var(--radius-sm);
  background: var(--sun-100); color: var(--sun-700);
  border: 1px solid var(--sun-400);
}
.hint-btn:hover:not(:disabled) { background: var(--sun-200); }
.hint-btn:disabled { opacity: .6; cursor: progress; }
:root[data-theme="dark"] .hint-btn { color: var(--sun-400); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hint-btn { color: var(--sun-400); }
}

.hint-panel {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .3s ease, margin .3s ease;
  margin: 0;
}
.hint-panel.is-open { grid-template-rows: 1fr; margin: -.25rem 0 .25rem; }
.hint-inner { overflow: hidden; border-radius: var(--radius-sm); }
.hint-panel.is-open .hint-inner {
  border-left: 3px solid var(--sun-400); background: var(--sun-100);
}
.hint-pad {
  padding: .8rem 1rem; font-size: .92rem; line-height: 1.6; color: var(--ink-700);
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
}

/* ------------------------------- explain ------------------------------- */

.explain-wrap { margin-top: -.35rem; }
.explain-btn {
  font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .45rem .9rem; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-700);
  border: 1px dashed var(--ink-300);
}
.explain-btn:hover:not(:disabled) { border-style: solid; border-color: var(--sun-500); color: var(--sun-700); }
.explain-btn:disabled { opacity: .6; cursor: progress; }
.explain-btn .chevron { font-size: .6rem; transition: transform .2s; }
.explain-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }
:root[data-theme="dark"] .explain-btn:hover:not(:disabled) { color: var(--sun-400); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .explain-btn:hover:not(:disabled) { color: var(--sun-400); }
}

/* Slides open by animating the grid track from 0fr to 1fr, so the panel can
   size to its content without hard-coding a height. */
.explain-panel {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .32s ease, margin-top .32s ease;
  margin-top: 0;
}
.explain-panel.is-open { grid-template-rows: 1fr; margin-top: .75rem; }
.explain-inner {
  overflow: hidden;
  border-radius: var(--radius-sm);
}
.explain-panel.is-open .explain-inner {
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.explain-panel.is-open .explain-inner > * { margin: 0; }
.explain-body-pad { padding: 1rem 1.15rem; display: grid; gap: .7rem; font-size: .93rem; line-height: 1.65; }
.explain-body-pad p { color: var(--ink-700); }
.explain-source {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-500); border-top: 1px solid var(--line); padding-top: .6rem;
}
.explain-notice { color: var(--ink-500); font-style: italic; }
.explain-error { color: var(--clay-600); }
:root[data-theme="dark"] .explain-error { color: #f0a294; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .explain-error { color: #f0a294; }
}

.explain-loading { display: flex; align-items: center; gap: .6rem; color: var(--ink-500); }
.spinner {
  width: 1rem; height: 1rem; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--line); border-top-color: var(--sun-500);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ------------------------------- results ------------------------------ */

.result-hero { display: flex; gap: 2rem; align-items: center; flex-wrap: wrap; padding: 2rem; }
.score-ring {
  flex: 0 0 auto; width: 150px; height: 150px; border-radius: 50%;
  display: grid; place-content: center; text-align: center;
  background: conic-gradient(var(--sun-400) var(--pct, 0%), var(--line) 0);
  position: relative;
}
.score-ring::after {
  content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--surface);
}
.score-ring.is-pass { background: conic-gradient(var(--stem-500) var(--pct, 0%), var(--line) 0); }
.score-value, .score-label { position: relative; z-index: 1; }
.score-value { font-size: 2.1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-500); }
.result-summary { flex: 1 1 320px; display: grid; gap: .6rem; }
.verdict { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.verdict.pass { color: var(--stem-600); }
.verdict.fail { color: var(--clay-600); }
:root[data-theme="dark"] .verdict.pass { color: #7fd6a0; }
:root[data-theme="dark"] .verdict.fail { color: #f0a294; }
.stat-row { display: flex; gap: 1.75rem; flex-wrap: wrap; list-style: none; padding: 0; margin: .5rem 0 0; }
.stat-row li { display: grid; }
.stat-row strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stat-row span { font-size: .78rem; color: var(--ink-500); text-transform: uppercase; letter-spacing: .05em; }
.result-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

.breakdown { display: grid; gap: .9rem; }
.breakdown-row { display: grid; gap: .3rem; }
.breakdown-label { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; }
.breakdown-label span:last-child { font-variant-numeric: tabular-nums; color: var(--ink-500); }
.bar { height: 9px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--sun-400); border-radius: 999px; }
.bar > i.is-strong { background: var(--stem-500); }
.bar > i.is-weak { background: var(--clay-500); }

.review-list { display: grid; gap: 1rem; }
.review-item { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius-sm); padding: 1rem 1.2rem; background: var(--surface-2); }
.review-item.correct { border-left-color: var(--stem-500); }
.review-item.incorrect { border-left-color: var(--clay-500); }
.review-item.unanswered { border-left-color: var(--ink-300); }
.review-head { display: flex; gap: .75rem; justify-content: space-between; align-items: baseline; flex-wrap: wrap; margin-bottom: .5rem; }
.review-index { font-size: .78rem; font-weight: 800; color: var(--ink-500); text-transform: uppercase; letter-spacing: .05em; }
.review-stem { font-weight: 700; margin-bottom: .6rem; }
.review-answers { display: grid; gap: .3rem; font-size: .9rem; margin-bottom: .6rem; }
.review-answers span strong { font-weight: 700; }
.review-rationale { font-size: .88rem; color: var(--ink-700); border-top: 1px solid var(--line); padding-top: .6rem; }

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

.dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 0; background: var(--surface); color: inherit; max-width: 420px; box-shadow: var(--shadow-md); }
.dialog::backdrop { background: rgba(20, 15, 5, .5); }
.dialog form { padding: 1.5rem; display: grid; gap: .75rem; }
.dialog-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: .5rem; }

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

.site-footer {
  border-top: 1px solid var(--line); background: var(--surface);
  padding: 2rem 0; margin-top: 3rem; font-size: .88rem;
}
.site-footer p + p { margin-top: .35rem; }

.view[hidden] { display: none; }

/* The 404 page reuses the button styling on a plain link. */
.notfound-actions { margin-top: 1.5rem; }
.notfound-actions .primary-btn { display: inline-block; text-decoration: none; }

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

@media print {
  .site-header, .site-footer, .result-actions, .filter-row,
  .exam-bar, .exam-footer, .zen-exit { display: none; }
  .panel { break-inside: avoid; box-shadow: none; }
}
