/* ==========================================================================
   David Exams: stylesheet
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --bg-2: #efede6;
  --surface: #ffffff;
  --surface-2: #f9f8f5;
  --surface-3: #f2f0ea;
  --ink: #18171c;
  --ink-2: #4e4c55;
  --muted: #7d7a84;
  --line: #e6e3dc;
  --line-2: #d6d2c8;
  --overlay: rgba(24, 23, 28, 0.42);

  --brand: #c24e22;
  --brand-hover: #a9421b;
  --brand-soft: #fbede6;
  --brand-ink: #9a3b15;
  --on-brand: #ffffff;

  --good: #15803d;
  --good-soft: #e7f5ec;
  --good-line: #9fd8b2;
  --bad: #c42b2b;
  --bad-soft: #fcebea;
  --bad-line: #f0aba7;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --warn-line: #f5c98a;
  --flag: #d97706;

  --c-teal: #0e8a63;
  --c-teal-soft: #e3f4ee;
  --c-violet: #5b4bd0;
  --c-violet-soft: #ecebfb;

  --shadow-sm: 0 1px 2px rgba(24, 23, 28, 0.06);
  --shadow: 0 1px 2px rgba(24, 23, 28, 0.05), 0 8px 24px -8px rgba(24, 23, 28, 0.12);
  --shadow-lg: 0 2px 6px rgba(24, 23, 28, 0.06), 0 24px 60px -16px rgba(24, 23, 28, 0.24);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --topbar-h: 64px;
  --exam: var(--brand);
  --exam-soft: var(--brand-soft);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f11;
    --bg-2: #17171a;
    --surface: #1a1a1e;
    --surface-2: #1f1f24;
    --surface-3: #26262c;
    --ink: #f3f2ee;
    --ink-2: #c5c3bc;
    --muted: #918f98;
    --line: #2c2c32;
    --line-2: #3b3b42;
    --overlay: rgba(0, 0, 0, 0.6);
    --brand: #f0794a;
    --brand-hover: #ff8c5f;
    --brand-soft: rgba(240, 121, 74, 0.14);
    --brand-ink: #ffa47f;
    --on-brand: #1b0f0a;
    --good: #4ade80;
    --good-soft: rgba(74, 222, 128, 0.12);
    --good-line: rgba(74, 222, 128, 0.45);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.12);
    --bad-line: rgba(248, 113, 113, 0.45);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.12);
    --warn-line: rgba(251, 191, 36, 0.4);
    --flag: #fbbf24;
    --c-teal: #34c493;
    --c-teal-soft: rgba(52, 196, 147, 0.13);
    --c-violet: #9085e9;
    --c-violet-soft: rgba(144, 133, 233, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 60px -16px rgba(0, 0, 0, 0.75);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f11;
  --bg-2: #17171a;
  --surface: #1a1a1e;
  --surface-2: #1f1f24;
  --surface-3: #26262c;
  --ink: #f3f2ee;
  --ink-2: #c5c3bc;
  --muted: #918f98;
  --line: #2c2c32;
  --line-2: #3b3b42;
  --overlay: rgba(0, 0, 0, 0.6);
  --brand: #f0794a;
  --brand-hover: #ff8c5f;
  --brand-soft: rgba(240, 121, 74, 0.14);
  --brand-ink: #ffa47f;
  --on-brand: #1b0f0a;
  --good: #4ade80;
  --good-soft: rgba(74, 222, 128, 0.12);
  --good-line: rgba(74, 222, 128, 0.45);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.12);
  --bad-line: rgba(248, 113, 113, 0.45);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --warn-line: rgba(251, 191, 36, 0.4);
  --flag: #fbbf24;
  --c-teal: #34c493;
  --c-teal-soft: rgba(52, 196, 147, 0.13);
  --c-violet: #9085e9;
  --c-violet-soft: rgba(144, 133, 233, 0.15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -8px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 24px 60px -16px rgba(0, 0, 0, 0.75);
}

.exam-teal { --exam: var(--c-teal); --exam-soft: var(--c-teal-soft); }
.exam-violet { --exam: var(--c-violet); --exam-soft: var(--c-violet-soft); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; background: var(--bg); }
html[data-fs="sm"] { font-size: 15px; }
html[data-fs="lg"] { font-size: 17.5px; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
body.has-modal { overflow: hidden; }
img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled, [aria-disabled="true"] { cursor: default; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.2; }
::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
kbd {
  font-family: var(--mono);
  font-size: 0.72em;
  padding: 0.12em 0.45em;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--ink-2);
  white-space: nowrap;
}
mark { background: color-mix(in srgb, var(--flag) 32%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.ic { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 10px; }
.skip:focus { top: 12px; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 640px) { .container { padding: 0 16px; } }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  height: 44px; padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; font-size: 0.94rem; line-height: 1;
  white-space: nowrap;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.18s var(--ease), box-shadow 0.18s;
  user-select: none;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn .ic { width: 1.1em; height: 1.1em; }
.btn kbd { margin-left: 2px; background: transparent; color: inherit; opacity: 0.7; border-color: currentColor; }
.btn-primary { --btn-bg: var(--brand); --btn-fg: var(--on-brand); --btn-bd: transparent; box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 6px 16px -6px color-mix(in srgb, var(--brand) 70%, transparent); }
.btn-primary:hover { --btn-bg: var(--brand-hover); border-color: transparent; }
.btn-ink { --btn-bg: var(--ink); --btn-fg: var(--bg); --btn-bd: transparent; }
.btn-ink:hover { border-color: transparent; opacity: 0.9; }
.btn-exam { --btn-bg: var(--exam); --btn-fg: #fff; --btn-bd: transparent; }
:root[data-theme="dark"] .btn-exam { --btn-fg: #0f0f11; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-exam { --btn-fg: #0f0f11; } }
.btn-exam:hover { border-color: transparent; filter: brightness(1.06); }
.btn-soft { --btn-bg: var(--surface-3); --btn-bd: transparent; }
.btn-soft:hover { --btn-bg: var(--bg-2); border-color: transparent; }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; color: var(--ink-2); }
.btn-ghost:hover { --btn-bg: var(--surface-3); border-color: transparent; color: var(--ink); }
.btn-danger { --btn-bg: var(--bad); --btn-fg: #fff; --btn-bd: transparent; }
.btn-danger:hover { border-color: transparent; filter: brightness(1.08); }
.btn-lg { height: 52px; padding: 0 24px; font-size: 1rem; border-radius: 14px; }
.btn-sm { height: 36px; padding: 0 13px; font-size: 0.86rem; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  color: var(--ink-2);
  transition: background 0.18s, color 0.18s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn .ic { width: 20px; height: 20px; }
.link { color: var(--brand-ink); font-weight: 600; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Chips / segmented ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  font-size: 0.86rem; font-weight: 600; color: var(--ink-2);
  transition: all 0.16s;
}
.chip:hover { border-color: var(--ink-2); color: var(--ink); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .count { font-weight: 500; opacity: 0.7; font-variant-numeric: tabular-nums; }
.chip:disabled { opacity: 0.45; pointer-events: none; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 9px; border-radius: 8px;
  background: var(--surface-3); color: var(--ink-2);
  font-size: 0.78rem; font-weight: 600; white-space: nowrap;
}
.tag .ic { width: 14px; height: 14px; }
.tag-exam { background: var(--exam-soft); color: var(--exam); }
.tag-good { background: var(--good-soft); color: var(--good); }
.tag-bad { background: var(--bad-soft); color: var(--bad); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.seg-control { display: inline-flex; padding: 4px; gap: 2px; border-radius: 12px; background: var(--surface-3); }
.seg-control button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: 9px;
  font-size: 0.88rem; font-weight: 600; color: var(--ink-2);
}
.seg-control button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  position: relative; width: 42px; height: 24px; flex: none;
  border-radius: 999px; background: var(--line-2);
  transition: background 0.2s;
}
.switch .track::after {
  content: ""; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.25s var(--spring);
}
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2.5px solid var(--brand); outline-offset: 2px; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
body[data-view="quiz"] .topbar { display: none; }
.topbar-inner { height: 100%; display: flex; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.06rem; letter-spacing: -0.02em; }
.brand-mark { width: 32px; height: 32px; }
.brand-name b { font-weight: 800; color: var(--brand); margin-left: 3px; }
.topnav { display: flex; gap: 4px; margin-left: 8px; }
.topnav a {
  height: 36px; padding: 0 12px; border-radius: 10px;
  display: inline-flex; align-items: center; gap: 7px;
  font-weight: 600; font-size: 0.9rem; color: var(--ink-2);
  transition: background 0.16s, color 0.16s;
}
.topnav a:hover { background: var(--surface-3); color: var(--ink); }
.topnav a.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.topnav .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--exam); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.search-trigger {
  display: inline-flex; align-items: center; gap: 10px;
  height: 40px; width: 250px; padding: 0 8px 0 12px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
  font-size: 0.9rem; text-align: left;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.search-trigger:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.search-trigger span { flex: 1; }
@media (max-width: 960px) {
  .search-trigger { width: 40px; padding: 0; justify-content: center; border-color: transparent; background: transparent; }
  .search-trigger span, .search-trigger kbd { display: none; }
}
@media (max-width: 720px) {
  .topnav { display: none; }
  .brand-name { font-size: 1rem; }
}

/* ---------- Views & animation ---------- */
#view { outline: none; min-height: calc(100vh - var(--topbar-h)); }
.view-enter { animation: view-in 0.45s var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.stagger > * { animation: rise 0.55s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: 0.05s; }
.stagger > *:nth-child(3) { animation-delay: 0.1s; }
.stagger > *:nth-child(4) { animation-delay: 0.15s; }
.stagger > *:nth-child(5) { animation-delay: 0.2s; }
.stagger > *:nth-child(6) { animation-delay: 0.25s; }

.section { padding-block: 56px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.section-head h2 { font-size: 1.6rem; font-weight: 800; }
.section-head p { color: var(--muted); margin-top: 4px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px 0 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 0.8rem; font-weight: 600; color: var(--ink-2);
  box-shadow: var(--shadow-sm);
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- Home: hero ---------- */
.hero { position: relative; overflow: hidden; padding: 72px 0 40px; }
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--ink) 14%, transparent) 1px, transparent 0);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 70% 30%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 70% 30%, #000 20%, transparent 75%);
  opacity: 0.6;
}
.hero::after {
  content: ""; position: absolute; width: 720px; height: 720px; right: -200px; top: -320px; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand) 22%, transparent), transparent 65%);
  filter: blur(10px);
}
.hero-inner { position: relative; z-index: 1; display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2.2rem, 4.4vw, 3.4rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.08; margin: 20px 0 18px; text-wrap: balance; }
.hero h1 .grad {
  background: linear-gradient(100deg, var(--brand) 10%, #e08a2c 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .lead { font-size: 1.12rem; color: var(--ink-2); max-width: 34em; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--line); }
.hero-stat b { display: block; font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.hero-stat span { font-size: 0.84rem; color: var(--muted); }
.hero-stat .ic { display: inline; width: 1em; height: 1em; vertical-align: -0.1em; color: var(--brand); }

.hero-visual { position: relative; height: 470px; }
.hv-card {
  position: absolute; background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--shadow-lg);
}
.hv-main { left: 6%; right: 2%; top: 30px; padding: 22px; transform: rotate(-2deg); animation: float 7s ease-in-out infinite; }
.hv-main .hv-meta { display: flex; gap: 8px; margin-bottom: 14px; }
.hv-q { font-weight: 700; font-size: 1.02rem; line-height: 1.4; margin-bottom: 16px; letter-spacing: -0.01em; }
.hv-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); margin-top: 8px; font-size: 0.86rem; color: var(--ink-2); }
.hv-opt i { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 700; font-size: 0.75rem; background: var(--surface-3); flex: none; }
.hv-opt.ok { border-color: var(--good-line); background: var(--good-soft); color: var(--ink); }
.hv-opt.ok i { background: var(--good); color: #fff; }
.hv-opt .ic { margin-left: auto; color: var(--good); }
.hv-score { right: -2%; bottom: 0; padding: 16px 18px; display: flex; align-items: center; gap: 14px; transform: rotate(3deg); animation: float 6s ease-in-out -2s infinite; }
.hv-score b { font-size: 1.4rem; font-weight: 800; display: block; line-height: 1; }
.hv-score span { font-size: 0.8rem; color: var(--muted); }
.hv-streak { left: 0; bottom: 30px; padding: 12px 16px; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 0.9rem; transform: rotate(-4deg); animation: float 8s ease-in-out -4s infinite; }
.hv-streak .ic { color: var(--brand); width: 22px; height: 22px; }
@keyframes float { 50% { translate: 0 -10px; } }
@media (max-width: 960px) {
  .hero { padding-top: 48px; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-visual { display: none; }
}

/* ---------- Home: exam cards ---------- */
.exam-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
@media (max-width: 400px) { .exam-grid { grid-template-columns: 1fr; } }
.exam-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-xl); overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.2s;
}
.exam-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--exam) 40%, var(--line)); }
.exam-cover {
  position: relative; height: 150px; padding: 22px 24px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--exam); color: #fff; overflow: hidden;
}
.exam-cover::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 85% 20%, rgba(255,255,255,0.28), transparent 45%),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.07) 0 2px, transparent 2px 14px);
}
.exam-cover::after {
  content: attr(data-code); position: absolute; right: -12px; top: -26px;
  font-size: 6rem; font-weight: 800; letter-spacing: -0.06em; line-height: 1;
  color: transparent; -webkit-text-stroke: 1.5px rgba(255,255,255,0.22);
  transition: transform 0.6s var(--ease);
}
.exam-card:hover .exam-cover::after { transform: translateX(-12px); }
.exam-level { position: relative; z-index: 1; align-self: flex-start; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.2; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,0.2); color: #fff; }
.exam-code { position: relative; z-index: 1; font-size: 2.1rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.exam-body { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.exam-body h3 { font-size: 1.22rem; font-weight: 700; }
.exam-body p { color: var(--ink-2); font-size: 0.93rem; }
.exam-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.exam-progress { margin-top: auto; display: grid; gap: 8px; }
.exam-progress-row { display: flex; justify-content: space-between; font-size: 0.84rem; color: var(--muted); }
.exam-progress-row b { color: var(--ink); font-weight: 700; }
.exam-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 4px; }
.exam-go { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--exam); }
.exam-go .ic { transition: transform 0.3s var(--ease); }
.exam-card:hover .exam-go .ic { transform: translateX(4px); }

.resume-list { display: grid; gap: 12px; }
.resume {
  display: flex; align-items: center; gap: 16px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); transition: border-color 0.2s, transform 0.25s var(--ease);
}
.resume:hover { border-color: var(--exam); transform: translateY(-2px); }
.resume-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--exam-soft); color: var(--exam); flex: none; }
.resume-icon .ic { width: 22px; height: 22px; }
.resume-body { flex: 1; min-width: 0; }
.resume-body b { display: block; font-weight: 700; }
.resume-body span { font-size: 0.86rem; color: var(--muted); }
.resume-bar { display: block; height: 5px; border-radius: 99px; background: var(--surface-3); margin-top: 8px; overflow: hidden; max-width: 360px; }
.resume-bar i { display: block; height: 100%; background: var(--exam); border-radius: 99px; }

.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 960px) { .features { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .features { grid-template-columns: 1fr; } }
.feature { padding: 22px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); }
.feature-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 14px; }
.feature h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.feature p { font-size: 0.9rem; color: var(--ink-2); }

.footer { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: 0.86rem; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.footer .brand { font-size: 0.95rem; color: var(--ink); }
.footer .brand-mark { width: 24px; height: 24px; }

/* ---------- Exam dashboard ---------- */
.exam-hero { position: relative; padding: 36px 0 32px; overflow: hidden; }
.exam-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(900px 340px at 12% -10%, color-mix(in srgb, var(--exam) 18%, transparent), transparent 70%),
    radial-gradient(600px 300px at 95% 0%, color-mix(in srgb, var(--exam) 10%, transparent), transparent 70%);
}
.exam-hero > .container { position: relative; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 0.86rem; color: var(--muted); margin-bottom: 22px; }
.crumbs a:hover { color: var(--ink); }
.crumbs .ic { width: 14px; height: 14px; }
.exam-hero-grid { display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: center; }
.exam-badge { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.84rem; color: var(--exam); background: var(--exam-soft); padding: 6px 12px; border-radius: 999px; letter-spacing: 0.02em; }
.exam-hero h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); font-weight: 800; letter-spacing: -0.035em; margin: 14px 0 10px; }
.exam-hero p.lead { color: var(--ink-2); max-width: 40em; font-size: 1.04rem; }
.exam-hero .exam-meta { margin-top: 16px; }
.exam-hero-ring { display: flex; align-items: center; gap: 22px; padding: 18px 22px; border-radius: var(--radius-lg); background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.ring-side { display: grid; gap: 8px; font-size: 0.88rem; min-width: 150px; }
.ring-side div { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); }
.ring-side b { color: var(--ink); font-variant-numeric: tabular-nums; }
@media (max-width: 820px) {
  .exam-hero-grid { grid-template-columns: 1fr; }
  .exam-hero-ring { justify-self: stretch; }
}
.resume-banners { display: grid; gap: 10px; margin-top: 22px; max-width: 640px; }

.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 8px 0 28px; }
@media (max-width: 1020px) { .modes { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .modes { grid-template-columns: 1fr; } }
.mode {
  position: relative; text-align: left;
  display: flex; flex-direction: column; gap: 10px;
  padding: 20px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.2s;
}
.mode:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--exam) 45%, var(--line)); }
.mode-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--exam-soft); color: var(--exam); }
.mode-icon .ic { width: 22px; height: 22px; }
.mode.featured { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.mode.featured .mode-icon { background: color-mix(in srgb, var(--bg) 14%, transparent); color: var(--bg); }
.mode.featured p { color: color-mix(in srgb, var(--bg) 72%, transparent); }
:root[data-theme="dark"] .mode.featured { background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 22%, var(--surface)), var(--surface) 70%); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); color: var(--ink); }
:root[data-theme="dark"] .mode.featured .mode-icon { background: var(--brand); color: var(--on-brand); }
:root[data-theme="dark"] .mode.featured p { color: var(--ink-2); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mode.featured { background: linear-gradient(160deg, color-mix(in srgb, var(--brand) 22%, var(--surface)), var(--surface) 70%); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); color: var(--ink); }
  :root:not([data-theme="light"]) .mode.featured .mode-icon { background: var(--brand); color: var(--on-brand); }
  :root:not([data-theme="light"]) .mode.featured p { color: var(--ink-2); }
}
.mode h3 { font-size: 1.05rem; font-weight: 700; }
.mode p { font-size: 0.88rem; color: var(--ink-2); }
.mode-badge { position: absolute; top: 18px; right: 18px; }
.mode .mode-go { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.88rem; padding-top: 4px; }

.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; padding-bottom: 56px; }
.panel { grid-column: span 6; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; min-width: 0; }
.panel.span-12 { grid-column: span 12; }
.panel.span-7 { grid-column: span 7; }
.panel.span-5 { grid-column: span 5; }
@media (max-width: 900px) { .panel, .panel.span-7, .panel.span-5 { grid-column: span 12; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-head h2 .ic { color: var(--muted); }
.panel-head p { font-size: 0.84rem; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.panel.span-5 .tiles { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.tile span { display: block; font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.tile b { display: block; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; margin-top: 2px; line-height: 1.2; }
.tile small { font-size: 0.8rem; color: var(--muted); font-weight: 500; }

/* segmented status bar */
.segbar { display: flex; gap: 2px; height: 14px; border-radius: 6px; overflow: hidden; background: var(--surface-3); }
.segbar.sm { height: 8px; border-radius: 4px; }
.segbar .seg { min-width: 4px; transition: flex-grow 0.8s var(--ease); }
.seg-mastered, .sw-mastered { background: var(--good); }
.seg-learning, .sw-learning { background: #eda100; }
.seg-wrong, .sw-wrong { background: var(--bad); }
.seg-new, .sw-new { background: var(--line-2); }
.legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 0.84rem; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* question map */
.qmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.qcell {
  position: relative; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--surface-3); color: var(--muted);
  border: 1px solid transparent;
  transition: transform 0.15s var(--ease), border-color 0.15s;
}
.qcell:hover { transform: translateY(-2px); border-color: var(--ink-2); }
.qcell.st-mastered { background: var(--good-soft); color: var(--good); }
.qcell.st-learning { background: var(--warn-soft); color: var(--warn); }
.qcell.st-wrong { background: var(--bad-soft); color: var(--bad); }
.qcell.is-flagged::after { content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--flag); box-shadow: 0 0 0 2px var(--surface); }
.qcell.is-hidden { opacity: 0.18; pointer-events: none; }

/* meters */
.meters { display: grid; gap: 16px; }
.meter-row { display: grid; gap: 7px; }
.meter-label { display: flex; justify-content: space-between; font-size: 0.88rem; }
.meter-label span { color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; }
.meter-label b { font-variant-numeric: tabular-nums; }
.meter-label small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--exam); transform-origin: left; animation: grow 0.9s var(--ease) both; }
@keyframes grow { from { transform: scaleX(0); } }

/* history table */
.htable { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-top: 14px; }
.htable th { text-align: left; font-weight: 600; color: var(--muted); font-size: 0.78rem; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.htable td { padding: 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.htable tr:last-child td { border-bottom: 0; }
.htable tbody tr { cursor: pointer; transition: background 0.15s; }
.htable tbody tr:hover { background: var(--surface-2); }
.htable .r { text-align: right; }
.table-wrap { overflow-x: auto; margin: 0 -10px; padding: 0 10px; }

/* ring */
.ring { position: relative; width: var(--size); height: var(--size); flex: none; }
.ring svg { width: 100%; height: 100%; }
.ring-track { stroke: var(--surface-3); }
.ring-value { stroke: var(--exam); animation: ring-in 1.2s var(--ease) both; }
.ring.good .ring-value { stroke: var(--good); }
.ring.bad .ring-value { stroke: var(--bad); }
@keyframes ring-in { from { stroke-dashoffset: var(--c); } }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-label b { font-size: calc(var(--size) * 0.24); font-weight: 800; letter-spacing: -0.04em; }
.ring-label span { font-size: max(11px, calc(var(--size) * 0.095)); color: var(--muted); font-weight: 600; margin-top: 3px; }

/* line chart */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; overflow: visible; }
.chart:focus-visible { outline-offset: 6px; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .pass-line { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 5; }
.chart .pass-label { fill: var(--muted); font-size: 11px; font-weight: 600; }
.chart .line { fill: none; stroke: var(--exam); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--exam); opacity: 0.08; }
.chart .pt { fill: var(--exam); stroke: var(--surface); stroke-width: 2; transition: r 0.15s; }
.chart .pt.is-active { r: 6.5; }
.chart .end-label { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart .cross { stroke: var(--line-2); stroke-width: 1; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 3;
  min-width: 150px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 0.82rem; line-height: 1.45;
  opacity: 0; transform: translate(-50%, calc(-100% - 14px)); transition: opacity 0.12s;
}
.chart-tip.show { opacity: 1; }
.chart-tip .t { color: var(--muted); font-size: 0.76rem; }
.chart-tip b { font-size: 1.05rem; }
.empty {
  display: grid; place-items: center; text-align: center; gap: 10px;
  padding: 36px 16px; color: var(--muted); font-size: 0.92rem;
  border: 1.5px dashed var(--line-2); border-radius: var(--radius);
}
.empty .ic { width: 28px; height: 28px; color: var(--line-2); }
.empty b { color: var(--ink); font-size: 1rem; }

.danger-zone { display: flex; justify-content: center; padding: 0 0 48px; }

/* ---------- Rich text (question/explanation HTML) ---------- */
.rich p + p { margin-top: 0.7em; }
.rich ul, .rich ol { margin: 0.4em 0; padding-left: 1.3em; }
.rich li + li { margin-top: 0.35em; }
.rich a { color: var(--brand-ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--brand) 40%, transparent); text-underline-offset: 3px; word-break: break-word; }
.rich a:hover { text-decoration-color: var(--brand); }
.rich b, .rich strong { font-weight: 700; }
.rich code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-3); padding: 0.1em 0.35em; border-radius: 5px; }
.note .nh {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--brand-ink); margin: 1.3em 0 0.5em; display: flex; align-items: center; gap: 8px;
}
.note .nh::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.note .nh:first-child { margin-top: 0; }
.note ul { list-style: none; padding-left: 0; }
.note li { position: relative; padding-left: 1.1em; }
.note li::before { content: ""; position: absolute; left: 0.15em; top: 0.68em; width: 5px; height: 5px; border-radius: 50%; background: var(--line-2); }
.note li > b.opt-ref { display: inline-grid; place-items: center; min-width: 1.55em; height: 1.55em; padding: 0 0.3em; margin-right: 0.25em; border-radius: 6px; background: var(--surface-3); font-size: 0.85em; }

/* ---------- Quiz ---------- */
.quiz { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
.quiz-top {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.quiz-top-inner { max-width: 1180px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 12px; height: 64px; }
.quiz-title { display: grid; line-height: 1.25; min-width: 0; }
.quiz-kicker { display: inline-flex; align-items: center; gap: 7px; font-size: 0.76rem; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiz-kicker .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--exam); flex: none; }
.quiz-title strong { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.quiz-top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.timer {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 13px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.95rem;
}
.timer .ic { width: 17px; height: 17px; color: var(--muted); }
.timer.warn { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }
.timer.danger { color: var(--bad); border-color: var(--bad-line); background: var(--bad-soft); animation: blink 1s steps(2) infinite; }
.timer.warn .ic, .timer.danger .ic { color: currentColor; }
@keyframes blink { 50% { opacity: 0.65; } }
.quiz-progress { height: 3px; background: transparent; }
.quiz-progress span { display: block; height: 100%; width: 0; background: var(--exam); transition: width 0.5s var(--ease); border-radius: 0 3px 3px 0; }

.quiz-layout { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 24px 120px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.quiz-main { min-width: 0; }
.quiz-side { position: sticky; top: 92px; display: grid; gap: 14px; }
@media (max-width: 1020px) {
  .quiz-layout { grid-template-columns: minmax(0, 1fr); padding-top: 20px; }
  .quiz-side { display: none; }
}
@media (max-width: 640px) {
  .quiz-top-inner { padding: 8px 12px; gap: 6px; }
  .quiz-layout { padding: 14px 12px 120px; }
}
.only-mobile { display: none; }
@media (max-width: 1020px) { .only-mobile { display: inline-grid; } .hide-mobile { display: none !important; } }

.qcard {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-xl); padding: 30px 32px 32px;
  box-shadow: var(--shadow-sm); outline: none;
}
@media (max-width: 640px) {
  .qcard { padding: 20px 16px 22px; border-radius: var(--radius-lg); }
  .q-text { font-size: 1.05rem; }
  .opt { gap: 10px; padding: 12px; min-height: 52px; font-size: 0.95rem; }
  .opt-key { width: 28px; height: 28px; font-size: 0.8rem; }
}
.qcard.anim-next { animation: slide-next 0.4s var(--ease) both; }
.qcard.anim-prev { animation: slide-prev 0.4s var(--ease) both; }
@keyframes slide-next { from { opacity: 0; transform: translateX(22px); } }
@keyframes slide-prev { from { opacity: 0; transform: translateX(-22px); } }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.q-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-num { font-weight: 800; font-size: 1.02rem; letter-spacing: -0.01em; margin-right: 4px; font-variant-numeric: tabular-nums; }
.q-num small { color: var(--muted); font-weight: 600; font-size: 0.85em; }
.q-id { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.flag-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px; border-radius: 10px;
  font-size: 0.84rem; font-weight: 600; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface);
  transition: all 0.16s;
}
.flag-btn .ic { width: 16px; height: 16px; }
.flag-btn:hover { color: var(--ink); border-color: var(--line-2); }
.flag-btn.on { color: var(--flag); border-color: var(--warn-line); background: var(--warn-soft); }
.flag-btn.on .ic { fill: currentColor; }
.q-text { font-size: 1.14rem; line-height: 1.68; font-weight: 500; letter-spacing: -0.005em; }
.q-hint { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 18px 0 14px; font-size: 0.86rem; font-weight: 600; color: var(--muted); }
.q-hint .ic { width: 16px; height: 16px; }
.q-counter { margin-left: auto; font-variant-numeric: tabular-nums; padding: 2px 9px; border-radius: 99px; background: var(--surface-3); color: var(--ink-2); }
.q-counter.full { background: var(--exam-soft); color: var(--exam); }
.q-counter.over { background: var(--warn-soft); color: var(--warn); }

/* options */
.opts { display: grid; gap: 10px; }
.opt {
  position: relative; width: 100%; text-align: left;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 14px 16px; min-height: 58px;
  border-radius: var(--radius); border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 0.99rem; line-height: 1.5; color: var(--ink);
  transition: border-color 0.16s, background 0.16s, transform 0.16s var(--ease), box-shadow 0.16s;
}
button.opt:hover:not([aria-disabled="true"]) { border-color: color-mix(in srgb, var(--exam) 55%, var(--line)); background: var(--surface-2); }
button.opt:active:not([aria-disabled="true"]) { transform: scale(0.995); }
.opt-key {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 50%; border: 1.5px solid var(--line-2);
  font-weight: 700; font-size: 0.86rem; color: var(--ink-2);
  transition: all 0.18s var(--ease);
}
.is-multi .opt-key { border-radius: 9px; }
.opt-text { min-width: 0; overflow-wrap: anywhere; }
.opt-mark { width: 22px; display: grid; place-items: center; }
.opt-mark .ic { width: 20px; height: 20px; stroke-width: 2.5; }
.opt-orig { font-size: 0.72rem; font-weight: 700; color: var(--muted); background: var(--surface-3); padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.opt .opt-orig + .opt-mark { margin-left: -6px; }
.opt:has(.opt-orig) { grid-template-columns: auto 1fr auto auto; }
/* Selection is neutral ink so it never reads as "correct" (green) or "wrong" (red). */
.opt.is-selected { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 9%, transparent); }
.opt.is-selected .opt-key { background: var(--ink); border-color: var(--ink); color: var(--bg); transform: scale(1.06); }
.opt.is-correct { border-color: var(--good); background: var(--good-soft); box-shadow: none; }
.opt.is-correct .opt-key { background: var(--good); border-color: var(--good); color: #fff; }
.opt.is-correct .opt-mark { color: var(--good); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: none; }
.opt.is-wrong .opt-key { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.is-wrong .opt-mark { color: var(--bad); }
.opt.is-missed { border-color: var(--good); border-style: dashed; background: transparent; }
.opt.is-missed .opt-key { border-color: var(--good); color: var(--good); }
.opt.is-missed .opt-mark { color: var(--good); }
.opt.is-answer { border-color: var(--good-line); background: var(--good-soft); }
.opt.is-answer .opt-key { background: var(--good); border-color: var(--good); color: #fff; }
.opt.is-answer .opt-mark { color: var(--good); }
.opt.is-dim { opacity: 0.6; }
:root[data-theme="dark"] .opt.is-selected .opt-key,
:root[data-theme="dark"] .opt.is-correct .opt-key,
:root[data-theme="dark"] .opt.is-wrong .opt-key,
:root[data-theme="dark"] .opt.is-answer .opt-key { color: #0f0f11; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .opt.is-selected .opt-key,
  :root:not([data-theme="light"]) .opt.is-correct .opt-key,
  :root:not([data-theme="light"]) .opt.is-wrong .opt-key,
  :root:not([data-theme="light"]) .opt.is-answer .opt-key { color: #0f0f11; }
}
.just-checked .opt.is-correct .opt-key { animation: pop 0.45s var(--spring); }
.just-checked .opt.is-wrong { animation: shake 0.42s var(--ease); }
@keyframes pop { 40% { transform: scale(1.25); } }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

/* matching */
.match { display: grid; gap: 10px; }
.mrow {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 12px 12px 12px 16px; border-radius: var(--radius);
  border: 1.5px solid var(--line); background: var(--surface);
  transition: border-color 0.16s, background 0.16s;
}
.mrow.is-correct { border-color: var(--good-line); background: var(--good-soft); }
.mrow.is-wrong { border-color: var(--bad-line); background: var(--bad-soft); }
.mrow-text { display: flex; gap: 12px; align-items: baseline; font-size: 0.97rem; line-height: 1.5; }
.mrow-n { flex: none; width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 7px; background: var(--surface-3); font-size: 0.76rem; font-weight: 700; color: var(--ink-2); transform: translateY(-1px); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 11px; background: var(--surface-3); justify-content: flex-end; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 34px; padding: 4px 12px; border-radius: 8px;
  font-size: 0.83rem; font-weight: 600; color: var(--ink-2); text-align: center; line-height: 1.25;
  transition: all 0.15s;
}
.seg-btn .ic { width: 15px; height: 15px; stroke-width: 2.6; }
button.seg-btn:hover:not([aria-disabled="true"]) { background: var(--surface); color: var(--ink); }
.seg-btn.is-selected { background: var(--ink); color: var(--bg); box-shadow: var(--shadow-sm); }
.seg-btn.is-correct { background: var(--good); color: #fff; }
.seg-btn.is-wrong { background: var(--bad); color: #fff; }
.seg-btn.is-dim { opacity: 0.55; }
:root[data-theme="dark"] .seg-btn.is-selected, :root[data-theme="dark"] .seg-btn.is-correct, :root[data-theme="dark"] .seg-btn.is-wrong { color: #0f0f11; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .seg-btn.is-selected,
  :root:not([data-theme="light"]) .seg-btn.is-correct,
  :root:not([data-theme="light"]) .seg-btn.is-wrong { color: #0f0f11; }
}
.match.is-stacked .mrow { grid-template-columns: 1fr; gap: 10px; }
.match.is-stacked .seg { justify-content: flex-start; }
.match.is-stacked .seg-btn { flex: 1 1 auto; justify-content: center; }
@media (max-width: 760px) {
  .mrow { grid-template-columns: 1fr; gap: 10px; padding: 12px; }
  .seg { justify-content: stretch; }
  .seg-btn { flex: 1; justify-content: center; }
}

/* feedback & explanation */
.feedback {
  display: flex; align-items: center; gap: 14px;
  margin-top: 20px; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid; animation: rise 0.4s var(--ease) both;
}
.feedback.ok { background: var(--good-soft); border-color: var(--good-line); }
.feedback.bad { background: var(--bad-soft); border-color: var(--bad-line); }
.fb-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; }
.feedback.ok .fb-icon { background: var(--good); }
.feedback.bad .fb-icon { background: var(--bad); }
:root[data-theme="dark"] .fb-icon { color: #0f0f11; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fb-icon { color: #0f0f11; } }
.fb-icon .ic { width: 20px; height: 20px; stroke-width: 2.8; }
.fb-body { display: grid; gap: 1px; font-size: 0.92rem; }
.fb-body strong { font-size: 1.02rem; }
.feedback.ok strong { color: var(--good); }
.feedback.bad strong { color: var(--bad); }
.fb-body .muted { font-size: 0.85rem; }

.explain {
  margin-top: 14px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface-2); overflow: hidden;
  animation: rise 0.45s var(--ease) 0.05s both;
}
.explain > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; font-weight: 700; font-size: 0.95rem;
}
.explain > summary::-webkit-details-marker { display: none; }
.explain > summary > .ic:first-child { color: var(--brand); }
.explain > summary em { font-style: normal; font-weight: 500; font-size: 0.82rem; color: var(--muted); }
.explain .chev { margin-left: auto; color: var(--muted); transition: transform 0.25s var(--ease); display: grid; }
.explain[open] .chev { transform: rotate(180deg); }
.explain .note { padding: 2px 18px 18px; font-size: 0.95rem; line-height: 1.65; color: var(--ink-2); }
.explain .note b, .explain .note strong { color: var(--ink); }

/* quiz footer */
.quiz-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.quiz-foot-inner { max-width: 1180px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 10px; }
.quiz-foot-inner .spacer { flex: 1; }
.quiz-foot-inner .foot-main { margin-left: auto; display: flex; gap: 10px; }
@media (min-width: 1021px) { .quiz-foot-inner { padding-right: calc(24px + 300px + 28px); } }
@media (max-width: 640px) {
  .quiz-foot-inner { padding: 10px 12px; gap: 8px; }
  .quiz-foot-inner .btn { padding: 0 14px; }
  .quiz-foot-inner .btn .lbl-long { display: none; }
  .quiz-foot-inner kbd { display: none; }
}
@media (max-width: 1020px) { .quiz-foot-inner kbd { display: none; } }

/* quiz side */
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
.side-card h3 { font-size: 0.86rem; font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.side-card h3 span { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.side-stats { display: flex; align-items: center; gap: 16px; }
.side-nums { display: grid; gap: 6px; font-size: 0.86rem; flex: 1; }
.side-nums div { display: flex; justify-content: space-between; color: var(--muted); }
.side-nums b { color: var(--ink); font-variant-numeric: tabular-nums; }
.side-nums .ok b { color: var(--good); }
.side-nums .bad b { color: var(--bad); }
.side-tip { display: grid; gap: 7px; font-size: 0.8rem; color: var(--muted); }
.side-tip div { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.side-tip span:last-child { display: flex; gap: 3px; }
.side-tip kbd { font-size: 0.7rem; }
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 5px; max-height: 340px; overflow: auto; padding: 2px; margin: -2px; scrollbar-width: thin; }
.navgrid.tall { max-height: none; }
.ncell {
  position: relative; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  font-size: 0.76rem; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--surface-3); color: var(--muted);
  border: 1.5px solid transparent;
  transition: all 0.15s;
}
.ncell:hover { border-color: var(--line-2); color: var(--ink); }
.ncell.is-answered { background: color-mix(in srgb, var(--ink) 14%, transparent); color: var(--ink); }
.ncell.is-correct { background: var(--good-soft); color: var(--good); }
.ncell.is-wrong { background: var(--bad-soft); color: var(--bad); }
.ncell.is-current { border-color: var(--ink); color: var(--ink); }
.ncell.is-flagged::after { content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--flag); }
.nav-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; font-size: 0.76rem; color: var(--muted); }
.nav-legend span { display: inline-flex; align-items: center; gap: 5px; }
.nav-legend i { width: 9px; height: 9px; border-radius: 3px; background: var(--surface-3); }
.nav-legend i.a { background: color-mix(in srgb, var(--ink) 40%, transparent); }
.nav-legend i.c { background: var(--good); }
.nav-legend i.w { background: var(--bad); }
.nav-legend i.f { background: var(--flag); border-radius: 50%; }
.side-timer { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.side-timer.warn { color: var(--warn); }
.side-timer.danger { color: var(--bad); }

/* ---------- Results ---------- */
.result-hero { padding-block: 36px 8px; }
.result-card {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: auto 1fr; gap: 32px; align-items: center;
  padding: 30px; border-radius: var(--radius-xl);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.result-card::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(500px 260px at 0% 0%, color-mix(in srgb, var(--exam) 14%, transparent), transparent 70%); }
.result-card.pass::before { background: radial-gradient(520px 280px at 0% 0%, color-mix(in srgb, var(--good) 16%, transparent), transparent 70%); }
.result-card.fail::before { background: radial-gradient(520px 280px at 0% 0%, color-mix(in srgb, var(--bad) 12%, transparent), transparent 70%); }
.result-card > * { position: relative; }
.result-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.result-title h1 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); font-weight: 800; letter-spacing: -0.03em; }
.verdict { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; font-weight: 800; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; }
.verdict .ic { width: 16px; height: 16px; stroke-width: 2.6; }
.verdict.pass { background: var(--good-soft); color: var(--good); }
.verdict.fail { background: var(--bad-soft); color: var(--bad); }
.result-sub { color: var(--ink-2); margin-top: 6px; }
.result-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
@media (max-width: 760px) {
  .result-card { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 24px 18px; }
  .result-title { justify-content: center; }
  .result-tiles { grid-template-columns: repeat(2, 1fr); width: 100%; text-align: left; }
}
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
@media (max-width: 760px) { .result-actions { justify-content: center; } }
.result-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; padding: 24px 0 64px; align-items: start; }
@media (max-width: 960px) { .result-grid { grid-template-columns: 1fr; } }
.result-grid .panel { grid-column: auto; }
.review-tabs { margin-bottom: 16px; }
.review-list { display: grid; gap: 10px; }
.ritem { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.ritem > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; transition: background 0.15s;
}
.ritem > summary::-webkit-details-marker { display: none; }
.ritem > summary:hover { background: var(--surface-2); }
.ritem-status { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.ritem-status .ic { width: 16px; height: 16px; stroke-width: 2.8; }
.ritem-status.ok { background: var(--good-soft); color: var(--good); }
.ritem-status.bad { background: var(--bad-soft); color: var(--bad); }
.ritem-status.skip { background: var(--surface-3); color: var(--muted); }
.ritem-n { font-weight: 700; font-variant-numeric: tabular-nums; flex: none; min-width: 3.2em; }
.ritem-q { flex: 1; min-width: 0; color: var(--ink-2); font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ritem .chev { color: var(--muted); transition: transform 0.25s var(--ease); display: grid; }
.ritem[open] .chev { transform: rotate(180deg); }
.ritem-body { padding: 4px 18px 20px; border-top: 1px solid var(--line); }
.ritem-body .q-text { font-size: 1.02rem; margin: 16px 0 14px; }
.ritem-body .opt { min-height: 50px; padding: 11px 14px; font-size: 0.94rem; }
.ritem-body .opt-key { width: 28px; height: 28px; font-size: 0.8rem; }
.your { font-size: 0.86rem; color: var(--muted); margin-top: 12px; }
.your b { color: var(--ink); }

/* ---------- Browse ---------- */
.browse-head { padding-block: 32px 8px; }
.browse-head h1 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); font-weight: 800; letter-spacing: -0.03em; margin-top: 8px; }
.browse-bar {
  position: sticky; top: var(--topbar-h); z-index: 20;
  padding: 14px 0; margin-bottom: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.browse-bar-inner { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.search-field {
  flex: 1 1 280px; display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 14px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--line-2);
  transition: border-color 0.16s, box-shadow 0.16s;
}
.search-field:focus-within { border-color: var(--exam); box-shadow: 0 0 0 4px color-mix(in srgb, var(--exam) 14%, transparent); }
.search-field .ic { color: var(--muted); }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 0.98rem; }
.search-field input::placeholder { color: var(--muted); }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-row select {
  height: 38px; padding: 0 34px 0 12px; border-radius: 11px;
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: 0.88rem; font-weight: 600; color: var(--ink-2);
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d7a84' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.browse-count { font-size: 0.86rem; color: var(--muted); margin: 6px 0 14px; }
.browse-list { display: grid; gap: 14px; padding-bottom: 40px; }
.bcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px 24px; scroll-margin-top: 160px; }
@media (max-width: 640px) { .bcard { padding: 18px 16px; } }
.bcard.is-focus { border-color: var(--exam); box-shadow: 0 0 0 4px color-mix(in srgb, var(--exam) 14%, transparent); }
.bcard-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.bcard-head .spacer { flex: 1; }
.bcard .q-text { font-size: 1.02rem; margin-bottom: 14px; }
.bcard .opts { gap: 8px; }
.bcard .opt { min-height: 48px; padding: 10px 14px; font-size: 0.94rem; border-width: 1px; }
.bcard .opt-key { width: 28px; height: 28px; font-size: 0.8rem; }
.bcard .explain { margin-top: 12px; animation: none; }
.bcard .reveal-row { margin-top: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); display: inline-block; }
.status-dot.st-mastered { background: var(--good); }
.status-dot.st-learning { background: #eda100; }
.status-dot.st-wrong { background: var(--bad); }
.sentinel { height: 1px; }

/* ---------- Modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--overlay); opacity: 0; transition: opacity 0.22s; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal {
  position: relative; width: 100%; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px);
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(12px) scale(0.98);
  transition: opacity 0.22s var(--ease), transform 0.3s var(--ease);
  outline: none;
}
.modal-sm { max-width: 440px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 720px; }
.modal-wrap.in .modal-backdrop { opacity: 1; }
.modal-wrap.in .modal { opacity: 1; transform: none; }
.modal-wrap.out .modal-backdrop { opacity: 0; }
.modal-wrap.out .modal { opacity: 0; transform: translateY(8px) scale(0.98); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 22px 6px 24px; }
.modal-head h2 { font-size: 1.2rem; font-weight: 800; }
.modal-head p { color: var(--muted); font-size: 0.88rem; margin-top: 3px; }
.modal-head .icon-btn { margin: -6px -6px 0 0; }
.modal-body { padding: 14px 24px 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .grow { flex: 1; }
.confirm-msg { color: var(--ink-2); }
@media (max-width: 640px) {
  .modal-wrap { place-items: end stretch; padding: 0; }
  .modal { max-width: none; border-radius: 24px 24px 0 0; max-height: 92vh; max-height: 92dvh; transform: translateY(40px); padding-bottom: env(safe-area-inset-bottom); }
  .modal-wrap.in .modal { transform: none; }
  .modal-wrap.out .modal { transform: translateY(40px); }
  .modal-foot .btn { flex: 1; }
}

.field { display: grid; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field-label { font-weight: 700; font-size: 0.92rem; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.field-label small { color: var(--muted); font-weight: 500; font-size: 0.82rem; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.field-row:last-child { border-bottom: 0; }
.field-row .txt b { display: block; font-weight: 600; font-size: 0.94rem; }
.field-row .txt span { display: block; font-size: 0.83rem; color: var(--muted); }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--brand); }
.range-row output { min-width: 3.2em; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.num-input { width: 86px; height: 34px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; }
.settings-group { margin-bottom: 8px; }
.settings-group h3 { font-size: 0.74rem; font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); margin: 14px 0 2px; }
.note-box { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--surface-3); font-size: 0.86rem; color: var(--ink-2); margin-top: 12px; }
.note-box .ic { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--muted); }
.shortcut-list { display: grid; gap: 2px; }
.shortcut-list div { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.shortcut-list div:last-child { border-bottom: 0; }
.shortcut-list span:last-child { display: flex; gap: 4px; }

/* ---------- Command palette ---------- */
.palette .modal-body { padding: 0; }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.palette-input .ic { color: var(--muted); width: 22px; height: 22px; }
.palette-input input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 1.08rem; min-width: 0; }
.palette-input input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.palette-results { max-height: min(60vh, 520px); overflow: auto; padding: 8px; }
.palette-item {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: start;
  width: 100%; text-align: left; padding: 12px; border-radius: 12px;
}
.palette-item.active, .palette-item:hover { background: var(--surface-3); }
.palette-item .tag { grid-row: span 2; }
.palette-item .pi-text { font-size: 0.92rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.palette-item .pi-meta { font-size: 0.78rem; color: var(--muted); }
.palette-foot { display: flex; gap: 16px; padding: 10px 20px; border-top: 1px solid var(--line); font-size: 0.78rem; color: var(--muted); flex-wrap: wrap; }
.palette-empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 0.92rem; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
body[data-view="quiz"] #toasts { bottom: 96px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg);
  font-size: 0.9rem; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px) scale(0.98);
  transition: opacity 0.25s var(--ease), transform 0.35s var(--ease);
}
.toast.in { opacity: 1; transform: none; }
.toast .ic { width: 18px; height: 18px; }
.toast-success .ic { color: var(--good); }
.toast-error .ic, .toast-warn .ic { color: var(--warn); }

/* ---------- Loading / error ---------- */
.loading { display: grid; place-items: center; gap: 16px; padding: 120px 20px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { max-width: 460px; margin: 80px auto; text-align: center; display: grid; gap: 14px; justify-items: center; padding: 0 16px; }
.error-state .ic { width: 40px; height: 40px; color: var(--bad); }
.error-state h2 { font-size: 1.3rem; }
.error-state p { color: var(--ink-2); }

.confetti { position: fixed; inset: 0; z-index: 90; pointer-events: none; width: 100vw; height: 100vh; }

/* ---------- Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .quiz-foot, .quiz-side, .browse-bar, .footer, #toasts { display: none !important; }
  body { background: #fff; }
  .bcard, .ritem { break-inside: avoid; }
}
