/* ─── TOKENS ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #f4f1eb;
  --surface: #fffdf8;
  --surface-2: #f0ece2;
  --border: #ddd8cc;
  --ink: #1e1b14;
  --ink-2: #5a5347;
  --ink-3: #8a8070;
  --accent: #1a4f3a;
  --accent-light: #e8f2ed;
  --accent-2: #c8872a;
  --accent-2-light: #fdf3e3;
  --correct: #1a6b3a;
  --correct-bg: #e6f4ec;
  --wrong: #b53a2a;
  --wrong-bg: #fbeae8;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(30, 27, 20, 0.08);
  --shadow-md: 0 4px 24px rgba(30, 27, 20, 0.12);
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Source Serif 4", "Times New Roman", serif;
  --font-ui: "DM Sans", system-ui, sans-serif;
}

/* ─── DARK MODE TOKENS ────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:           #0f1210;
  --surface:      #181f1c;
  --surface-2:    #1e2822;
  --border:       #2d3d35;
  --ink:          #e8e4da;
  --ink-2:        #a8a096;
  --ink-3:        #6a6560;
  --accent:       #4a9e78;
  --accent-light: #1a3028;
  --accent-2:     #d4963a;
  --accent-2-light: #2a1f0a;
  --correct:      #4aad6a;
  --correct-bg:   #0f2418;
  --wrong:        #d4614e;
  --wrong-bg:     #2a100d;
  --shadow:       0 2px 12px rgba(0, 0, 0, 0.35);
  --shadow-md:    0 4px 24px rgba(0, 0, 0, 0.50);
}

/* ─── THEME TRANSITION ────────────────────────────────────────────────────── */
body,
.top-bar,
.card,
.case-study-details,
.case-static,
.option-btn,
.feedback-box,
.answer-point,
.rating-btn,
.sub-q-tab,
.loading-msg code {
  transition:
    background-color 0.25s ease,
    border-color     0.25s ease,
    color            0.25s ease,
    box-shadow       0.25s ease;
}

/* ─── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
}
button { cursor: pointer; font-family: var(--font-ui); border: none; background: none; }
details summary { cursor: pointer; }
details summary::-webkit-details-marker { display: none; }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.tagline {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-3);
  display: none;
}

@media (min-width: 480px) { .tagline { display: block; } }

.back-btn {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--accent);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.back-btn:hover { background: var(--accent-light); }

.screen {
  flex: 1;
  padding: 24px 16px 100px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

/* ─── TYPOGRAPHY ─────────────────────────────────────────────────────────── */
.screen-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 24px;
  line-height: 1.25;
}

.breadcrumb {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.q-counter {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--ink-3);
  margin-bottom: 16px;
  font-weight: 500;
}

/* ─── PROGRESS BAR ───────────────────────────────────────────────────────── */
.progress-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  margin-bottom: 10px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ─── CARDS ──────────────────────────────────────────────────────────────── */
.card-grid {
  display: grid;
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Subject card */
.subject-card {
  padding: 24px 20px;
}
.card-icon { font-size: 2rem; flex-shrink: 0; }
.card-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  display: block;
}
.card-code {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-3);
  display: block;
  margin-top: 2px;
}

/* Year card */
.year-card { flex-direction: column; align-items: flex-start; gap: 4px; }
.card-year-label {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
}
.card-year-sub {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--ink-3);
}

/* Section card */
.section-card { flex-direction: column; align-items: flex-start; gap: 6px; }
.section-badge {
  width: 36px; height: 36px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
}
.card-sub {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--ink-3);
}

/* Question card */
.question-card {
  display: block;
  cursor: default;
}
.question-card:hover { transform: none; box-shadow: var(--shadow); }

.q-marks-row { margin-bottom: 6px; }
.q-marks {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--accent-2);
  font-weight: 600;
  background: var(--accent-2-light);
  padding: 2px 8px;
  border-radius: 20px;
}

.q-text {
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.65;
  margin-bottom: 20px;
}

/* ─── MCQ OPTIONS ────────────────────────────────────────────────────────── */
.options-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.option-btn {
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.4;
}

.option-btn:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.option-btn.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
  font-weight: 600;
}

.option-btn.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
}

.option-btn.dimmed {
  opacity: 0.5;
}

/* ─── FEEDBACK ───────────────────────────────────────────────────────────── */
.feedback-box {
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.feedback-label {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--ink);
}
.feedback-exp {
  font-size: 0.9rem;
  color: var(--ink-2);
  margin-bottom: 6px;
  line-height: 1.5;
}
.feedback-ref {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-3);
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 13px 20px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: #133d2c; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

/* ─── CASE STUDY ─────────────────────────────────────────────────────────── */
.case-study-details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.case-summary {
  padding: 14px 18px;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.case-summary::after {
  content: "▼";
  font-size: 0.7rem;
  margin-left: auto;
  transition: transform 0.2s;
  color: var(--ink-3);
}
details[open] .case-summary::after { transform: rotate(180deg); }

.case-body {
  padding: 0 18px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink-2);
}
.case-body p { margin-top: 10px; }
.case-body p:first-child { margin-top: 12px; }

/* ─── WRITTEN ANSWER ─────────────────────────────────────────────────────── */
.answer-block {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  margin-top: 4px;
}

.answer-section {
  margin-bottom: 18px;
}

.answer-section h4 {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.answer-section p {
  font-size: 0.9rem;
  color: var(--ink-2);
  line-height: 1.65;
}

.answer-point {
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

.answer-point strong {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.answer-point p {
  font-size: 0.875rem;
  color: var(--ink-2);
  line-height: 1.6;
}

.answer-block .feedback-ref {
  margin: -4px 0 16px;
}
.rating-area {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.rating-prompt {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-3);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.rating-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rating-btn {
  padding: 8px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--ink-2);
  transition: border-color 0.15s, background 0.15s;
}

.rating-btn:hover { border-color: var(--accent); }

.rating-btn.active-confident {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
}
.rating-btn.active-almost {
  border-color: #c8872a;
  background: var(--accent-2-light);
  color: #7a4e08;
}
.rating-btn.active-revise {
  border-color: var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
}

/* ─── LOADING SCREEN ─────────────────────────────────────────────────────── */
.loading-screen {
  padding-bottom: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
  padding: 32px;
  text-align: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-msg {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink-3);
  line-height: 1.5;
}

.loading-msg code {
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.85em;
}

.error-icon {
  font-size: 2.5rem;
}

/* ─── STATIC CASE BLOCK (Section A grouped MCQ) ─────────────────────────── */
/* Not collapsible — stays visible while cycling through grouped questions.   */
.case-static {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.case-static-title {
  padding: 12px 18px;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  background: var(--accent-light);
}

.case-static-body {
  padding: 14px 18px;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--ink-2);
}
.case-static-body p { margin-bottom: 8px; }
.case-static-body p:last-child { margin-bottom: 0; }

/* ─── KEY FACTS DROPDOWN (Section B only) ────────────────────────────────── */
.keyfacts-details { margin-top: -6px; } /* tuck neatly below full case */

.keyfacts-summary {
  color: var(--accent-2);           /* amber to visually distinguish from case */
}

.keyfacts-list {
  list-style: none;
  padding: 4px 18px 14px;
  margin: 0;
  border-top: 1px solid var(--border);
}

.keyfacts-list li {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--ink-2);
  line-height: 1.5;
  padding: 7px 0 7px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.keyfacts-list li:last-child { border-bottom: none; }

.keyfacts-list li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--accent-2);
  font-weight: 700;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (min-width: 480px) {
  .screen { padding: 32px 24px 104px; }
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .year-card, .section-card { grid-column: span 1; }
  .subject-card { grid-column: 1 / -1; }
}

@media (min-width: 640px) {
  .screen { padding: 40px 32px 112px; }
}

/* ─── SECTION B ENHANCEMENTS ─────────────────────────────────────────────── */
.command-word-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding: 4px 10px;
  background: var(--surface-2);
  border-radius: 6px;
  display: inline-block;
}

.other-answers {
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  margin-top: 4px;
}

.other-answers h4 {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.other-answers p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ─── WRITTEN QUESTION SELECTOR ──────────────────────────────────────────── */
.screen-sub {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--ink-3);
  margin-top: -16px;
  margin-bottom: 20px;
}

.written-q-card {
  border-left: 4px solid var(--accent);
}

.section-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.section-label {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  display: block;
}

.section-sub {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--ink-3);
  display: block;
}

/* ─── SUB-QUESTION TABS ───────────────────────────────────────────────────── */
.sub-q-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.sub-q-tab {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.sub-q-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.sub-q-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ─── THEME TOGGLE BUTTON ─────────────────────────────────────────────────── */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: rotate(12deg) scale(1.08);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── BOTTOM NAVIGATION BAR ──────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  box-shadow: 0 -2px 12px rgba(30, 27, 20, 0.07);
  z-index: 100;
  /* Respect device safe areas (notched phones) */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] .bottom-nav {
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.35);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  padding: 6px 4px 4px;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--ink-3);
  font-family: var(--font-ui);
  gap: 3px;
  transition: color 0.15s, background-color 0.15s;
  position: relative;
}

.nav-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: transparent;
  transition: background 0.2s;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item.active::before {
  background: var(--accent);
}

.nav-item:not(:disabled):not(.nav-disabled):hover {
  color: var(--accent);
  background: var(--accent-light);
}

.nav-item.nav-disabled,
.nav-item:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.nav-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

/* ─── MCQ SCORE SCREEN ────────────────────────────────────────────────────────── */
.score-card {
  text-align: center;
  padding: 32px 24px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.score-emoji { font-size: 2.5rem; line-height: 1; margin-bottom: 10px; }

.score-number {
  font-family: var(--font-display);
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}
.score-denom {
  font-size: 2rem;
  color: var(--ink-3);
}
.score-percentage {
  font-family: var(--font-ui);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-top: 6px;
}
.score-label {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--ink-3);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Tier colour overrides */
.score-tier-gold  .score-number { color: #b8860b; }
.score-tier-gold  .score-emoji  { filter: drop-shadow(0 2px 6px rgba(184,134,11,0.4)); }
.score-tier-green .score-number { color: var(--correct); }
.score-tier-amber .score-number { color: var(--accent-2); }
.score-tier-red   .score-number { color: var(--wrong); }

[data-theme="dark"] .score-tier-gold .score-number { color: #d4a017; }

.score-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

@media (min-width: 480px) {
  .score-actions { flex-direction: row; }
  .score-actions .btn-primary,
  .score-actions .btn-secondary { flex: 1; }
}

/* Secondary / danger buttons (used in score + confirm) */
.btn-secondary {
  display: block;
  width: 100%;
  padding: 13px 20px;
  background: var(--surface-2);
  color: var(--ink);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--accent-light); border-color: var(--accent); }

.btn-danger {
  display: block;
  width: 100%;
  padding: 13px 20px;
  background: var(--wrong-bg);
  color: var(--wrong);
  border: 1.5px solid var(--wrong);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  transition: background 0.15s;
  cursor: pointer;
}
.btn-danger:hover { background: var(--wrong); color: #fff; }

/* ─── QUESTION REVIEW LIST ────────────────────────────────────────────────────── */
.review-list-title {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.question-review-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.question-review-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.question-review-item:last-child { border-bottom: none; }
.question-review-item:hover { background: var(--accent-light); }

.question-indicator {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.question-indicator.correct  { background: var(--correct-bg); color: var(--correct); }
.question-indicator.incorrect { background: var(--wrong-bg);  color: var(--wrong); }
.question-indicator.skipped  { background: var(--surface-2);  color: var(--ink-3); }

.review-q-text {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--ink-2);
  line-height: 1.4;
}

/* ─── REVIEW MODE SCREEN ──────────────────────────────────────────────────────── */
.review-mode-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--accent-2-light);
  color: var(--accent-2);
  border-radius: 20px;
  padding: 2px 8px;
  margin-left: 8px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.review-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.review-nav .btn-secondary,
.review-nav .btn-primary { flex: 1; }

/* ─── ANSWERED BADGE (MCQ in-progress) ───────────────────────────────────────── */
.q-answered-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  padding: 2px 8px;
  margin-left: 8px;
  vertical-align: middle;
}

/* ─── CONFIRM DIALOG ──────────────────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.confirm-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 90%;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.15s ease;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.confirm-message {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 0;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.confirm-actions .btn-secondary,
.confirm-actions .btn-danger { flex: 1; padding: 10px 16px; }

/* ─── PRACTICE MODE ──────────────────────────────────────────────────────────── */
.practice-mode-card {
  border: 2px dashed var(--accent);
  background: var(--accent-light);
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.practice-mode-card .card-title { color: var(--accent); }
.practice-mode-card .card-code  { color: var(--ink-3); }
.practice-mode-card .card-icon  { font-size: 1.8rem; }

.practice-section { margin-bottom: 24px; }

.practice-section-title {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.practice-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.practice-opt-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--ink);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.practice-opt-btn:hover   { border-color: var(--accent); background: var(--accent-light); }
.practice-opt-btn.active  { border-color: var(--accent); background: var(--accent-light); color: var(--accent); font-weight: 600; }

.practice-counts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.practice-count-btn {
  flex: 1;
  min-width: 56px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-2);
  text-align: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  cursor: pointer;
}
.practice-count-btn:hover  { border-color: var(--accent); background: var(--accent-light); }
.practice-count-btn.active { border-color: var(--accent); background: var(--accent); color: #fff; }

.practice-source-badge {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-2);
  background: var(--accent-2-light);
  border-radius: 20px;
  padding: 3px 10px;
  display: inline-block;
  margin-bottom: 10px;
}

/* ─── TOP-BAR RIGHT CLUSTER ──────────────────────────────────────────────── */
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.search-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.search-icon-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  transform: scale(1.08);
}
.search-icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── SEARCH OVERLAY ──────────────────────────────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  animation: srFadeIn 0.15s ease;
}
@keyframes srFadeIn { from { opacity: 0; } to { opacity: 1; } }

.search-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  animation: srSlideDown 0.18s ease;
}
@keyframes srSlideDown { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

[data-theme="dark"] .search-panel {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.search-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  transition: border-color 0.15s;
}
.search-input-wrap:focus-within {
  border-color: var(--accent);
}

.search-input-icon {
  font-size: 0.95rem;
  flex-shrink: 0;
  opacity: 0.6;
}

.search-panel-input {
  flex: 1;
  height: 42px;
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  color: var(--ink);
  /* Remove the browser's native clear button on search inputs */
  -webkit-appearance: none;
}
.search-panel-input::-webkit-search-cancel-button { display: none; }

.search-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  font-size: 0.85rem;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.search-close-btn:hover { background: var(--wrong-bg); color: var(--wrong); border-color: var(--wrong); }

.search-panel-meta {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--ink-3);
  padding: 8px 16px 4px;
  flex-shrink: 0;
  min-height: 28px;
}

.search-panel-results {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* ─── SEARCH RESULT ITEMS ─────────────────────────────────────────────────── */
.sr-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  outline: none;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover,
.sr-item:focus-visible { background: var(--accent-light); }

.sr-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.sr-type-badge {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}
.sr-badge-mcq     { background: var(--accent-light);   color: var(--accent); }
.sr-badge-written { background: var(--accent-2-light); color: var(--accent-2); }

.sr-meta {
  font-family: var(--font-ui);
  font-size: 0.73rem;
  color: var(--ink-3);
}

.sr-text {
  font-size: 0.855rem;
  color: var(--ink-2);
  line-height: 1.45;
}

/* Search input loading state (disabled while year data fetches on overlay open) */
.search-panel-input:disabled {
  opacity: 0.45;
  cursor: wait;
}

/* ─── BOOKMARK BUTTON ─────────────────────────────────────────────────────── */
.q-card-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.q-card-header > p.q-text,
.q-card-header > div {
  flex: 1;
  min-width: 0;
}

.bm-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.15s;
  margin-top: 2px;
}
.bm-btn:hover {
  background: var(--accent-2-light);
  border-color: var(--accent-2);
  color: var(--accent-2);
  transform: scale(1.1);
}
.bm-btn.bm-active {
  background: var(--accent-2-light);
  border-color: var(--accent-2);
  color: var(--accent-2);
}
.bm-btn:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

/* ─── BOTTOM NAV BOOKMARK BADGE ──────────────────────────────────────────── */
.bm-nav-count {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--accent-2);
  color: #fff;
  border-radius: 20px;
  padding: 1px 5px;
  margin-left: 3px;
  vertical-align: middle;
  line-height: 1.4;
}

/* ─── BOOKMARKS SCREEN ───────────────────────────────────────────────────── */
.bm-total-count {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--accent-2-light);
  color: var(--accent-2);
  border-radius: 20px;
  padding: 2px 10px;
  margin-left: 10px;
  vertical-align: middle;
  font-family: var(--font-ui);
}

.bm-clear-btn {
  margin-bottom: 16px;
  font-size: 0.85rem;
  padding: 9px 16px;
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bm-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Empty state */
.bm-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-3);
}
.bm-empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}
.bm-empty-title {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.bm-empty-sub {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--ink-3);
}

/* Subject group */
.bm-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.bm-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.bm-group-icon { font-size: 1.2rem; }
.bm-group-title {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
}
.bm-group-count {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  padding: 2px 8px;
}

/* Individual bookmark card */
.bm-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.bm-item:last-child { border-bottom: none; }
.bm-item:hover { background: var(--accent-light); }

.bm-item-main { flex: 1; min-width: 0; }

.bm-item-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 5px;
}
.bm-type-badge {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
}
.bm-badge-mcq     { background: var(--accent-light);   color: var(--accent); }
.bm-badge-written { background: var(--accent-2-light); color: var(--accent-2); }

.bm-item-meta {
  font-family: var(--font-ui);
  font-size: 0.73rem;
  color: var(--ink-3);
}
.bm-item-date {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: var(--ink-3);
  margin-left: auto;
}
.bm-item-preview {
  font-size: 0.84rem;
  color: var(--ink-2);
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bm-delete-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  margin-top: 2px;
}
.bm-delete-btn:hover { background: var(--wrong-bg); color: var(--wrong); border-color: var(--wrong); }

/* ─── STATS DASHBOARD ────────────────────────────────────────────────────── */

/* Summary grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.stat-label {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* Score colour helpers (text) — reuse on stat-value, session-score, subj-score */
.score-green { color: var(--correct); }
.score-amber { color: var(--accent-2); }
.score-red   { color: var(--wrong); }

/* Shared section wrapper */
.stats-section {
  margin-bottom: 20px;
}
.stats-section-title {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.stats-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Bar chart */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 10px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.chart-title {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: 12px;
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 140px;        /* fixed chart height; bars grow up from bottom */
  overflow-x: auto;
  padding-bottom: 2px;
}
.bar-col {
  flex: 1;
  min-width: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: default;
}
.bar-score {
  font-family: var(--font-ui);
  font-size: 0.58rem;
  color: var(--ink-3);
  text-align: center;
}
.bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transition: opacity 0.15s;
}
.bar-green { background: var(--correct); }
.bar-amber { background: var(--accent-2); }
.bar-red   { background: var(--wrong); }
.bar-col:hover .bar { opacity: 0.75; }
.bar-label {
  font-family: var(--font-ui);
  font-size: 0.55rem;
  color: var(--ink-3);
  text-align: center;
  white-space: nowrap;
}

/* Subject breakdown */
.subj-list { padding: 0 }
.subj-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.subj-row:last-child { border-bottom: none; }
.subj-icon { font-size: 1.4rem; flex-shrink: 0; padding-top: 2px; }
.subj-info { flex: 1; min-width: 0; }
.subj-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.subj-name {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.subj-score {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  flex-shrink: 0;
}
.subj-meta {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.progress-bar-bg {
  height: 7px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.pf-green { background: var(--correct); }
.pf-amber { background: var(--accent-2); }
.pf-red   { background: var(--wrong); }

/* Recent sessions */
.session-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.session-row:last-child { border-bottom: none; }
.session-left { flex: 1; min-width: 0; }
.session-date {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-2);
}
.session-desc {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-3);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-score {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Empty state */
.stats-empty {
  text-align: center;
  padding: 52px 20px;
  color: var(--ink-3);
}
.stats-empty-icon {
  font-size: 3rem;
  opacity: 0.45;
  margin-bottom: 14px;
}
.stats-empty-title {
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.stats-empty-sub {
  font-family: var(--font-ui);
  font-size: 0.84rem;
  color: var(--ink-3);
  line-height: 1.55;
}

/* Footer reset link */
.stats-footer {
  margin-top: 28px;
  text-align: center;
}
.reset-stats-btn {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-3);
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}
.reset-stats-btn:hover { color: var(--wrong); }

/* ─── STATS: COMPLETED/ABANDONED ADDITIONS ───────────────────────────────── */

/* 2×2 grid for the 4-card summary */
.stats-grid-2x2 {
  grid-template-columns: repeat(2, 1fr);
}

/* Abandoned badge on recent-session rows */
.session-abandoned-badge {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-2);
  background: var(--accent-2-light);
  border-radius: 4px;
  padding: 1px 6px;
  margin-top: 3px;
}

/* Slightly muted background for abandoned rows */
.session-row-abandoned {
  opacity: 0.75;
}

/* ─── BOOKMARK VIEW (read-only) ──────────────────────────────────────────── */
.bv-mode-badge {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  background: var(--accent-2-light);
  border-radius: 20px;
  padding: 3px 10px;
  margin-bottom: 14px;
}

.bv-info-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.bv-correct-label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--correct);
  margin-bottom: 8px;
}

.bv-explanation {
  margin-top: 6px;
  font-size: 0.88rem;
  color: var(--ink-2);
  line-height: 1.5;
}
