:root {
  --bg: #0c0c0f;
  --bg-warm: #100f0d;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.07);
  --surface-active: rgba(255,255,255,0.10);
  --glass: rgba(20,19,17,0.75);
  --glass-border: rgba(255,255,255,0.08);
  --text: #e8e4de;
  --text-bright: #faf8f5;
  --muted: rgba(232,228,222,0.45);
  --amber: #e5a349;
  --amber-dim: rgba(229,163,73,0.15);
  --good: #5fd068;
  --good-bg: rgba(95,208,104,0.12);
  --good-dim: rgba(95,208,104,0.08);
  --bad: #f06449;
  --bad-bg: rgba(240,100,73,0.12);
  --warn: #f0b449;
  --border: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 2px 8px rgba(8,6,3,0.45), 0 0 1px rgba(255,255,255,0.05) inset;
  --shadow-lg: 0 8px 32px rgba(8,6,3,0.5), 0 0 1px rgba(255,255,255,0.08) inset;
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Outfit', 'Noto Sans SC', sans-serif;
  --font-zh: 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Depth & Light: amber treated as a light source */
  --amber-glow: rgba(229,163,73,0.45);
  --amber-glow-soft: rgba(229,163,73,0.18);
  --good-glow: rgba(95,208,104,0.4);
  --bad-glow: rgba(240,100,73,0.4);
  --ring-track: rgba(255,255,255,0.06);
  --elev-1: 0 2px 8px rgba(8,6,3,0.45), 0 1px 0 rgba(255,255,255,0.05) inset;
  --elev-2: 0 12px 32px rgba(8,6,3,0.5), 0 1px 0 rgba(255,255,255,0.06) inset;
  /* reusable gradient-border ring mask (mask-composite: exclude) */
  --ring-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  font-size: clamp(15px, 0.45vw + 13.5px, 20px);
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(229,163,73,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(229,163,73,0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: -50%;
  /* Two warm-amber ambient blooms — both on-brand (audit: removed the AI-purple
     second radial and the perpetual blob-float loop). */
  background:
    radial-gradient(circle at 30% 40%, rgba(229,163,73,0.03) 0%, transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(229,163,73,0.022) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.noise-overlay {
  position: fixed;
  inset: 0;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
  pointer-events: none;
  z-index: 1;
}

.app-shell {
  position: relative;
  z-index: 2;
  max-width: min(860px, 90vw);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(12,12,15,0.94);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  /* Opaque enough to fully occlude scrolled content under the sticky bar
     (audit: 0.82 let the quiz row bleed through). */
  box-shadow: 0 6px 20px -10px rgba(8,6,3,0.5);
}

.header-left { display: flex; align-items: center; }
.header-right { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }

.logo-btn {
  display: flex;
  align-items: baseline;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: none;
}
.logo-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--amber);
  letter-spacing: -0.5px;
}
.logo-num {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--muted);
  margin-left: 1px;
}

.btn-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s var(--ease-out);
}
.btn-nav:hover { background: var(--surface-hover); border-color: var(--border-hover); }
.btn-nav svg { opacity: 0.6; }
.btn-nav:hover svg { opacity: 0.85; }

/* Icon-only nav button (theme toggle) */
.btn-icon { padding: 0.5rem; min-width: 36px; justify-content: center; }
.btn-icon svg { transition: transform 0.4s var(--ease-spring), opacity 0.18s; }
.btn-icon:hover svg { transform: rotate(18deg); }
/* Show the icon for the CURRENT theme: moon in dark, sun in light. */
.icon-sun { display: none; }
.icon-moon { display: block; }
html[data-theme="light"] .icon-sun { display: block; }
html[data-theme="light"] .icon-moon { display: none; }

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.lang-btn {
  min-width: 38px;
  padding: 0.38rem 0.48rem;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1;
  transition: background 0.18s var(--ease-out), color 0.18s var(--ease-out), box-shadow 0.18s var(--ease-out);
}

.lang-btn:hover { color: var(--text); background: var(--surface-hover); }
.lang-btn.active {
  background: var(--amber-dim);
  color: var(--amber);
  box-shadow: 0 0 0 1px rgba(229,163,73,0.25);
}

html[data-lang-mode="en"] .lang-zh:not(.lang-fallback),
html[data-lang-mode="zh"] .lang-en:not(.lang-fallback) {
  display: none !important;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bad);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  margin-left: 2px;
  animation: badge-pop 0.35s var(--ease-spring);
}
@keyframes badge-pop { from { transform: scale(0); } to { transform: scale(1); } }
.hidden { display: none !important; }

/* Visually hidden but available to assistive tech (live-region status). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* === Focus visibility (keyboard) === */
:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
/* Custom and icon controls that have no/!weak native ring */
.mode-card:focus-visible,
.option-item:focus-visible,
.btn-nav:focus-visible,
.lang-btn:focus-visible,
.quiz-back:focus-visible,
.btn-small:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.quiz-reset:focus-visible,
.yn-btn:focus-visible,
.logo-btn:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}
/* #main is programmatically focused on each view swap; don't show a ring there. */
#main:focus { outline: none; }

/* === Main === */
main {
  flex: 1;
  padding: 24px 20px 48px;
}

/* === Animations === */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes shimmer {
  from { background-position: -200% 0; }
  to { background-position: 200% 0; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-4px); }
}
@keyframes breathe {
  0% { box-shadow: 0 0 0 1px var(--good), inset 3px 0 0 var(--good); }
  50% { box-shadow: 0 0 0 1px var(--good), 0 0 15px 0 var(--good-glow), inset 3px 0 0 var(--good); }
  100% { box-shadow: 0 0 0 1px var(--good), inset 3px 0 0 var(--good); }
}

/* === Cards === */
.card {
  background: radial-gradient(130% 90% at 50% -5%, rgba(255,255,255,0.045), transparent 50%), var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  position: relative;
  box-shadow: var(--shadow-lg), 0 1px 0 rgba(255,255,255,0.05) inset;
  animation: scale-in 0.4s var(--ease-out) both;
}
/* Gradient-border ring — amber catching light on the top edge.
   Excludes .home-progress / .empty-state which define their own treatment. */
.card:not(.home-progress):not(.empty-state)::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(155deg, rgba(229,163,73,0.28), rgba(255,255,255,0.06) 30%, transparent 65%);
  -webkit-mask: var(--ring-mask);
  mask: var(--ring-mask);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* === Home === */
.home-progress {
  text-align: center;
  margin-bottom: 8px;
  position: relative;
  isolation: isolate;
  padding: 36px 28px 32px;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(229,163,73,0.16) 0%, transparent 55%),
    var(--glass);
  box-shadow:
    var(--shadow-lg),
    0 0 60px -12px rgba(229,163,73,0.25),
    0 1px 0 rgba(255,255,255,0.06) inset;
}
.home-progress::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  pointer-events: none;
  z-index: -1;
  background: linear-gradient(160deg, rgba(229,163,73,0.55), rgba(255,255,255,0.06) 35%, var(--glass-border) 70%);
  -webkit-mask: var(--ring-mask);
  mask: var(--ring-mask);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.home-progress::after {
  content: '';
  position: absolute;
  left: 50%; top: -40px;
  width: 320px; height: 200px;
  transform: translateX(-50%);
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(circle, var(--amber) 0%, transparent 60%);
  opacity: 0.18;
  filter: blur(40px);
  /* One-shot bloom-in, then settles (audit: was a 9s perpetual drift loop). */
  animation: hero-spotlight 1.2s var(--ease-out) 1 both;
}
@keyframes hero-spotlight {
  from { transform: translateX(-50%) scale(0.92); opacity: 0; }
  to   { transform: translateX(-50%) scale(1); opacity: 0.18; }
}

.home-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  text-shadow: 0 0 24px var(--amber-glow-soft);
}
.home-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.progress-circle-wrap {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 16px auto 20px;
}
.progress-circle-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.progress-bg {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 8;
  box-shadow: 0 1px 2px rgba(0,0,0,0.5) inset;
}
.progress-value {
  fill: none;
  stroke: var(--amber);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s var(--ease-spring);
  filter: drop-shadow(0 0 12px var(--amber-glow));
}
.progress-circle-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-bright);
  text-shadow: 0 0 12px var(--amber-glow-soft);
}

.progress-text {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
}
.score-text {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}
.score-text .correct-num { color: var(--good); font-weight: 600; }
.score-text .wrong-num { color: var(--bad); font-weight: 600; }

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
}

.mode-card {
  position: relative;
  background:
    radial-gradient(140% 100% at 50% 0%, rgba(255,255,255,0.05), transparent 60%),
    var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  overflow: hidden;
  box-shadow: var(--elev-1);
  animation: fade-up 0.5s var(--ease-out) both;
  /* Add CSS variables to define unique theme per mode-card */
  --card-glow: var(--amber-glow);
  --card-dim: var(--amber-dim);
  --card-border: rgba(229, 163, 73, 0.3);
}

/* Single-accent lock: every mode card uses the brand amber, differentiated by
   icon shape + label. Only "wrong" keeps a semantic red (matches the --bad
   error state). Audit: removed green/purple/blue per-mode --amber overrides
   that diluted the amber brand and shipped a banned AI-purple. */
.mode-card[data-mode="wrong"] {
  --card-glow: rgba(240, 100, 73, 0.45);
  --card-dim: rgba(240, 100, 73, 0.15);
  --card-border: rgba(240, 100, 73, 0.3);
  --amber: #f06449;
}

.mode-card:nth-child(1) { animation-delay: 0.05s; }
.mode-card:nth-child(2) { animation-delay: 0.1s; }
.mode-card:nth-child(3) { animation-delay: 0.15s; }
.mode-card:nth-child(4) { animation-delay: 0.2s; }

.mode-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.25s;
  background: radial-gradient(circle at 50% 0%, var(--card-dim), transparent 70%);
}
/* gradient-border ring that lights up on hover */
.mode-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(150deg, rgba(255,255,255,0.10), transparent 50%);
  -webkit-mask: var(--ring-mask);
  mask: var(--ring-mask);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  transition: background 0.25s var(--ease-out);
}
.mode-card:hover {
  border-color: var(--card-border);
  transform: translateY(-2px);
  box-shadow: var(--elev-2), 0 0 0 1px var(--card-border), 0 0 32px -8px var(--card-glow);
}
.mode-card:hover::before { opacity: 1; }
.mode-card:hover::after { background: linear-gradient(150deg, var(--card-glow), rgba(255,255,255,0.06) 50%); }
.mode-card:active { transform: translateY(0); }

.mode-icon {
  width: 48px;
  height: 48px;
  padding: 9px;
  margin-bottom: 12px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  z-index: 1;
  color: var(--amber);
  border-radius: var(--radius-sm);
  background: var(--amber-dim);
  box-shadow: 0 0 0 1px rgba(229,163,73,0.2) inset, 0 4px 12px -4px rgba(229,163,73,0.3);
  transition: box-shadow 0.25s var(--ease-out), transform 0.25s var(--ease-out);
}
.mode-card:hover .mode-icon {
  box-shadow: 0 0 0 1px rgba(229,163,73,0.4) inset, 0 6px 18px -4px var(--amber-glow);
  transform: translateY(-1px);
}
.mode-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}
.mode-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-bright);
  position: relative;
  z-index: 1;
}
.mode-count {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
  position: relative;
  z-index: 1;
}

/* === Quiz === */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  animation: fade-in 0.3s var(--ease-out);
  gap: 12px;
}
.quiz-back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--amber);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  padding: 6px 2px;
  transition: opacity 0.15s;
}
.quiz-back:hover { opacity: 0.8; }
.quiz-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.quiz-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid rgba(240,180,73,0.24);
  border-radius: var(--radius-xs);
  background: rgba(240,180,73,0.08);
  color: var(--warn);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s var(--ease-out);
}
.quiz-reset:hover {
  background: rgba(240,180,73,0.14);
  border-color: rgba(240,180,73,0.42);
}
.quiz-progress {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}

.q-type-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  background: linear-gradient(135deg, var(--amber-dim), rgba(229,163,73,0.05));
  color: var(--amber);
  border: 1px solid rgba(229,163,73,0.2);
  box-shadow: 0 0 0 1px rgba(229,163,73,0.25) inset, 0 0 16px -6px var(--amber-glow);
  margin-bottom: 16px;
  letter-spacing: 0.3px;
}

.q-prompt { margin-bottom: 24px; }
.q-instruction {
  margin-bottom: 12px;
}
.q-instruction-en,
.q-instruction-zh {
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.55;
  color: var(--muted);
}
.q-instruction-zh {
  font-family: var(--font-zh);
  margin-top: 4px;
}
.q-prompt-en {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--text-bright);
  margin-bottom: 10px;
}
.q-prompt-zh {
  font-family: var(--font-zh);
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.7;
}

.dropdown-answer-wrap {
  display: inline-flex;
  max-width: 100%;
  margin: 0 5px;
  vertical-align: baseline;
}
.dropdown-answer {
  width: min(22rem, 100%);
  max-width: 100%;
  padding: 0.42rem 2rem 0.42rem 0.7rem;
  border: 1px solid rgba(229,163,73,0.38);
  border-radius: var(--radius-xs);
  background: rgba(229,163,73,0.08);
  color: var(--text-bright);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23e5a349' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.dropdown-answer:focus {
  border-color: var(--amber);
  outline: none;
  box-shadow: 0 0 0 1px var(--amber), 0 0 18px rgba(229,163,73,0.12);
}
.dropdown-answer:disabled {
  cursor: default;
  opacity: 0.95;
}
.dropdown-answer option {
  background: #1a1a1d;
  color: var(--text);
}
.dropdown-token {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border: 1px solid rgba(229,163,73,0.24);
  border-radius: var(--radius-xs);
  background: rgba(229,163,73,0.06);
  color: var(--amber);
  font-family: var(--font-body);
  font-weight: 600;
  white-space: nowrap;
}
.dropdown-answer-wrap.correct .dropdown-answer {
  border-color: var(--good);
  background-color: var(--good-bg);
  box-shadow: 0 0 0 1px var(--good);
}
.dropdown-answer-wrap.wrong .dropdown-answer {
  border-color: var(--bad);
  background-color: var(--bad-bg);
  box-shadow: 0 0 0 1px var(--bad);
}
html[data-lang-mode="bilingual"] .dropdown-answer-wrap-zh {
  display: none;
}
html[data-lang-mode="zh"] .dropdown-token-zh {
  display: none;
}

/* === Options (single/multi) === */
.options-list { display: flex; flex-direction: column; gap: 10px; }

.option-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  user-select: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--surface);
  animation: fade-up 0.35s var(--ease-out) both;
}
.option-item:nth-child(1) { animation-delay: 0.05s; }
.option-item:nth-child(2) { animation-delay: 0.08s; }
.option-item:nth-child(3) { animation-delay: 0.11s; }
.option-item:nth-child(4) { animation-delay: 0.14s; }
.option-item:nth-child(5) { animation-delay: 0.17s; }

.option-item:hover {
  border-color: rgba(229,163,73,0.35);
  background: rgba(229,163,73,0.06);
  box-shadow: 0 0 16px -4px rgba(229,163,73,0.25), inset 2px 0 0 rgba(229,163,73,0.4);
}
.option-item.selected {
  border-color: var(--amber);
  background: var(--amber-dim);
  box-shadow: 0 0 0 1px var(--amber), 0 0 20px -4px rgba(229,163,73,0.3), inset 3px 0 0 var(--amber);
}
.option-item.disabled { pointer-events: none; }

.option-item.correct {
  border-color: var(--good);
  background: var(--good-bg);
  box-shadow: 0 0 0 1px var(--good), 0 0 20px -4px rgba(95,208,104,0.3), inset 3px 0 0 var(--good);
  animation: breathe 0.9s var(--ease-out) 1 both;
}
.option-item.wrong {
  border-color: var(--bad);
  background: var(--bad-bg);
  box-shadow: 0 0 0 1px var(--bad), 0 0 20px -4px rgba(240,100,73,0.3), inset 3px 0 0 var(--bad);
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}
.option-item.missed {
  border-color: var(--good);
  border-style: dashed;
  background: var(--good-dim);
}

.option-indicator {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 1px;
  transition: all 0.2s var(--ease-out);
}
.option-item.selected .option-indicator {
  border-color: var(--amber);
  background: var(--amber);
  color: var(--bg);
}
.option-item.correct .option-indicator {
  border-color: var(--good);
  background: var(--good);
  color: var(--bg);
}
.option-item.wrong .option-indicator {
  border-color: var(--bad);
  background: var(--bad);
  color: #fff;
}
.option-indicator.checkbox { border-radius: 5px; }
/* Inline status glyphs (replace bare Unicode ✓/✗). */
.status-ic { width: 1em; height: 1em; }
.option-indicator .status-ic { width: 14px; height: 14px; }
.statement-result .status-ic, .match-result .status-ic { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }

.option-text { flex: 1; min-width: 0; }
.option-en { font-size: 0.9rem; color: var(--text); line-height: 1.5; }
.option-zh { font-family: var(--font-zh); font-size: 0.85rem; color: var(--muted); margin-top: 3px; line-height: 1.5; }

/* === Yes/No === */
.statements-list { display: flex; flex-direction: column; gap: 14px; }

.statement-item {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  animation: fade-up 0.35s var(--ease-out) both;
}
.statement-item:nth-child(1) { animation-delay: 0.05s; }
.statement-item:nth-child(2) { animation-delay: 0.1s; }
.statement-item:nth-child(3) { animation-delay: 0.15s; }

.statement-text { margin-bottom: 12px; }
.statement-en { font-size: 0.9rem; color: var(--text); line-height: 1.55; }
.statement-zh { font-family: var(--font-zh); font-size: 0.85rem; color: var(--muted); margin-top: 4px; line-height: 1.55; }

.yn-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.yn-btn {
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  transition: all 0.2s var(--ease-out);
  letter-spacing: 0.5px;
}
.yn-btn:hover { border-color: var(--border-hover); background: var(--surface-hover); }
.yn-btn.active {
  border-color: var(--amber);
  background: var(--amber-dim);
  color: var(--amber);
  box-shadow: 0 0 0 1px var(--amber);
}
.yn-btn:disabled { cursor: default; }
.yn-btn.correct-answer {
  border-color: var(--good);
  background: var(--good-bg);
  color: var(--good);
  box-shadow: 0 0 0 1px var(--good);
}
.yn-btn.wrong-answer {
  border-color: var(--bad);
  background: var(--bad-bg);
  color: var(--bad);
  box-shadow: 0 0 0 1px var(--bad);
}

.statement-result {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}
.statement-result.correct { color: var(--good); }
.statement-result.wrong { color: var(--bad); }

/* === Match === */
.match-list { display: flex; flex-direction: column; gap: 14px; }
.match-item {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  animation: fade-up 0.35s var(--ease-out) both;
}
.match-item:nth-child(1) { animation-delay: 0.05s; }
.match-item:nth-child(2) { animation-delay: 0.1s; }
.match-item:nth-child(3) { animation-delay: 0.15s; }
.match-item.correct { border-color: var(--good); background: var(--good-bg); box-shadow: 0 0 0 1px var(--good); }
.match-item.wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 0 0 1px var(--bad); }

.match-text { margin-bottom: 12px; }
.match-en { font-size: 14px; color: var(--text); }
.match-zh { font-family: var(--font-zh); font-size: 13px; color: var(--muted); margin-top: 3px; }

.match-select,
.order-select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.match-select:focus,
.order-select:focus { border-color: var(--amber); outline: none; box-shadow: 0 0 0 1px var(--amber); }
.match-select:disabled,
.order-select:disabled { cursor: default; opacity: 0.85; }
.match-select option,
.order-select option { background: #1a1a1d; color: var(--text); }

.match-result {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}
.match-result.correct { color: var(--good); }
.match-result.wrong { color: var(--bad); }

/* === Order === */
.order-list { display: flex; flex-direction: column; gap: 10px; }
.order-slot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.order-slot.correct { border-color: var(--good); background: var(--good-bg); box-shadow: 0 0 0 1px var(--good); }
.order-slot.wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 0 0 1px var(--bad); }

.order-num {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(229,163,73,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
}

/* === Buttons === */
.btn-row {
  margin-top: 28px;
  display: flex;
  gap: 12px;
}

.btn-primary {
  flex: 1;
  padding: 0.95rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--amber), #d4912e);
  color: var(--bg);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px -4px var(--amber-glow), 0 1px 0 rgba(255,255,255,0.25) inset;
}
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  background-size: 200% 100%;
  opacity: 0;
  transition: opacity 0.3s;
}
.btn-primary:hover::before { opacity: 1; animation: shimmer 1.5s ease infinite; }
.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-primary:disabled::before { display: none; }
.btn-primary:hover:not(:disabled) { box-shadow: 0 4px 20px rgba(229,163,73,0.3); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary {
  padding: 14px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-hover); }

/* === Feedback === */
.feedback-banner {
  position: relative;
  overflow: hidden;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 0.5px;
  animation: scale-in 0.3s var(--ease-spring);
}
/* light-burst on reveal, tinted to the banner's good/bad color via currentColor */
.feedback-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, currentColor, transparent 60%);
  animation: feedback-burst 0.6s var(--ease-out) forwards;
}
@keyframes feedback-burst {
  0%   { opacity: 0.35; transform: scale(0.6); }
  100% { opacity: 0; transform: scale(1.3); }
}
.feedback-banner.correct {
  background: var(--good-bg);
  color: var(--good);
  border: 1px solid rgba(95,208,104,0.3);
  box-shadow: 0 0 40px -8px var(--good-glow), 0 0 0 1px rgba(95,208,104,0.3) inset;
}
.feedback-banner.wrong {
  background: var(--bad-bg);
  color: var(--bad);
  border: 1px solid rgba(240,100,73,0.3);
  box-shadow: 0 0 40px -8px var(--bad-glow), 0 0 0 1px rgba(240,100,73,0.3) inset;
}

.explanation-box {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-top: 16px;
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px -16px rgba(0,0,0,0.8);
  animation: fade-in 0.4s var(--ease-out) 0.1s both;
}
.explanation-title {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(229,163,73,0.3);
  opacity: 0.8;
}
.explanation-body {
  white-space: normal;
}
.explanation-en {
  color: var(--text);
  line-height: 1.75;
  white-space: pre-wrap;
}
.explanation-zh {
  color: var(--muted);
  font-family: var(--font-zh);
  line-height: 1.8;
  margin-top: 8px;
  white-space: pre-wrap;
}
.explanation-empty {
  color: var(--muted);
  font-family: var(--font-zh);
}
.reference-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  white-space: normal;
}
.reference-title {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}
.reference-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.reference-list a {
  color: var(--amber);
  overflow-wrap: anywhere;
  text-decoration: none;
}
.reference-list a:hover {
  text-decoration: underline;
}

/* === Wrong Book === */
.wrongbook-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  animation: fade-in 0.3s var(--ease-out);
}
.wrongbook-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-bright);
}
.wrongbook-actions { display: flex; gap: 8px; }

.wrong-item {
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  transition: border-color 0.2s;
  animation: fade-up 0.4s var(--ease-out) both;
}
.wrong-item:hover { border-color: var(--border-hover); }

.wrong-item-info { flex: 1; min-width: 0; }
.wrong-item-id {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  color: var(--amber);
}
.wrong-item-preview {
  font-family: var(--font-zh);
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.wrong-item-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(232,228,222,0.3);
  margin-top: 8px;
}
.wrong-item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.btn-small {
  padding: 7px 14px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-small:hover { background: var(--surface-hover); border-color: var(--border-hover); }
.btn-small.danger { color: var(--bad); border-color: rgba(240,100,73,0.3); }
.btn-small.danger:hover { background: var(--bad-bg); border-color: var(--bad); }

/* === Stats === */
.stats-section-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, rgba(255,255,255,0.04), transparent 55%), var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  box-shadow: var(--elev-1);
  animation: fade-up 0.4s var(--ease-out) both;
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  pointer-events: none;
  background: linear-gradient(150deg, rgba(255,255,255,0.10), transparent 55%);
  -webkit-mask: var(--ring-mask);
  mask: var(--ring-mask);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.stat-card:nth-child(1) { animation-delay: 0s; }
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }

.stat-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--amber);
  letter-spacing: -1px;
  line-height: 1;
  text-shadow: 0 0 20px var(--amber-glow-soft);
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-value[style*="--good"] { text-shadow: 0 0 20px var(--good-glow); }
.stat-card .stat-value[style*="--bad"]  { text-shadow: 0 0 20px var(--bad-glow); }

/* Accuracy gauge: conic ring with the % as real text in the bore */
.stat-ring {
  width: 92px;
  height: 92px;
  margin: 0 auto 6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background: conic-gradient(var(--amber) calc(var(--pct) * 1%), var(--ring-track) 0);
  box-shadow: 0 0 24px -6px var(--amber-glow);
  transition: background 0.9s var(--ease-out);
}
.stat-ring::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--bg-warm);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5) inset;
}
.stat-ring .ring-num { position: relative; font-size: 1.5rem; }

/* Type distribution as single-column stacked bars (answered behind, correct in front) */
.type-bars { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.type-legend { display: flex; gap: 16px; margin-bottom: 12px; font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); }
.type-legend span { display: inline-flex; align-items: center; gap: 6px; }
.type-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--ring-track); box-shadow: 0 0 0 1px var(--border) inset; }
.type-bar-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.type-bar-name { font-family: var(--font-zh); font-size: 0.9rem; color: var(--text); }
.type-bar-val { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.type-bar-track {
  position: relative;
  height: 8px;
  border-radius: 4px;
  background: var(--ring-track);
  box-shadow: 0 1px 2px rgba(0,0,0,0.5) inset;
  overflow: hidden;
}
.type-bar-fill, .type-bar-correct {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: calc(var(--w) * 1%);
  border-radius: 4px;
  transition: width 0.9s var(--ease-out);
}
.type-bar-fill { background: var(--bad); box-shadow: 0 0 10px var(--bad-glow); }
.type-bar-correct { background: var(--good); box-shadow: 0 0 10px var(--good-glow); }
.stat-label {
  font-family: var(--font-zh);
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.empty-icon {
  margin-bottom: 20px;
  color: var(--amber);
  display: flex;
  justify-content: center;
}
.empty-icon svg { width: 52px; height: 52px; }
.empty-text {
  font-family: var(--font-display);
  font-size: 17px;
  color: var(--text);
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  transition: all 0.3s var(--ease-out);
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* === Selection === */
::selection { background: rgba(229,163,73,0.3); color: var(--text-bright); }

/* === Responsive === */
@media (max-width: 540px) {
  .mode-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  main { padding: 16px 14px 40px; }
  .card { padding: 20px; }
  .header { padding: 12px 14px; gap: 10px; }
  .header-right { gap: 5px; }
  .btn-nav { padding: 0.48rem 0.58rem; min-width: 36px; justify-content: center; }
  .btn-nav > span:not(.badge) { display: none; }
  .btn-nav svg { opacity: 0.75; }
  .lang-btn { min-width: 34px; padding: 0.38rem 0.4rem; }
  /* The inline answer select can be wider than a narrow column; let it fill. */
  .dropdown-answer-wrap { display: flex; width: 100%; margin: 6px 0; }
  .dropdown-answer { width: 100%; }
  /* Depth & Light: tame the hero glow + instrument sizes on narrow screens */
  .home-progress { padding: 28px 18px 26px; }
  .home-progress::after { width: 220px; height: 140px; filter: blur(32px); }
  .stat-ring { width: 80px; height: 80px; }
  .mode-icon { width: 44px; height: 44px; }
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

@media (min-width: 1400px) {
  .app-shell { max-width: 920px; }
  .card { padding: 2rem; }
  main { padding: 2rem 1.5rem 3.5rem; }
}

@media (min-width: 1800px) {
  .app-shell { max-width: 1020px; }
}

@media (min-width: 2200px) {
  .app-shell { max-width: 1100px; }
}

/* ============================================================
   WARM PAPER — light theme  (html[data-theme="light"])
   A warm ivory page lit by rich ochre. Overrides the :root
   tokens + every dark-assuming hard-coded value. MUST stay LAST
   in the file (wins by source order + specificity). Radius /
   fonts / eases / --ring-mask are theme-agnostic and inherited.
   Two-amber split: --amber stays BRIGHT for fills/rings/borders;
   --amber-text is the dark ochre used for text & standalone glyphs.
   ============================================================ */
html[data-theme="light"] {
  --bg: #f7f3ea;
  --bg-warm: #f1e9d9;

  --surface: rgba(58,42,18,0.045);
  --surface-hover: rgba(58,42,18,0.075);
  --surface-active: rgba(58,42,18,0.11);

  --glass: rgba(255,252,245,0.72);
  --glass-border: rgba(58,42,18,0.12);

  --text: #3a3027;
  --text-bright: #241c12;
  --muted: #766550;          /* SOLID warm neutral, ~5:1 on ivory (audit: 8a7a66 was 3.75:1, failed AA) */

  --amber: #e5a349;          /* fills / rings / borders / gradients / conic */
  --amber-text: #985c12;     /* text & standalone glyphs (~4.6:1 on ivory) */
  --amber-dim: rgba(229,163,73,0.20);

  --good: #2c9c44;           /* fill / border (UI ≥3:1) */
  --good-text: #1c7330;      /* text (~4.8:1) */
  --good-bg: rgba(44,156,68,0.14);
  --good-dim: rgba(44,156,68,0.09);
  --bad: #d23b1f;            /* fill / border */
  --bad-text: #b8331a;       /* text (~4.7:1) */
  --bad-bg: rgba(210,59,31,0.12);
  --warn: #9a6a08;           /* text-legible warn (~4.6:1) */

  --border: rgba(58,42,18,0.10);
  --border-hover: rgba(58,42,18,0.20);

  --shadow: 0 2px 8px rgba(74,56,28,0.10), 0 0 1px rgba(74,56,28,0.06) inset;
  --shadow-lg: 0 10px 30px rgba(74,56,28,0.14), 0 1px 0 rgba(255,255,255,0.6) inset;

  --amber-glow: rgba(229,163,73,0.32);
  --amber-glow-soft: rgba(229,163,73,0.14);
  --good-glow: rgba(44,156,68,0.28);
  --bad-glow: rgba(210,59,31,0.28);

  --ring-track: rgba(58,42,18,0.10);
  --elev-1: 0 2px 8px rgba(74,56,28,0.10), 0 1px 0 rgba(255,255,255,0.5) inset;
  --elev-2: 0 14px 34px rgba(74,56,28,0.16), 0 1px 0 rgba(255,255,255,0.65) inset;
}

/* ---------- header ---------- */
html[data-theme="light"] body { background: var(--bg); }
html[data-theme="light"] .header { background: rgba(247,243,234,0.94); }
html[data-theme="light"] .lang-toggle { background: rgba(58,42,18,0.04); }
html[data-theme="light"] .lang-btn.active {
  color: var(--amber-text);
  box-shadow: 0 0 0 1px rgba(229,163,73,0.45);
}

/* ---------- background / noise / glow ---------- */
html[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(229,163,73,0.16) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(229,163,73,0.10) 0%, transparent 50%);
}
html[data-theme="light"] .noise-overlay { opacity: 0.02; mix-blend-mode: multiply; }

/* ---------- cards, rings & sheens ---------- */
html[data-theme="light"] .card {
  background: radial-gradient(130% 90% at 50% -5%, rgba(255,255,255,0.5), transparent 50%), var(--glass);
  box-shadow: var(--shadow-lg), 0 1px 0 rgba(255,255,255,0.6) inset;
}
html[data-theme="light"] .card:not(.home-progress):not(.empty-state)::before {
  background: linear-gradient(155deg, rgba(229,163,73,0.40), rgba(58,42,18,0.06) 30%, transparent 65%);
}
html[data-theme="light"] .home-progress {
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(229,163,73,0.22) 0%, transparent 55%),
    var(--glass);
  box-shadow: var(--shadow-lg), 0 0 50px -16px rgba(229,163,73,0.22), 0 1px 0 rgba(255,255,255,0.6) inset;
}
html[data-theme="light"] .home-progress::before {
  background: linear-gradient(160deg, rgba(229,163,73,0.65), rgba(58,42,18,0.08) 35%, var(--glass-border) 70%);
}
html[data-theme="light"] .mode-card,
html[data-theme="light"] .stat-card {
  background: radial-gradient(140% 100% at 50% 0%, rgba(229,163,73,0.06), transparent 60%), var(--glass);
}
html[data-theme="light"] .mode-card::after {
  background: linear-gradient(150deg, rgba(58,42,18,0.10), transparent 50%);
}
html[data-theme="light"] .mode-card:hover::after {
  background: linear-gradient(150deg, rgba(229,163,73,0.55), rgba(58,42,18,0.05) 50%);
}
html[data-theme="light"] .mode-card:hover {
  border-color: rgba(229,163,73,0.55);
  box-shadow: var(--elev-2), 0 0 0 1px rgba(229,163,73,0.35), 0 6px 22px -10px rgba(229,163,73,0.30);
}
html[data-theme="light"] .stat-card::before {
  background: linear-gradient(150deg, rgba(229,163,73,0.34), rgba(58,42,18,0.06) 55%, transparent);
}

/* ---------- amber-as-text → --amber-text ---------- */
html[data-theme="light"] .logo-mark,
html[data-theme="light"] .quiz-back,
html[data-theme="light"] .dropdown-token,
html[data-theme="light"] .wrong-item-id,
html[data-theme="light"] .reference-list a,
html[data-theme="light"] .order-num,
html[data-theme="light"] .mode-icon { color: var(--amber-text); }

html[data-theme="light"] .q-type-badge {
  color: var(--amber-text);
  box-shadow: 0 0 0 1px rgba(229,163,73,0.40) inset;
}
html[data-theme="light"] .explanation-title { color: var(--amber-text); text-shadow: none; opacity: 1; }
html[data-theme="light"] .home-title { text-shadow: none; }

/* ---------- stat numbers (glow halos → off, semantic text colors) ---------- */
html[data-theme="light"] .stat-value { color: var(--amber-text); text-shadow: none; }
html[data-theme="light"] .stat-card .stat-value[style*="--good"] { color: var(--good-text); text-shadow: none; }
html[data-theme="light"] .stat-card .stat-value[style*="--bad"]  { color: var(--bad-text);  text-shadow: none; }
html[data-theme="light"] .score-text .correct-num { color: var(--good-text); }
html[data-theme="light"] .score-text .wrong-num   { color: var(--bad-text); }

/* ---------- selects & options (hard-coded dark popups + carets) ---------- */
html[data-theme="light"] .dropdown-answer option,
html[data-theme="light"] .match-select option,
html[data-theme="light"] .order-select option { background: #fffdf8; color: var(--text); }
html[data-theme="light"] .match-select,
html[data-theme="light"] .order-select { background-color: rgba(58,42,18,0.04); }
html[data-theme="light"] .dropdown-answer {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23985c12' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
html[data-theme="light"] .match-select,
html[data-theme="light"] .order-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6660' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ---------- progress / stat-ring / type-bars ---------- */
html[data-theme="light"] .progress-bar {
  background: rgba(58,42,18,0.10);
  box-shadow: 0 1px 2px rgba(74,56,28,0.12) inset;
}
html[data-theme="light"] .stat-ring { box-shadow: 0 0 16px -8px var(--amber-glow); }
html[data-theme="light"] .stat-ring::before { box-shadow: 0 1px 4px rgba(74,56,28,0.18) inset; }
html[data-theme="light"] .type-bar-track { box-shadow: 0 1px 2px rgba(74,56,28,0.12) inset; }

/* ---------- option states & feedback ---------- */
html[data-theme="light"] .option-item { background: var(--surface); }
html[data-theme="light"] .option-item:hover {
  border-color: rgba(229,163,73,0.55);
  background: rgba(229,163,73,0.10);
}
html[data-theme="light"] .option-item.selected { box-shadow: 0 0 0 1px var(--amber), inset 3px 0 0 var(--amber); }
html[data-theme="light"] .option-item.correct  { box-shadow: 0 0 0 1px var(--good),  inset 3px 0 0 var(--good); }
html[data-theme="light"] .option-item.wrong    { box-shadow: 0 0 0 1px var(--bad),   inset 3px 0 0 var(--bad); }
html[data-theme="light"] .option-indicator { border-color: rgba(58,42,18,0.22); }
/* glyph traps: base paints these with var(--bg)=cream → force dark on the colored fills */
html[data-theme="light"] .option-item.selected .option-indicator { color: #2a1c08; }
html[data-theme="light"] .option-item.correct  .option-indicator { color: #0f3d18; }

html[data-theme="light"] .yn-btn.active         { color: var(--amber-text); }
html[data-theme="light"] .yn-btn.correct-answer { color: var(--good-text); }
html[data-theme="light"] .yn-btn.wrong-answer   { color: var(--bad-text); }
html[data-theme="light"] .statement-result.correct,
html[data-theme="light"] .match-result.correct  { color: var(--good-text); }
html[data-theme="light"] .statement-result.wrong,
html[data-theme="light"] .match-result.wrong    { color: var(--bad-text); }

html[data-theme="light"] .feedback-banner.correct {
  color: var(--good-text);
  border: 1px solid rgba(44,156,68,0.40);
  box-shadow: 0 6px 20px -10px var(--good-glow), 0 0 0 1px rgba(44,156,68,0.30) inset;
}
html[data-theme="light"] .feedback-banner.wrong {
  color: var(--bad-text);
  border: 1px solid rgba(210,59,31,0.40);
  box-shadow: 0 6px 20px -10px var(--bad-glow), 0 0 0 1px rgba(210,59,31,0.30) inset;
}
html[data-theme="light"] .explanation-box {
  background: rgba(58,42,18,0.035);
  box-shadow: 0 1px 0 rgba(255,255,255,0.5) inset, 0 8px 24px -18px rgba(74,56,28,0.30);
}

/* ---------- buttons ---------- */
html[data-theme="light"] .btn-primary {
  color: #2a1c08;
  box-shadow: 0 4px 14px -6px var(--amber-glow), 0 1px 0 rgba(255,255,255,0.45) inset;
}
html[data-theme="light"] .btn-primary:hover:not(:disabled) { box-shadow: 0 6px 18px -6px rgba(229,163,73,0.45); }
html[data-theme="light"] .btn-small.danger { color: var(--bad-text); }
html[data-theme="light"] .quiz-reset {
  border-color: rgba(154,106,8,0.30);
  background: rgba(154,106,8,0.08);
  color: var(--warn);
}
html[data-theme="light"] .quiz-reset:hover {
  background: rgba(154,106,8,0.14);
  border-color: rgba(154,106,8,0.50);
}
html[data-theme="light"] .wrong-item-meta { color: #6e5d48; }

/* ---------- focus ring (1.4.11: bright amber is too low-contrast on ivory) ---------- */
html[data-theme="light"] :focus-visible,
html[data-theme="light"] .mode-card:focus-visible,
html[data-theme="light"] .option-item:focus-visible,
html[data-theme="light"] .btn-nav:focus-visible,
html[data-theme="light"] .lang-btn:focus-visible,
html[data-theme="light"] .quiz-back:focus-visible,
html[data-theme="light"] .btn-small:focus-visible,
html[data-theme="light"] .btn-primary:focus-visible,
html[data-theme="light"] .btn-secondary:focus-visible,
html[data-theme="light"] .quiz-reset:focus-visible,
html[data-theme="light"] .yn-btn:focus-visible,
html[data-theme="light"] .logo-btn:focus-visible { outline-color: var(--amber-text); }

/* ---------- scrollbar / selection / toast ---------- */
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(58,42,18,0.20); }
html[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(58,42,18,0.32); }
html[data-theme="light"] ::selection { background: rgba(229,163,73,0.35); color: var(--text-bright); }
html[data-theme="light"] .toast { box-shadow: 0 10px 30px rgba(74,56,28,0.18); }
