/* ==========================================================================
   Testit :: Mock Exam Platform
   Structural design system: layout, spacing, and every component. Colour
   tokens are NOT defined here — they live in themes.css, keyed by the
   data-theme / data-mode attributes theme.js sets on <html>, so the same
   markup and layout renders in any of five accent themes and either a light
   or dark mode. This file uses no third-party brand colours or brand assets.
   ========================================================================== */

:root {
  /* Type */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  /* Shape */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --r-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(25, 25, 23, .06), 0 1px 3px rgba(25, 25, 23, .04);
  --shadow:    0 2px 4px rgba(25, 25, 23, .05), 0 8px 24px rgba(25, 25, 23, .07);
  --shadow-lg: 0 4px 8px rgba(25, 25, 23, .06), 0 20px 48px rgba(25, 25, 23, .10);

  --wrap: 1100px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -.015em;
  line-height: 1.2;
  margin: 0 0 .5em;
  color: var(--ink);
}
h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; font-family: var(--sans); font-weight: 600; }

p { margin: 0 0 1em; }
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.wrap-narrow { max-width: 780px; }

/* ---------- Utility ---------- */
.mono { font-family: var(--mono); }
.muted { color: var(--slate-2); }
.small { font-size: .875rem; }
.xsmall { font-size: .8rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(var(--canvas-rgb), .88);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; height: 64px;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 600; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-family: var(--serif); font-weight: 500; font-size: 1.06rem; }
.brand-text span { font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; color: var(--slate-2); }
.topnav { display: flex; gap: 6px; align-items: center; }
.topnav a {
  padding: 8px 13px; border-radius: 999px; font-size: .9rem;
  color: var(--slate); font-weight: 500;
}
.topnav a:hover { background: var(--accent-soft); color: var(--accent-dark); text-decoration: none; }

/* ---------- Browse Exams nav dropdown ---------- */
.nav-browse { position: relative; }
.nav-browse-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px; border-radius: 999px; border: 0;
  background: transparent; color: var(--slate); font: inherit; font-weight: 500; font-size: .9rem;
  cursor: pointer; transition: background .12s ease, color .12s ease;
}
.nav-browse-btn:hover, .nav-browse-btn[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-dark); }
.nav-browse-btn svg { transition: transform .15s ease; }
.nav-browse-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.nav-browse-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 50;
  min-width: 280px; max-height: 60vh; overflow-y: auto;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 6px;
}
.nav-browse-menu a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none;
}
.nav-browse-menu a:hover, .nav-browse-menu a:focus-visible { background: var(--accent-soft); color: var(--accent-dark); outline: none; }
.nav-browse-menu .nb-title { font-size: .9rem; font-weight: 500; }
.nav-browse-menu .nb-code { font-family: var(--mono); font-size: .72rem; color: var(--slate-2); white-space: nowrap; }
.nav-browse-menu .nb-empty { display: block; padding: 10px 12px; color: var(--slate-2); font-size: .85rem; }

/* Brand glyph */
.brand-glyph { display: block; }

/* ---------- Theme switcher ---------- */
.theme-switcher { display: flex; align-items: center; gap: 8px; }
.theme-swatches {
  display: flex; align-items: center; gap: 5px; padding: 5px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 999px;
}
.theme-swatch {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent;
  background: var(--sw); cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
  transition: transform .12s ease, border-color .12s ease;
}
.theme-swatch:hover { transform: scale(1.15); }
.theme-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-swatch.is-on { border-color: var(--ink); }
.theme-mode-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; padding: 0;
  background: var(--paper-2); border: 1px solid var(--line); color: var(--slate);
  cursor: pointer; transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.theme-mode-btn:hover { background: var(--paper); color: var(--ink); border-color: var(--slate-2); }
.theme-mode-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Inside the always-dark exam bar, the switcher borrows the timer chip's own
   fixed dark styling instead of the page's theme colours, for the same
   reason .exam-bar itself does not follow the theme. */
.exam-bar .theme-swatches { background: #262624; border-color: #3A3A36; }
.exam-bar .theme-swatch.is-on { border-color: #F2F0E9; }
.exam-bar .theme-mode-btn { background: #262624; border-color: #3A3A36; color: #9A978B; }
.exam-bar .theme-mode-btn:hover { background: #322F2B; color: #F2F0E9; border-color: #4A4640; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  background: var(--accent); color: #fff; text-decoration: none;
  transition: background .15s ease, transform .06s ease, box-shadow .15s ease, color .15s ease, border-color .15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--accent-dark); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--sand); outline-offset: 2px; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; transform: none; }

.btn-ghost { background: transparent; color: var(--accent-dark); border-color: var(--sand); box-shadow: none; }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-deep); border-color: var(--accent); text-decoration: none; }

.btn-quiet { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--sand); box-shadow: var(--shadow-sm); }
.btn-quiet:hover { background: var(--wheat); color: var(--accent-deep); border-color: var(--accent); text-decoration: none; }

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

.btn-sm { padding: 8px 15px; font-size: .875rem; }
.btn-lg { padding: 15px 30px; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}
.card-flat { box-shadow: none; }
.card-white { background: var(--paper-2); }
.card + .card { margin-top: 20px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent-dark);
  border: 1px solid var(--sand);
}
.pill-neutral { background: var(--paper-2); color: var(--slate); border-color: var(--line); }
.pill-ok   { background: var(--ok-soft);   color: var(--ok);   border-color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.pill-bad  { background: var(--bad-soft);  color: var(--bad);  border-color: var(--bad); }

/* ---------- Hero (home) ---------- */
.hero { padding: 64px 0 40px; position: relative; overflow: hidden; }
.hero-grid {
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center;
}
.hero h1 { margin-bottom: .35em; }
.hero-lede { font-size: 1.12rem; color: var(--slate); max-width: 46ch; }
.hero-cta { margin-top: 26px; display: flex; gap: 12px; flex-wrap: wrap; }
.hero-note { margin-top: 18px; font-size: .85rem; color: var(--slate-2); }

.glance {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 6px 22px; box-shadow: var(--shadow);
}
.glance dl { margin: 0; }
.glance dl > div {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 13px 0; border-bottom: 1px solid var(--line-2);
}
.glance dl > div:last-child { border-bottom: 0; }
.glance dt { color: var(--slate-2); font-size: .86rem; }
.glance dd { margin: 0; font-weight: 600; font-size: .9rem; text-align: right; }

/* Section rhythm */
.section { padding: 46px 0; }
.section-head { margin-bottom: 26px; max-width: 62ch; }
.section-head .pill { margin-bottom: 14px; }
.hr { height: 1px; background: var(--line); border: 0; margin: 0; }

/* ---------- Feature grid ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.feature { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; }
.feature h4 { margin-bottom: .35em; }
.feature p { margin: 0; font-size: .9rem; color: var(--slate); }
.feature-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; margin-bottom: 12px;
  background: var(--accent-soft); color: var(--accent-dark);
  font-weight: 700; font-size: .85rem; font-family: var(--mono);
}

/* ---------- Blueprint table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper-2); }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 560px; }
table.data th, table.data td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line-2); }
table.data thead th {
  background: var(--canvas); font-size: .74rem; letter-spacing: .07em;
  text-transform: uppercase; color: var(--slate-2); font-weight: 600; white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.total-row td { background: var(--canvas); font-weight: 700; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dom-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: var(--r-sm);
  background: var(--wheat); color: var(--accent-deep);
  font-family: var(--mono); font-size: .78rem; font-weight: 700;
}

/* weight bar */
.wbar { height: 7px; background: var(--line-2); border-radius: 999px; overflow: hidden; min-width: 90px; }
.wbar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* ---------- Objective lists ---------- */
.dom-card { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.dom-card + .dom-card { margin-top: 12px; }
.dom-card > summary {
  cursor: pointer; padding: 16px 20px; display: flex; align-items: center; gap: 12px;
  font-weight: 600; list-style: none;
}
.dom-card > summary::-webkit-details-marker { display: none; }
.dom-card > summary:hover { background: var(--paper); }
.dom-card > summary .chev { margin-left: auto; color: var(--slate-2); transition: transform .18s ease; }
.dom-card[open] > summary .chev { transform: rotate(90deg); }
.dom-card > summary .w { font-size: .8rem; color: var(--slate-2); font-variant-numeric: tabular-nums; }
.dom-body { padding: 4px 20px 18px 58px; border-top: 1px solid var(--line-2); }
.dom-body ul { margin: 12px 0 0; padding-left: 18px; }
.dom-body li { font-size: .9rem; color: var(--slate); margin-bottom: 6px; }

/* ---------- Exam cards ---------- */
.exam-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.exam-card {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px; display: flex; flex-direction: column; gap: 10px;
}
.exam-card .exam-code { font-family: var(--mono); font-size: .76rem; color: var(--slate-2); letter-spacing: .04em; }
.exam-card h4 { margin: 0; }
.exam-card p { margin: 0; font-size: .87rem; color: var(--slate); flex: 1 1 auto; }
.exam-card .exam-meta { display: flex; gap: 8px; flex-wrap: wrap; }
/* Actions sit at the card's foot; the description above flexes, so every card
   in a row keeps the same height regardless of how long its blurb is. */
.exam-card-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  border-top: 1px dashed var(--line); padding-top: 14px; margin-top: 4px;
}
.exam-card-actions .btn { flex: 1 1 auto; }

/* ---------- Exam details modal ---------- */
.modal-wide { width: 70vw; height: 70vh; max-width: 70vw; max-height: 70vh; display: flex; flex-direction: column; }
.em-head { display: flex; align-items: flex-start; gap: 16px; flex-shrink: 0; }
.em-head-text { min-width: 0; }
.em-head-text .exam-code {
  font-family: var(--mono); font-size: .76rem; color: var(--slate-2); letter-spacing: .04em;
}
.em-head-text h3 { margin: 4px 0 2px; }
.em-group:empty { display: none; }
.em-close {
  margin-left: auto; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; border-radius: 50%;
  background: transparent; border: 1px solid var(--line); color: var(--slate-2);
  cursor: pointer; transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.em-close:hover { background: var(--paper); color: var(--ink); border-color: var(--slate-2); }
.em-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The body scrolls inside the panel, so a long blueprint never pushes the
   action buttons off-screen. */
.em-body {
  margin-top: 18px; overflow-y: auto; flex: 1 1 auto; min-height: 0;
  max-height: none; padding-right: 4px;
}
.em-desc { font-size: .92rem; color: var(--slate); margin: 0 0 4px; }
.em-h {
  margin: 22px 0 10px; font-size: .78rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--slate-2);
}
.em-glance { box-shadow: none; padding: 2px 18px; }
.em-body .table-wrap { font-size: .85rem; overflow-x: hidden; width: 100%; }
.em-body table.data { min-width: 0; width: 100%; table-layout: fixed; }
.em-body table.data th, .em-body table.data td { padding: 10px 10px; word-break: break-word; }
.em-body .wbar { min-width: 0; width: 100%; max-width: 80px; }
.em-body .dom-card { font-size: .88rem; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field .hint { font-size: .8rem; color: var(--slate-2); margin: 0 0 7px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; font: inherit; font-size: .95rem;
  background: var(--paper-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .22);
}
.input.is-error { border-color: var(--bad); background: var(--bad-soft); }
.err-msg { color: var(--bad); font-size: .82rem; margin: 6px 0 0; min-height: 1em; }
select.input { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B6B63' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }

.checkline { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; color: var(--slate); }
.checkline input { margin-top: 4px; flex: 0 0 auto; accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: none;
  background: rgba(25, 25, 23, .45); backdrop-filter: blur(3px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
body.modal-open { overflow: hidden; }
.modal {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); width: 70vw; height: 70vh; max-width: 70vw; max-height: 70vh;
  padding: 30px; display: flex; flex-direction: column; box-sizing: border-box; overflow-y: auto;
}
.modal h3 { margin-bottom: .5em; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: auto; padding-top: 16px; flex-wrap: wrap; flex-shrink: 0; }

/* ==========================================================================
   EXAM RUNNER
   ========================================================================== */
body.exam-mode { background: var(--canvas); }

/* The exam bar is deliberately a fixed dark "focus mode" chrome — it does not
   follow the page theme or light/dark mode, the same way it did not before
   dark mode existed. Colours here are literals on purpose, not var(--ink) /
   var(--canvas), which would otherwise flip this bar to bright white the
   moment a candidate switches to a dark theme. */
.exam-bar {
  position: sticky; top: 0; z-index: 40;
  background: #171715; color: #F2F0E9;
  border-bottom: 1px solid #000;
}
.exam-bar-inner { display: flex; align-items: center; gap: 18px; height: 60px; }
.exam-bar .ex-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .95rem; color: #F2F0E9; }
.exam-bar .ex-cand {
  font-size: .82rem; color: #B8B5A8; border-left: 1px solid #3A3A36; padding-left: 18px;
  display: flex; flex-direction: column; line-height: 1.3; min-width: 0;
}
.exam-bar .ex-cand b { color: #F2F0E9; font-weight: 600; font-size: .88rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30ch; }
.exam-bar .ex-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.timer {
  display: flex; align-items: center; gap: 9px;
  background: #262624; border: 1px solid #3A3A36; border-radius: 999px;
  padding: 8px 17px; font-family: var(--mono); font-size: 1.02rem;
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.timer .t-label { font-family: var(--sans); font-size: .7rem; letter-spacing: .08em;
  text-transform: uppercase; color: #9A978B; }
.timer.is-warn { background: #4A3617; border-color: #7A5A25; color: #F5C978; }
.timer.is-crit { background: #4A1F1B; border-color: #7E332B; color: #F5A79B;
  animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .62 } }

.exam-layout {
  display: grid; grid-template-columns: 1fr 280px; gap: 24px;
  align-items: start; padding: 24px 0 40px;
}

/* progress strip */
.progress-strip { background: var(--paper); border-bottom: 1px solid var(--line); }
.progress-strip-inner { display: flex; align-items: center; gap: 16px; padding: 11px 0; }
.pbar { flex: 1 1 auto; height: 6px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.pbar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.progress-strip .p-text { font-size: .82rem; color: var(--slate-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* question card */
.q-card {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 30px 32px; box-shadow: var(--shadow-sm);
}
.q-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.q-num { font-family: var(--mono); font-size: .82rem; font-weight: 700; color: var(--slate-2); letter-spacing: .04em; }
.q-dom { font-size: .74rem; color: var(--slate-2); }
.q-flag-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 7px;
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font: inherit; font-size: .82rem; font-weight: 600;
  color: var(--slate-2); cursor: pointer; transition: all .15s ease;
}
.q-flag-btn:hover { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.q-flag-btn.is-on { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }

.q-stem { font-size: 1.06rem; line-height: 1.6; color: var(--ink); margin-bottom: 8px; white-space: pre-wrap; }
.q-instruction {
  font-size: .85rem; font-weight: 600; color: var(--accent-dark);
  background: var(--accent-soft); border-radius: var(--r-sm);
  padding: 8px 13px; display: inline-block; margin-bottom: 20px;
}

.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; gap: 13px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 17px; cursor: pointer; background: var(--paper);
  transition: border-color .13s ease, background .13s ease;
}
.opt:hover { border-color: var(--sand); background: var(--paper-2); }
.opt input { margin: 3px 0 0; flex: 0 0 auto; accent-color: var(--accent); width: 17px; height: 17px; cursor: pointer; }
.opt .opt-key {
  flex: 0 0 auto; font-family: var(--mono); font-weight: 700; font-size: .85rem;
  color: var(--slate-2); min-width: 1.2em;
}
.opt .opt-text { flex: 1 1 auto; font-size: .96rem; line-height: 1.5; }
.opt.is-picked { border-color: var(--accent); background: var(--accent-soft); }
.opt.is-picked .opt-key { color: var(--accent-dark); }

/* Optional per-question / per-option images, set via an exam's YAML. */
.q-img { display: block; max-width: 100%; max-height: 360px; border-radius: var(--r);
  border: 1px solid var(--line); margin-bottom: 14px; }
.q-stem-text { display: block; }
.opt-text-inner { display: block; }
.opt-img { display: block; max-width: 100%; max-height: 220px; border-radius: var(--r-sm);
  border: 1px solid var(--line); margin-bottom: 8px; }

.q-nav { display: flex; gap: 10px; align-items: center; margin-top: 26px; flex-wrap: wrap; }
.q-nav .spacer { flex: 1 1 auto; }

/* sidebar navigator */
.side {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; position: sticky; top: 84px;
}
.side h4 { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--slate-2); margin-bottom: 14px; }
.qgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.qgrid button {
  aspect-ratio: 1; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--paper-2); color: var(--slate-2); cursor: pointer;
  font: inherit; font-size: .76rem; font-weight: 600; font-family: var(--mono);
  display: flex; align-items: center; justify-content: center; position: relative;
  padding: 0; transition: all .12s ease;
}
.qgrid button:hover { border-color: var(--slate-2); }
.qgrid button.is-answered { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.qgrid button.is-flagged::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--warn);
}
.qgrid button.is-current { border-color: var(--accent); border-width: 2px; background: var(--accent-soft); color: var(--accent-dark); }

.legend { margin-top: 16px; display: flex; flex-direction: column; gap: 7px; font-size: .78rem; color: var(--slate-2); }
.legend span { display: flex; align-items: center; gap: 8px; }
.legend i { width: 13px; height: 13px; border-radius: 3px; border: 1px solid var(--line); flex: 0 0 auto; }
.legend i.l-ans { background: var(--ok-soft); border-color: var(--ok); }
.legend i.l-cur { background: var(--accent-soft); border-color: var(--accent); }
.legend i.l-flag { background: var(--warn); border-color: var(--warn); border-radius: 50%; width: 9px; height: 9px; }

.side-stats { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line-2);
  display: flex; flex-direction: column; gap: 6px; font-size: .82rem; }
.side-stats div { display: flex; justify-content: space-between; }
.side-stats b { font-variant-numeric: tabular-nums; }

.side-actions { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(140%);
  background: var(--ink); color: var(--canvas); padding: 13px 22px;
  border-radius: 999px; font-size: .9rem; z-index: 200; box-shadow: var(--shadow-lg);
  transition: transform .3s cubic-bezier(.2,.9,.3,1); max-width: 90vw; text-align: center;
}
.toast.is-up { transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   RESULTS / SCORE REPORT
   ========================================================================== */
.result-hero { padding: 40px 0 10px; }
.verdict {
  border-radius: var(--r-xl); padding: 34px; border: 1px solid var(--line);
  background: var(--paper-2); box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 30px; align-items: center;
}
.verdict.is-pass { border-color: var(--ok); background: linear-gradient(180deg, var(--pass-tint) 0%, var(--paper-2) 70%); }
.verdict.is-fail { border-color: var(--bad); background: linear-gradient(180deg, var(--fail-tint) 0%, var(--paper-2) 70%); }
.verdict h2 { margin-bottom: .25em; }
.verdict p { margin: 0; color: var(--slate); font-size: .95rem; max-width: 52ch; }

.score-dial { text-align: center; }
.score-dial .sd-num {
  font-family: var(--serif); font-size: 3.6rem; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.score-dial .sd-scale { font-size: .78rem; color: var(--slate-2); margin-top: 6px; }
.score-dial.is-pass .sd-num { color: var(--ok); }
.score-dial.is-fail .sd-num { color: var(--bad); }

/* score scale bar */
.scale-bar { margin-top: 26px; }
.scale-track {
  position: relative; height: 12px; border-radius: 999px; margin: 30px 0 8px;
  background: var(--line-2);
  border: 1px solid var(--line);
}
.scale-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--accent); }
.scale-fill.is-pass { background: var(--ok); }
.scale-cut { position: absolute; top: -9px; bottom: -9px; width: 2px; background: var(--ink); }
.scale-cut::after {
  content: attr(data-label); position: absolute; top: -21px; left: 50%; transform: translateX(-50%);
  font-size: .68rem; font-weight: 700; letter-spacing: .05em; color: var(--ink); white-space: nowrap;
}
.scale-ends { display: flex; justify-content: space-between; font-size: .72rem; color: var(--slate-2); }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 22px; }
.tile { background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.tile .t-lab { font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; color: var(--slate-2); }
.tile .t-val { font-family: var(--serif); font-size: 1.75rem; line-height: 1.1; margin-top: 7px; font-variant-numeric: tabular-nums; }
.tile .t-sub { font-size: .78rem; color: var(--slate-2); margin-top: 3px; }

/* domain performance rows */
.dperf { display: flex; flex-direction: column; }
.dperf-row {
  display: grid; grid-template-columns: 30px 1fr 116px 120px 74px;
  gap: 14px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--line-2);
}
.dperf-row:last-child { border-bottom: 0; }
.dperf-row .d-name { font-size: .92rem; font-weight: 500; }
.dperf-row .d-name small { display: block; color: var(--slate-2); font-size: .76rem; font-weight: 400; }
.dperf-bar { height: 9px; background: var(--line-2); border-radius: 999px; overflow: hidden; position: relative; }
.dperf-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.dperf-bar > i.is-ok   { background: var(--ok); }
.dperf-bar > i.is-warn { background: var(--warn); }
.dperf-bar > i.is-bad  { background: var(--bad); }
.dperf-row .d-pct { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .95rem; text-align: right; }
.dperf-row .d-raw { font-size: .8rem; color: var(--slate-2); font-variant-numeric: tabular-nums; }

/* improvement plan */
.plan-item {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r); background: var(--paper-2); padding: 20px 22px;
}
.plan-item + .plan-item { margin-top: 14px; }
.plan-item.pri-high { border-left-color: var(--bad); }
.plan-item.pri-med  { border-left-color: var(--warn); }
.plan-item.pri-low  { border-left-color: var(--ok); }
.plan-item h4 { margin-bottom: 4px; }
.plan-item .plan-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.plan-item ul { margin: 10px 0 0; padding-left: 20px; }
.plan-item li { font-size: .89rem; color: var(--slate); margin-bottom: 5px; }
.miss-list { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.miss-list .ml-lab { font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-2); margin-bottom: 6px; }
.miss-list code { font-family: var(--mono); font-size: .8rem; background: var(--canvas);
  padding: 2px 7px; border-radius: 4px; border: 1px solid var(--line-2); margin: 0 4px 4px 0; display: inline-block; }

/* answer review */
.rev-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  padding: 7px 15px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper-2); color: var(--slate); font: inherit; font-size: .85rem;
  font-weight: 600; cursor: pointer; transition: all .13s ease;
}
.chip:hover { border-color: var(--slate-2); }
.chip.is-on { background: var(--ink); color: var(--canvas); border-color: var(--ink); }

.rev {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--paper-2); overflow: hidden;
}
.rev + .rev { margin-top: 12px; }
.rev > summary {
  cursor: pointer; padding: 15px 18px; display: flex; gap: 12px; align-items: flex-start; list-style: none;
}
.rev > summary::-webkit-details-marker { display: none; }
.rev > summary:hover { background: var(--paper); }
.rev .rev-ic {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; margin-top: 1px;
}
.rev.is-right .rev-ic { background: var(--ok-soft); color: var(--ok); }
.rev.is-wrong .rev-ic { background: var(--bad-soft); color: var(--bad); }
.rev.is-skip  .rev-ic { background: var(--line-2); color: var(--slate-2); }
.rev .rev-sum { flex: 1 1 auto; min-width: 0; }
.rev .rev-sum .rs-meta { font-size: .74rem; color: var(--slate-2); margin-bottom: 3px;
  font-family: var(--mono); letter-spacing: .03em; }
.rev .rev-sum .rs-stem { font-size: .93rem; line-height: 1.45; }
.rev-body { padding: 4px 18px 20px 52px; border-top: 1px solid var(--line-2); }
.rev-opt {
  display: flex; gap: 11px; padding: 10px 13px; border-radius: var(--r-sm);
  border: 1px solid transparent; font-size: .91rem; align-items: flex-start;
}
.rev-opt .ro-key { font-family: var(--mono); font-weight: 700; flex: 0 0 auto; }
.rev-opt .ro-tag { margin-left: auto; font-size: .7rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; white-space: nowrap; padding-left: 10px; }
.rev-opt.ro-correct { background: var(--ok-soft); border-color: var(--ok); }
.rev-opt.ro-correct .ro-tag { color: var(--ok); }
.rev-opt.ro-chosen-bad { background: var(--bad-soft); border-color: var(--bad); }
.rev-opt.ro-chosen-bad .ro-tag { color: var(--bad); }
.rationale {
  margin-top: 14px; padding: 15px 17px; background: var(--canvas);
  border-radius: var(--r-sm); font-size: .89rem; color: var(--slate); border: 1px solid var(--line-2);
}
.rationale b { color: var(--ink); }

/* ---------- Certificate ---------- */
.cert-shell { margin-top: 22px; }
.cert {
  position: relative; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 46px 52px; box-shadow: var(--shadow);
  background-image:
    radial-gradient(circle at 100% 0%, var(--accent-soft), transparent 46%),
    radial-gradient(circle at 0% 100%, var(--wheat), transparent 46%);
  overflow: hidden;
}
.cert::before {
  content: ''; position: absolute; inset: 12px; border: 1px solid var(--line-2);
  border-radius: var(--r); pointer-events: none;
}
.cert-inner { position: relative; }
.cert-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.cert-org { display: flex; align-items: center; gap: 11px; }
.cert-org b { font-family: var(--serif); font-size: 1.05rem; font-weight: 500; }
.cert-org span { display: block; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--slate-2); }
.cert-kicker { font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; color: var(--accent-dark); font-weight: 700; }
.cert h2 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); margin: 6px 0 24px; }
.cert-award { font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--slate-2); margin-bottom: 6px; }
.cert-name {
  font-family: var(--serif); font-size: clamp(1.7rem, 4vw, 2.5rem); line-height: 1.15;
  padding-bottom: 12px; margin-bottom: 8px; border-bottom: 2px solid var(--sand);
  display: inline-block; min-width: 55%; word-break: break-word;
}
.cert-email { font-size: .86rem; color: var(--slate-2); margin-bottom: 26px; }
.cert-body { font-size: .94rem; color: var(--slate); max-width: 62ch; margin-bottom: 28px; }
.cert-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
  padding-top: 22px; border-top: 1px solid var(--line-2); }
.cert-grid .cg-lab { font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: var(--slate-2); }
.cert-grid .cg-val { font-weight: 600; font-size: .95rem; margin-top: 4px; }
.cert-foot { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line-2);
  display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; flex-wrap: wrap; }
.cert-id { font-family: var(--mono); font-size: .78rem; color: var(--slate-2); }
.cert-stamp {
  width: 92px; height: 92px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--accent); color: var(--accent-dark);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; font-size: .58rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; line-height: 1.35; transform: rotate(-7deg); background: var(--accent-soft);
}
.cert-stamp.is-fail { border-color: var(--slate-2); color: var(--slate-2); background: var(--line-2); }
.cert-stamp b { font-family: var(--serif); font-size: 1.05rem; letter-spacing: 0; text-transform: none; }
.cert-disclaimer { font-size: .74rem; color: var(--slate-2); margin-top: 14px; }

/* ---------- Footer ---------- */
.site-foot { border-top: 1px solid var(--line); margin-top: 50px; padding: 32px 0 44px; }
.site-foot .f-grid { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.site-foot p { font-size: .82rem; color: var(--slate-2); margin: 0 0 6px; max-width: 62ch; }
.site-foot a { color: var(--slate); text-decoration: underline; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 70px 20px; }
.empty h2 { margin-bottom: .4em; }
.empty p { color: var(--slate-2); max-width: 46ch; margin: 0 auto 22px; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 940px) {
  .hero-grid { grid-template-columns: 1fr; gap: 32px; }
  .exam-layout { grid-template-columns: 1fr; }
  .side { position: static; order: -1; }
  .qgrid { grid-template-columns: repeat(10, 1fr); }
  .grid-3, .exam-grid { grid-template-columns: 1fr 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .cert-grid { grid-template-columns: 1fr 1fr; }
  .dperf-row { grid-template-columns: 26px 1fr 70px; row-gap: 8px; }
  .dperf-row .dperf-bar { grid-column: 2 / -1; }
  .dperf-row .d-raw { grid-column: 2 / -1; }
}
@media (max-width: 680px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 40px 0 26px; }
  .grid-3, .grid-2, .exam-grid { grid-template-columns: 1fr; }
  .verdict { grid-template-columns: 1fr; }
  .q-card { padding: 22px 18px; }
  .cert { padding: 30px 22px; }
  .cert-grid { grid-template-columns: 1fr; gap: 12px; }
  .qgrid { grid-template-columns: repeat(8, 1fr); }
  .exam-bar-inner { height: auto; padding: 10px 0; flex-wrap: wrap; }
  .exam-bar .ex-cand { border-left: 0; padding-left: 0; }
  .exam-bar .ex-right { width: 100%; }
  .topnav a { padding: 7px 10px; font-size: .84rem; }
  .brand-text span { display: none; }
  /* Brand + theme switcher on the first row, nav wrapping onto a second, so a
     narrow phone header never forces the page to scroll sideways. */
  .topbar-inner { height: auto; padding: 10px 0; flex-wrap: wrap; row-gap: 8px; }
  .topnav { order: 3; width: 100%; }
  /* Stay readable without pushing past the viewport edge. */
  .nav-browse-menu { min-width: min(300px, calc(100vw - 40px)); }
  .dom-body { padding-left: 20px; }
  .rev-body { padding-left: 18px; }
  .modal, .modal-wide { width: 90vw; height: 90vh; max-width: 90vw; max-height: 90vh; padding: 20px 16px; }
}

/* ==========================================================================
   Print - certificate & report only
   ========================================================================== */
@media print {
  body { background: #fff; }
  .topbar, .site-foot, .no-print, .rev-filters, .exam-bar, .progress-strip { display: none !important; }
  .card, .cert, .verdict { box-shadow: none; break-inside: avoid; }
  .cert { border: 1px solid #999; }
  .section { padding: 14px 0; }
  .rev { break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  @page { margin: 12mm; }

  /* "Print certificate" narrows the printout to the certificate alone. */
  body.print-cert-only #report > section:not(#certificate) { display: none !important; }
  body.print-cert-only .site-foot { display: none !important; }
  body.print-cert-only #certificate .section-head { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
