/* ===========================================================
   LTO Non-Professional Mock Exam
   =========================================================== */
:root {
  --bg: #eef2f9;
  --bg-glow: #dfe9ff;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --ink: #101a2e;
  --ink-2: #334159;
  --muted: #66738c;
  --line: #e2e8f4;
  --line-strong: #cfd8ea;
  --brand: #0b3d91;
  --brand-2: #1d5fd6;
  --brand-ink: #062a66;
  --accent: #d8233f;
  --gold: #f0b429;
  --ok: #0c8a57;
  --ok-bg: #e7f7ef;
  --bad: #c92a3c;
  --bad-bg: #fdecee;
  --warn: #b45309;
  --shadow-sm: 0 1px 2px rgba(16, 26, 46, .05), 0 4px 12px rgba(16, 26, 46, .05);
  --shadow-md: 0 10px 30px rgba(16, 26, 46, .09);
  --shadow-lg: 0 24px 60px rgba(9, 22, 48, .18);
  --radius: 18px;
  --radius-sm: 12px;
  --tap: 46px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #080e1c;
    --bg-glow: #0d1930;
    --surface: #111b2f;
    --surface-2: #0d1628;
    --ink: #eef3ff;
    --ink-2: #c3cee4;
    --muted: #94a2bd;
    --line: #223050;
    --line-strong: #2e4066;
    --brand: #5b8dff;
    --brand-2: #3f7bff;
    --brand-ink: #bcd3ff;
    --accent: #ff5d72;
    --gold: #f6c445;
    --ok: #45d699;
    --ok-bg: #0d2b20;
    --bad: #ff7a89;
    --bad-bg: #33131a;
    --warn: #f0ad5a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 16px rgba(0, 0, 0, .22);
    --shadow-md: 0 14px 34px rgba(0, 0, 0, .4);
    --shadow-lg: 0 30px 70px rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1100px 520px at 12% -8%, var(--bg-glow) 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(240, 180, 41, .10) 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; }
.icon.flip { transform: rotate(180deg); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 8px; }

/* ---------- layout ---------- */
.screen { min-height: 100vh; min-height: 100dvh; }
.wrap { width: min(1080px, 100%); margin: 0 auto; padding: 28px 20px 40px; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 34px 32px 0;
  color: #fff;
  background:
    radial-gradient(700px 300px at 95% -20%, rgba(240, 180, 41, .38), transparent 60%),
    radial-gradient(600px 340px at 10% 120%, rgba(59, 130, 246, .55), transparent 65%),
    linear-gradient(135deg, #08265b 0%, #0b3d91 52%, #1257b8 100%);
  box-shadow: var(--shadow-lg);
}
.hero::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .16) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: .35;
  pointer-events: none;
  mask-image: linear-gradient(180deg, transparent 20%, #000 100%);
}
.hero-top { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.crest {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(160deg, #fff, #dbe6ff);
  color: #0b3d91;
  font-weight: 900; font-size: 13px; letter-spacing: .04em;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
}
.hero-eyebrow { font-size: 12px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: #cfe0ff; }
.hero h1 {
  position: relative; z-index: 1;
  margin: 22px 0 12px;
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.02;
  letter-spacing: -.03em;
  font-weight: 850;
}
.hero h1 span { color: var(--gold); }
.hero-sub { position: relative; z-index: 1; max-width: 620px; color: #d7e3fb; font-size: 15.5px; }
.hero-stats {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 28px -32px 0;
  background: rgba(255, 255, 255, .14);
  border-top: 1px solid rgba(255, 255, 255, .16);
}
.hstat { padding: 16px 14px 18px; background: rgba(6, 26, 64, .18); text-align: center; backdrop-filter: blur(6px); }
.hstat strong { display: block; font-size: 26px; font-weight: 820; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hstat span { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: #c7d8f7; }

/* ---------- cards ---------- */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 348px; gap: 20px; margin-top: 20px; align-items: start; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head { padding: 22px 22px 0; }
.card-head h2 { font-size: 19px; letter-spacing: -.01em; }
.card-head p { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.card-head.row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

/* ---------- setup ---------- */
.setup { padding-bottom: 18px; }
.field { border: 0; margin: 0; padding: 20px 22px 0; min-width: 0; }
.field legend {
  padding: 0; margin-bottom: 10px;
  font-size: 12px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.choice-grid { display: grid; gap: 9px; }
.choice-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice { position: relative; display: block; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice-body {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px 12px 40px;
  min-height: 58px;
  border: 1.5px solid var(--line-strong);
  border-radius: 13px;
  background: var(--surface-2);
  transition: border-color .16s, background .16s, box-shadow .16s, transform .16s;
}
.choice-body::before {
  content: "";
  position: absolute; left: 14px; top: 50%; width: 16px; height: 16px;
  margin-top: -8px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  transition: border-color .16s, box-shadow .16s;
}
.choice-title { font-size: 14.5px; font-weight: 680; letter-spacing: -.005em; }
.choice-sub { font-size: 12px; color: var(--muted); }
.choice:hover .choice-body { border-color: color-mix(in srgb, var(--brand) 45%, var(--line-strong)); }
.choice input:checked + .choice-body {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 7%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent);
}
.choice input:checked + .choice-body::before {
  border-color: var(--brand);
  background: var(--brand);
  box-shadow: inset 0 0 0 3.5px var(--surface);
}
.choice input:focus-visible + .choice-body { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.choice.is-disabled { opacity: .45; pointer-events: none; }

.switch-list { display: grid; gap: 8px; }
.switch-row {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 13px;
  background: var(--surface-2);
  cursor: pointer;
}
.switch-copy { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.switch-title { font-size: 14px; font-weight: 650; }
.switch-sub { font-size: 12px; color: var(--muted); }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch {
  position: relative; flex: none;
  width: 44px; height: 26px; border-radius: 999px;
  background: var(--line-strong);
  transition: background .18s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s;
}
.switch-row input:checked + .switch { background: var(--brand); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.switch-row:has(input:disabled) { opacity: .5; cursor: not-allowed; }
.field-note { margin-top: 10px; font-size: 12px; color: var(--muted); }

.start-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin: 20px 22px 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.start-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
#start-count { font-size: 15px; font-weight: 750; letter-spacing: -.01em; }
#start-mode { font-size: 12px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  font-size: 14px; font-weight: 700; letter-spacing: -.005em;
  transition: transform .12s, box-shadow .16s, background .16s, border-color .16s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn-primary { background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn-primary:hover { box-shadow: 0 8px 22px color-mix(in srgb, var(--brand) 45%, transparent); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--brand); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 12.5px; border-radius: 9px; }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 15.5px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.danger-text { color: var(--bad); }
.btn-danger { background: var(--bad); color: #fff; }

/* ---------- progress card ---------- */
.progress-card { padding-bottom: 16px; position: sticky; top: 18px; }
.progress-summary { display: flex; align-items: center; gap: 18px; padding: 18px 22px 0; }
.ring {
  --pct: 0;
  position: relative; flex: none;
  width: 92px; height: 92px; border-radius: 50%;
  display: grid; place-items: center; align-content: center;
  background: conic-gradient(var(--brand) calc(var(--pct) * 1%), var(--line) 0);
}
.ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--surface); }
.ring span, .ring small { position: relative; z-index: 1; }
.ring span { font-size: 22px; font-weight: 820; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ring small { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.progress-facts { display: grid; gap: 8px; flex: 1; }
.fact { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.fact strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.fact span { font-size: 12px; color: var(--muted); }
.progress-actions { padding: 16px 22px 0; }
.history { padding: 18px 22px 0; }
.history h3 { font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; max-height: 260px; overflow: auto; }
.history-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 12.5px;
}
.history-item .h-left { display: flex; flex-direction: column; min-width: 0; }
.history-item .h-date { color: var(--muted); font-size: 11px; }
.history-item .h-mode { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item .h-score { display: flex; align-items: center; gap: 6px; font-weight: 750; font-variant-numeric: tabular-nums; }
.pill { font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 2px 6px; border-radius: 999px; text-transform: uppercase; }
.pill.pass { background: var(--ok-bg); color: var(--ok); }
.pill.fail { background: var(--bad-bg); color: var(--bad); }
.history-list .empty { color: var(--muted); font-size: 12.5px; padding: 10px 2px; }

/* ---------- quiz ---------- */
.quiz-top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.quiz-top-inner {
  width: min(820px, 100%); margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
}
.quiz-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.quiz-counter { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.quiz-cat { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiz-tools { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: grid; place-items: center;
  width: 42px; height: 42px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink-2);
  transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.icon-btn[aria-pressed="true"] { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); background: color-mix(in srgb, var(--gold) 13%, var(--surface)); }
.icon-btn[aria-pressed="true"] svg { fill: color-mix(in srgb, var(--gold) 30%, transparent); }
.timer-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 34px; padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px; font-weight: 750;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.timer-chip .icon { width: 15px; height: 15px; color: var(--muted); }
.timer-chip.is-low { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-bg); }
.timer-chip.is-low .icon { color: var(--bad); }
.progress-track { height: 5px; background: var(--line); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-2), var(--brand)); transition: width .25s ease; }

.quiz-main { width: min(820px, 100%); margin: 0 auto; padding: 18px 16px calc(112px + env(safe-area-inset-bottom)); }
.question-card { animation: rise .22s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.q-badges { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase;
  background: color-mix(in srgb, var(--brand) 9%, var(--surface));
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 18%, transparent);
}
.badge.moto { background: color-mix(in srgb, var(--gold) 15%, var(--surface)); color: #8a5a00; border-color: color-mix(in srgb, var(--gold) 38%, transparent); }
@media (prefers-color-scheme: dark) { .badge.moto { color: var(--gold); } }
.badge.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.q-index { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.q-text { font-size: clamp(19px, 2.6vw, 23px); line-height: 1.35; letter-spacing: -.015em; font-weight: 760; }
.q-figure { margin: 16px 0 4px; display: flex; justify-content: center; }
.q-figure img {
  display: block; width: auto; max-width: min(100%, 420px); max-height: 260px;
  object-fit: contain;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}
.options { display: grid; gap: 9px; margin-top: 18px; }
.option {
  position: relative;
  display: flex; align-items: flex-start; gap: 13px;
  width: 100%; min-height: 60px;
  padding: 13px 15px;
  text-align: left;
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color .14s, background .14s, box-shadow .14s, transform .1s;
}
.option:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line-strong)); background: var(--surface-2); }
.option:active { transform: scale(.995); }
.letter {
  flex: none;
  display: grid; place-items: center;
  width: 30px; height: 30px; margin-top: -1px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-size: 13px; font-weight: 800;
  color: var(--ink-2);
}
.option-text { font-size: 15px; line-height: 1.45; padding-top: 3px; }
.option.is-selected { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.option.is-selected .letter { background: var(--brand); border-color: var(--brand); color: #fff; }
.option.is-correct { border-color: var(--ok); background: var(--ok-bg); box-shadow: none; }
.option.is-correct .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.option.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.option.is-wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.option .mark { margin-left: auto; flex: none; align-self: center; color: var(--ok); }
.option.is-wrong .mark { color: var(--bad); }
.option:disabled { cursor: default; }
.option:disabled:hover { transform: none; }
.option:disabled:not(.is-selected):not(.is-correct):not(.is-wrong):hover { background: var(--surface); border-color: var(--line-strong); }

.image-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.image-option {
  position: relative;
  display: flex; flex-direction: column;
  padding: 8px;
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  text-align: center;
  transition: border-color .14s, box-shadow .14s, transform .1s;
}
.image-option:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line-strong)); }
.image-option:active { transform: scale(.99); }
.image-option .img-wrap {
  display: grid; place-items: center;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}
.image-option img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-option .letter {
  position: absolute; top: 10px; left: 10px;
  background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.image-option.is-selected { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); }
.image-option.is-selected .letter { background: var(--brand); border-color: var(--brand); color: #fff; }
.image-option.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.image-option.is-correct .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.image-option.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.image-option.is-wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.image-option:disabled { cursor: default; }
.image-option .tick {
  position: absolute; top: 10px; right: 10px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ok); color: #fff;
}
.image-option .tick.bad { background: var(--bad); }
.image-option .tick svg { width: 13px; height: 13px; }

.feedback {
  display: flex; align-items: flex-start; gap: 9px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.feedback.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.feedback strong { font-weight: 800; }
.feedback .icon { width: 17px; height: 17px; margin-top: 1px; }

.quiz-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.quiz-nav .btn { flex: 1; }
.quiz-nav #next-btn { flex: 1.5; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(6, 14, 30, .55);
  backdrop-filter: blur(4px);
  animation: fade .16s ease both;
  padding: 0;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  width: min(680px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  animation: sheet .22s cubic-bezier(.2, .8, .25, 1) both;
}
@media (min-width: 640px) {
  .modal { align-items: center; padding: 24px; }
  .modal-card { border-radius: 22px; padding: 24px; }
}
@keyframes sheet { from { transform: translateY(28px); opacity: .4; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h3 { font-size: 18px; letter-spacing: -.01em; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.modal-close { flex: none; }
.modal-body { font-size: 14px; color: var(--ink-2); }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
@media (min-width: 640px) { .modal-actions .btn { flex: none; min-width: 110px; } }

.grid-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; font-size: 11.5px; color: var(--muted); }
.grid-legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 3px; background: var(--line-strong); display: inline-block; }
.dot.answered { background: var(--brand); }
.dot.flagged { background: var(--gold); }
.dot.current { background: var(--ink); }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 7px; }
.qgrid button {
  position: relative;
  height: 42px; border-radius: 10px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  transition: border-color .12s, background .12s;
}
.qgrid button:hover { border-color: var(--brand); }
.qgrid button.answered { background: color-mix(in srgb, var(--brand) 14%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); color: var(--brand); }
.qgrid button.flagged::after {
  content: ""; position: absolute; top: 4px; right: 4px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--gold);
}
.qgrid button.current { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.grid-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.grid-foot .btn { min-width: 120px; }

/* ---------- results ---------- */
.results-wrap { width: min(900px, 100%); padding-bottom: 48px; }
.results-wrap > * { }
.result-hero {
  position: relative; overflow: hidden;
  border-radius: 24px;
  padding: 28px;
  color: #fff;
  background: linear-gradient(135deg, #0a2a63, #0b3d91 55%, #1257b8);
  box-shadow: var(--shadow-lg);
}
.result-hero.fail { background: linear-gradient(135deg, #3d0b18, #7a1229 55%, #a81c38); }
.result-hero::after {
  content: ""; position: absolute; right: -80px; top: -80px;
  width: 280px; height: 280px; border-radius: 50%;
  background: rgba(255, 255, 255, .09);
}
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; position: relative; z-index: 1; }
.verdict {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 11px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
}
.verdict.pass { background: rgba(69, 214, 153, .2); border-color: rgba(69, 214, 153, .55); color: #d6ffee; }
.verdict.fail { background: rgba(255, 141, 155, .18); border-color: rgba(255, 141, 155, .5); color: #ffe1e5; }
.result-hero h2 { position: relative; z-index: 1; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.02em; margin-top: 14px; }
.result-hero .sub { position: relative; z-index: 1; color: #d6e3fb; font-size: 13.5px; margin-top: 4px; }
.result-score { display: flex; align-items: flex-end; gap: 10px; margin-top: 20px; position: relative; z-index: 1; flex-wrap: wrap; }
.result-score .big { font-size: clamp(46px, 9vw, 68px); font-weight: 850; line-height: .95; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.result-score .pct { font-size: 22px; font-weight: 750; color: var(--gold); margin-bottom: 6px; }
.result-score .fraction { font-size: 15px; color: #c8d9f7; margin-bottom: 9px; }
.result-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; position: relative; z-index: 1; }
.rfact {
  display: flex; align-items: baseline; gap: 6px;
  padding: 7px 11px; border-radius: 10px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .16);
  font-size: 12px; color: #dce7fb;
}
.rfact strong { font-size: 14px; color: #fff; font-variant-numeric: tabular-nums; }
.review-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 22px 0 14px;
  flex-wrap: wrap;
}
.tabs { display: inline-flex; gap: 3px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 9px;
  font-size: 13px; font-weight: 680;
}
.tab.is-active { background: var(--brand); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--brand) 30%, transparent); }
.review-count { font-size: 12.5px; color: var(--muted); }
.result-hero .badge.ghost {
  color: #dce7fb;
  border-color: rgba(255, 255, 255, .3);
  background: rgba(255, 255, 255, .08);
}
.review-list { display: grid; gap: 12px; }
.review-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ok);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.review-card.wrong { border-left-color: var(--bad); }
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.review-num { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.review-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag { font-size: 10px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.tag.flag { color: #8a5a00; border-color: color-mix(in srgb, var(--gold) 40%, transparent); background: color-mix(in srgb, var(--gold) 14%, var(--surface)); }
@media (prefers-color-scheme: dark) { .tag.flag { color: var(--gold); } }
.review-card .q-text { font-size: 16.5px; font-weight: 700; }
.review-figure { margin: 10px 0 0; }
.review-figure img {
  display: block; max-width: min(100%, 300px); max-height: 190px;
  object-fit: contain; padding: 8px; background: #fff;
  border: 1px solid var(--line); border-radius: 12px;
}
.review-options { display: grid; gap: 6px; margin-top: 12px; }
.review-opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13.5px;
  background: var(--surface-2);
}
.review-opt .letter { width: 24px; height: 24px; border-radius: 7px; font-size: 11px; margin-top: 0; }
.review-opt.is-correct { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); background: var(--ok-bg); }
.review-opt.is-correct .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.review-opt.is-wrong { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); background: var(--bad-bg); }
.review-opt.is-wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.review-opt .ro-text { flex: 1; padding-top: 1px; }
.ro-tag { font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; align-self: center; }
.review-opt.is-correct .ro-tag { color: var(--ok); }
.review-opt.is-wrong .ro-tag { color: var(--bad); }
.review-images { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.review-img {
  position: relative; display: grid; place-items: center;
  padding: 6px; background: #fff; border: 1.5px solid var(--line);
  border-radius: 10px; aspect-ratio: 1 / 1;
}
.review-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.review-img.is-correct { border-color: var(--ok); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 25%, transparent); }
.review-img.is-wrong { border-color: var(--bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 25%, transparent); }
.review-img .letter { position: absolute; top: 5px; left: 5px; width: 21px; height: 21px; font-size: 10px; border-radius: 6px; background: var(--surface); }
.review-img.is-correct .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.review-img.is-wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.review-summary { margin-top: 11px; font-size: 12.5px; color: var(--muted); }
.review-summary b { color: var(--ink); }
.review-summary .good { color: var(--ok); }
.review-summary .bad { color: var(--bad); }
.results-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.results-actions .btn { flex: 1; min-width: 190px; }
.empty-review { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 14px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 14px; }

@media (min-width: 900px) {
  .quiz-nav {
    left: 50%; right: auto; transform: translateX(-50%);
    width: 820px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
  }
}

/* ---------- footer ---------- */
.foot { margin-top: 26px; text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.foot p { max-width: 680px; margin: 0 auto; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr; }
  .progress-card { position: static; }
}
@media (max-width: 620px) {
  .wrap { padding: 14px 12px 32px; }
  .hero { border-radius: 20px; padding: 22px 20px 0; }
  .hero h1 { margin-top: 16px; }
  .hero-sub { font-size: 14px; }
  .hero-stats { margin: 22px -20px 0; grid-template-columns: repeat(2, 1fr); }
  .hstat { padding: 12px 10px 14px; }
  .hstat strong { font-size: 22px; }
  .card { border-radius: 16px; }
  .card-head { padding: 18px 16px 0; }
  .field { padding: 16px 16px 0; }
  .choice-grid.cols-2, .choice-grid.cols-3 { grid-template-columns: 1fr; }
  .choice-body { min-height: 54px; padding: 10px 12px 10px 38px; }
  .start-bar { flex-direction: column; align-items: stretch; margin: 16px 16px 0; }
  .start-bar .btn { width: 100%; }
  .progress-summary { padding: 16px 16px 0; }
  .progress-actions, .history { padding-left: 16px; padding-right: 16px; }
  .quiz-main { padding: 14px 12px calc(104px + env(safe-area-inset-bottom)); }
  .q-figure img { max-height: 210px; }
  .option { min-height: 56px; padding: 11px 12px; gap: 10px; }
  .option-text { font-size: 14.5px; }
  .image-options { gap: 7px; }
  .image-option { padding: 6px; border-radius: 12px; }
  .image-option .letter { top: 7px; left: 7px; width: 25px; height: 25px; font-size: 11px; }
  .quiz-nav { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .result-hero { padding: 22px 18px; border-radius: 18px; }
  .review-card { padding: 14px 14px; }
  .results-actions .btn { min-width: 100%; }
  .quiz-top-inner { padding: 8px 10px; gap: 6px; }
  .icon-btn { width: 40px; height: 40px; }
  .timer-chip { height: 32px; padding: 0 8px; font-size: 12px; }
  .q-badges .badge { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
