/* ── Theme variables ── */
:root {
  --accent: #FF3621;
  --accent-hover: #ff5540;
  --correct: #16a34a;
  --correct-bg: rgba(22,163,74,0.12);
  --incorrect: #dc2626;
  --incorrect-bg: rgba(220,38,38,0.12);
  --warning: #d97706;
  --warning-bg: rgba(217,119,6,0.1);
  --info: #2563eb;
  --info-bg: rgba(37,99,235,0.1);
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.15);
}

/* ── Dark mode (default) ── */
:root,
:root[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222534;
  --surface3: #2a2e42;
  --border: #2e3147;
  --border-hover: #3d4266;
  --text: #e8eaf0;
  --text-muted: #8b92b0;
  --text-faint: #555e80;
  --code-bg: #0d1117;
  --code-text: #e6edf3;
  --code-inline-bg: rgba(255,255,255,0.08);
  --code-inline-text: #79c0ff;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

/* ── Light mode ── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface2: #f0f1f4;
    --surface3: #e8eaf0;
    --border: #d1d5db;
    --border-hover: #9ca3af;
    --text: #111827;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;
    --code-bg: #1e1e2e;
    --code-text: #cdd6f4;
    --code-inline-bg: rgba(0,0,0,0.07);
    --code-inline-text: #2563eb;
    --shadow: 0 4px 24px rgba(0,0,0,0.1);
  }
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface2: #f0f1f4;
  --surface3: #e8eaf0;
  --border: #d1d5db;
  --border-hover: #9ca3af;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --code-bg: #1e1e2e;
  --code-text: #cdd6f4;
  --code-inline-bg: rgba(0,0,0,0.07);
  --code-inline-text: #2563eb;
  --shadow: 0 4px 24px rgba(0,0,0,0.1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

a { color: inherit; text-decoration: none; }

/* ── Layout ── */
.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }
.container--wide { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ── Nav ── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
  color: var(--text);
}

.nav__logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  color: white;
}

.nav__spacer { flex: 1; }

.nav__link {
  color: var(--text-muted);
  font-size: 14px;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: all 0.15s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.nav__link:hover { color: var(--text); background: var(--surface2); }
.nav__link--active { color: var(--text); }

/* Theme toggle button */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-hover); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
  color: var(--text);
}
.btn--primary {
  background: var(--accent);
  color: white !important;
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn--ghost:hover { color: var(--text); border-color: var(--border-hover); background: var(--surface2); }
.btn--sm { padding: 7px 14px; font-size: 13px; }
.btn--lg { padding: 14px 28px; font-size: 16px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card:hover { border-color: var(--border-hover); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge--available { background: var(--correct-bg); color: var(--correct); }
.badge--coming { background: var(--surface2); color: var(--text-muted); }
.badge--easy { background: var(--correct-bg); color: var(--correct); }
.badge--medium { background: var(--warning-bg); color: var(--warning); }
.badge--hard { background: var(--incorrect-bg); color: var(--incorrect); }

/* ── Progress bar ── */
.progress-bar {
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Code ── */
pre, code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 13px;
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  margin: 12px 0;
  line-height: 1.5;
  color: var(--code-text);
}
code {
  background: var(--code-inline-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--code-inline-text);
}
pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* ── Timer ── */
.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 6px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 90px;
  color: var(--text);
}
.timer--warning { color: var(--warning) !important; border-color: rgba(217,119,6,0.4); }
.timer--critical { color: var(--incorrect) !important; border-color: rgba(220,38,38,0.4); animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ── Answer options ── */
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 10px;
  text-align: left;
  width: 100%;
  /* Fix: browser button default clobbers color */
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
}
.option:hover:not(.correct):not(.incorrect):not(.missed) {
  border-color: var(--border-hover);
  background: var(--surface3);
}
.option.selected {
  border-color: var(--info);
  background: var(--info-bg);
  color: var(--text);
}
.option.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--text);
}
.option.incorrect {
  border-color: var(--incorrect);
  background: var(--incorrect-bg);
  color: var(--text);
}
.option.missed {
  border-color: var(--correct);
  background: var(--correct-bg);
  opacity: 0.75;
  border-style: dashed;
  color: var(--text);
}

.option__key {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.15s;
  /* Explicitly inherit text color so it's always visible */
  color: var(--text-muted);
  background: var(--surface);
  font-family: inherit;
}
.option:hover:not(.correct):not(.incorrect):not(.missed) .option__key {
  border-color: var(--border-hover);
  color: var(--text);
}
.option.selected .option__key {
  border-color: var(--info);
  background: var(--info);
  color: white;
}
.option.correct .option__key {
  border-color: var(--correct);
  background: var(--correct);
  color: white;
}
.option.incorrect .option__key {
  border-color: var(--incorrect);
  background: var(--incorrect);
  color: white;
}
.option.missed .option__key {
  border-color: var(--correct);
  color: var(--correct);
  background: transparent;
}

.option__text { flex: 1; padding-top: 2px; color: inherit; }

/* ── Question Navigator dots ── */
.q-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 6px;
}
.q-dot {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-muted);
  font-family: inherit;
}
.q-dot:hover { border-color: var(--border-hover); color: var(--text); }
.q-dot.answered { background: var(--info-bg); border-color: var(--info); color: var(--text); }
.q-dot.flagged { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.q-dot.current { border-color: var(--accent); color: var(--accent); }
.q-dot.correct { background: var(--correct-bg); border-color: var(--correct); color: var(--correct); }
.q-dot.incorrect { background: var(--incorrect-bg); border-color: var(--incorrect); color: var(--incorrect); }

/* ── Explanation box ── */
.explanation {
  margin-top: 16px;
  padding: 16px;
  background: var(--info-bg);
  border: 1px solid rgba(37,99,235,0.25);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
}
.explanation__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--info);
  margin-bottom: 8px;
}

/* ── Multi-hint ── */
.multi-hint {
  font-size: 12px;
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid rgba(217,119,6,0.25);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Domain bar ── */
.domain-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.domain-bar__name { width: 200px; font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.domain-bar__track {
  flex: 1;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}
.domain-bar__fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}
.domain-bar__score { width: 48px; text-align: right; font-size: 13px; font-weight: 700; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow);
  color: var(--text);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s;
  z-index: 999;
  max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── Spinner ── */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ── */
.text-muted { color: var(--text-muted) !important; }
.text-correct { color: var(--correct) !important; }
.text-incorrect { color: var(--incorrect) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }
.fs-14 { font-size: 14px; }
.fs-20 { font-size: 20px; }
.fs-24 { font-size: 24px; }

@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .nav { padding: 0 16px; }
}
