/* ── Quick-start presets (UX-PRESETS) — quiz chapter-selection chips ──── */
.preset-row-label {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3, #6b737d);
  margin-bottom: 8px;
}
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border2, #3d4451);
  background: var(--bg3, #1c2430);
  color: var(--text, #e6edf3);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.preset-chip:hover:not(:disabled) { border-color: var(--amber, #f0a500); background: var(--bg4, #21262d); }
.preset-chip-icon { font-size: 14px; }
.preset-chip-disabled, .preset-chip:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Resume banner (UX-RESUME) — in-progress quiz/mock resume prompt ──── */
.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--amber-dim, rgba(240,165,0,0.12));
  border: 1px solid var(--amber, #f0a500);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
}
.resume-banner-text { display: flex; flex-direction: column; gap: 2px; }
.resume-banner-text strong { font-size: 15px; color: var(--text, #e6edf3); }
.resume-banner-text span { font-size: 13px; color: var(--text2, #8b949e); }
.resume-banner-actions { display: flex; gap: 10px; align-items: center; }

/* ── Design tokens ──────────────────────────────────────────────────── */
:root {
  --bg:         #0d1117;
  --bg2:        #161b22;
  --bg3:        #1c2430;
  --bg4:        #21262d;
  --border:     #30363d;
  --border2:    #3d4451;
  --text:       #e6edf3;
  --text2:      #8b949e;                 /* 6.15:1 on --bg — WCAG AA */
  --text3:      #808892;                 /* UX-POLISH: was #6b737d (3.94:1, failed AA) → 5.28:1 */
  --amber:      #f0a500;
  --amber2:     #ffc53d;
  --amber-dim:  rgba(240,165,0,0.12);
  --teal:       #39c5cf;
  --teal-dim:   rgba(57,197,207,0.1);
  --red:        #f85149;
  --red-dim:    rgba(248,81,73,0.1);
  --green:      #3fb950;
  --green-dim:  rgba(63,185,80,0.1);
  --blue:       #58a6ff;
  --blue-dim:   rgba(88,166,255,0.1);
  --radius:     12px;
  --radius-sm:  8px;
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { color: inherit; text-decoration: none; }

/* ── Base ───────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(240,165,0,0.04) 0%, transparent 50%),
    radial-gradient(circle at 85% 70%, rgba(57,197,207,0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ─────────────────────────────────────────────────────────── */
.wrapper { position: relative; z-index: 1; max-width: 1100px; margin: 0 auto; padding: 0 24px 80px; }

/* ── Shared nav ─────────────────────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.nav-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  color: var(--text);
}
.nav-logo span { color: var(--amber); }
.nav-back {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  transition: color 0.15s;
  cursor: pointer;
  background: none;
  border: none;
  font-family: 'Nunito', sans-serif;
}
.nav-back:hover { color: var(--amber); }
.nav-actions-desktop { display: flex; gap: 8px; align-items: center; }
@media (max-width: 700px) { .nav-actions-desktop { display: none; } }

/* ── Eyebrow label ──────────────────────────────────────────────────── */
.eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--amber);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ── Tabs ───────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 28px;
  overflow-x: auto;
}
.tab-btn {
  flex: 1;
  min-width: 120px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); background: var(--bg3); }
.tab-btn.active { background: var(--amber); color: #0d1117; }
.tab-icon { font-size: 15px; }

/* ── Panels ─────────────────────────────────────────────────────────── */
.panel { display: none; animation: fadeIn 0.3s ease; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge-amber  { background: var(--amber-dim);  color: var(--amber);  border: 1px solid rgba(240,165,0,0.3); }
.badge-teal   { background: var(--teal-dim);   color: var(--teal);   border: 1px solid rgba(57,197,207,0.3); }
.badge-blue   { background: var(--blue-dim);   color: var(--blue);   border: 1px solid rgba(88,166,255,0.3); }
.badge-green  { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(63,185,80,0.3); }
.badge-red    { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(248,81,73,0.3); }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}
.btn-primary { background: var(--amber); color: #0d1117; }
.btn-primary:hover { background: var(--amber2); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-dim); }

/* ── Tables ─────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--bg);
  color: var(--text2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  line-height: 1.5;
}
.data-table td:first-child { color: var(--text); font-weight: 600; }
.data-table tr:hover td { background: var(--bg3); }
.mono { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--amber); }

/* ── Study guide ─────────────────────────────────────────────────────── */
.study-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  align-items: start;
}
@media(max-width:700px) { .study-grid { grid-template-columns: 1fr; } }

.toc-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 76px;
}
.toc-title {
  font-size: 10px;
  font-weight: 800;
  color: var(--text3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.toc-item {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  margin-bottom: 2px;
}
.toc-item:hover { background: var(--bg3); color: var(--text); }
.toc-item.active { background: var(--amber-dim); color: var(--amber); border-left: 3px solid var(--amber); padding-left: 13px; }

.content-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; touch-action: pan-y; min-width: 0; overflow-wrap: break-word; }
.content-section { display: none; }
.content-section.active { display: block; animation: fadeIn 0.25s ease; }
.content-section h2 { font-family: 'DM Serif Display', serif; font-size: 26px; color: var(--text); margin-bottom: 16px; }
.section-body { font-size: 15px; line-height: 1.75; color: var(--text2); margin-bottom: 20px; }

.key-point {
  background: var(--amber-dim);
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 16px 0;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}

/* ── Flashcards ──────────────────────────────────────────────────────── */
.fc-controls { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; flex-wrap: wrap; }
.filter-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--amber); color: var(--amber); }
.filter-btn.active { background: var(--amber); border-color: var(--amber); color: #0d1117; }
/* UX-15: meet WCAG 2.5.5 44px min touch target on mobile */
@media (max-width: 700px) {
  .filter-btn {
    padding: 10px 16px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

.fc-stage { perspective: 1200px; margin-bottom: 24px; touch-action: pan-y; }
.fc-swipe-overlay {
  position: absolute; inset: 0; border-radius: var(--radius);
  opacity: 0; transition: opacity 0.08s; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; z-index: 2;
}
.fc-swipe-overlay.hint-easy { background: var(--green-dim); }
.fc-swipe-overlay.hint-hard { background: var(--red-dim); }
.fc-card-wrap {
  position: relative;
  min-height: 280px; /* height is set in JS after measuring face content */
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4,0,0.2,1);
  user-select: none;
}
.fc-card-wrap.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 36px 40px;
  text-align: center;
  overflow-y: auto;
}
.fc-front { background: var(--bg2); border: 1px solid var(--border2); }
.fc-back  { background: var(--bg3); border: 1px solid var(--amber); transform: rotateY(180deg); }

.fc-tag {
  position: absolute;
  top: 16px; left: 16px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.tag-definition { background: var(--teal-dim);  color: var(--teal); }
.tag-formula    { background: var(--amber-dim); color: var(--amber); }
.tag-concept    { background: var(--blue-dim);  color: var(--blue); }

.fc-counter { position: absolute; top: 16px; right: 16px; font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); }
.fc-question { font-family: 'DM Serif Display', serif; font-size: clamp(18px,3vw,24px); color: var(--text); line-height: 1.4; margin-bottom: 12px; }
.fc-hint     { font-size: 12px; color: var(--text3); margin-top: 16px; }
.fc-answer   { font-size: 15px; color: var(--text); line-height: 1.65; }
.fc-formula-display { font-family: 'DM Mono', monospace; font-size: 18px; color: var(--amber); background: var(--bg); padding: 8px 20px; border-radius: var(--radius-sm); margin: 12px 0; }

.fc-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 20px; }
.nav-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.nav-btn:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-dim); }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.fc-index { font-family: 'DM Mono', monospace; font-size: 13px; color: var(--text2); min-width: 60px; text-align: center; }

.fc-rating { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; }
.rate-btn {
  padding: 8px 22px;
  border-radius: 20px;
  border: 1px solid;
  font-size: 13px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; gap: 6px;
}
.rate-easy { border-color: rgba(63,185,80,0.4); color: var(--green); background: var(--green-dim); }
.rate-easy:hover { background: var(--green); color: #0d1117; }
.rate-hard { border-color: rgba(248,81,73,0.4); color: var(--red); background: var(--red-dim); }
.rate-hard:hover { background: var(--red); color: #fff; }

.fc-dots { display: flex; justify-content: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.fc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bg4); cursor: pointer; transition: all 0.15s; }
.fc-dot.seen   { background: var(--border2); }
.fc-dot.easy   { background: var(--green); }
.fc-dot.hard   { background: var(--red); }
.fc-dot.current { background: var(--amber); transform: scale(1.4); }

/* ── Practice paper ──────────────────────────────────────────────────── */
.paper-header {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.paper-meta { font-size: 13px; color: var(--text2); }
.paper-meta strong { color: var(--text); }
.score-display { font-family: 'DM Serif Display', serif; font-size: 28px; color: var(--amber); }
.score-label { font-size: 12px; color: var(--text2); text-align: right; }

.q-section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text3);
  margin: 28px 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.q-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.q-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}
.q-card.correct { border-color: var(--green); }
.q-card.wrong   { border-color: var(--red); }

.q-num {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 10px;
}
.q-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 16px;
}
/* Figure cropped from a past-paper PDF, shown above the options */
.quiz-q-image { margin: 0 0 16px; }
.quiz-q-image img {
  max-width: 100%;
  max-height: 340px;
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 6px;
}
.options-grid { display: grid; gap: 8px; }
.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  font-family: 'Nunito', sans-serif;
  width: 100%;
}
.option-btn:hover:not(:disabled) { border-color: var(--amber); color: var(--text); background: var(--amber-dim); }
.option-btn .opt-letter {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg4);
  font-size: 11px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  font-family: 'DM Mono', monospace;
}
.option-btn.selected { border-color: var(--amber); background: var(--amber-dim); color: var(--text); }
.option-btn.selected .opt-letter { background: var(--amber); color: #0d1117; }
.option-btn.correct-ans { border-color: var(--green); background: var(--green-dim); color: var(--text); }
.option-btn.correct-ans .opt-letter { background: var(--green); color: #0d1117; }
.option-btn.wrong-ans { border-color: var(--red); background: var(--red-dim); }

.explanation {
  display: none;
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--bg3);
  border-left: 3px solid var(--green);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}
.explanation.show { display: block; animation: fadeIn 0.25s ease; }

/* ── Assertion–Reason layout ──────────────────────────────────────────── */
.ar-blocks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.ar-block {
  display: flex;
  gap: 8px;
  font-size: 14px;
  line-height: 1.65;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.ar-label {
  font-weight: 700;
  color: var(--text2);
  white-space: nowrap;
  min-width: 110px;
  flex-shrink: 0;
}
.ar-text { color: var(--text); }

/* ── Match the Column layout ──────────────────────────────────────────── */
.match-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 600px) {
  .match-columns { grid-template-columns: 1fr; }
}
.match-col {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.match-col-header {
  font-weight: 700;
  font-size: 12px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.match-col-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  border-bottom: 1px solid var(--border);
}
.match-col-item:last-child { border-bottom: none; }

/* ── Integer input (Task 20) ──────────────────────────────────────────── */
.integer-input-wrap {
  margin-bottom: 16px;
}
.integer-input {
  width: 160px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg3);
  color: var(--text);
  font-size: 18px;
  font-family: 'DM Mono', monospace;
  outline: none;
  transition: border-color 0.15s;
}
.integer-input:focus { border-color: var(--teal); }
.integer-answer-display {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  border: 2px solid transparent;
}
.integer-answer-display.correct-ans {
  background: var(--green-dim, #dcfce7);
  border-color: var(--green);
  color: var(--green);
}
.integer-answer-display.wrong-ans {
  background: var(--red-dim, #fee2e2);
  border-color: var(--red, #f87171);
  color: var(--red, #f87171);
}

.sa-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 14px; }
.sa-marks { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); margin-bottom: 8px; }
.sa-q { font-size: 15px; color: var(--text); margin-bottom: 14px; line-height: 1.6; }
.reveal-btn {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 13px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.reveal-btn:hover { border-color: var(--teal); color: var(--teal); }
.model-answer {
  display: none;
  margin-top: 14px;
  padding: 16px 18px;
  background: var(--bg3);
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px;
  color: var(--text2);
  line-height: 1.7;
}
.model-answer.show { display: block; animation: fadeIn 0.25s ease; }
.model-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--teal); margin-bottom: 8px; }

/* ── Formula sheet ───────────────────────────────────────────────────── */
.formula-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.formula-card-header { padding: 12px 20px; background: var(--bg); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text3); border-bottom: 1px solid var(--border); }

/* ── Loading / error states ─────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 16px;
  color: var(--text2);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 12px;
  color: var(--red);
  text-align: center;
}

/* ── Empty state (UX-STATES) ──────────────────────────────────────────────
   One shared pattern for "nothing here yet": icon + line + optional action.
   Usage:
     <div class="empty-state">
       <div class="empty-state-icon">📭</div>
       <p class="empty-state-line">No papers uploaded yet.</p>
       <a class="btn btn-primary empty-state-action" href="...">Browse chapters</a>
     </div>
   `.empty-state--inline` drops the tall min-height for use inside a card. */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  gap: 10px;
  text-align: center;
  padding: 24px;
}
.empty-state--inline { min-height: 0; padding: 20px; }
.empty-state-icon {
  font-size: 34px;
  line-height: 1;
  opacity: 0.85;
}
.empty-state-line {
  font-size: 14px;
  color: var(--text2);
  max-width: 340px;
  line-height: 1.5;
}
.empty-state-action { margin-top: 6px; }

/* ── Back to top (UX-POLISH) ──────────────────────────────────────────────
   Floating button for long scrolling lists (chapter browser). Hidden until
   the page is scrolled; JS toggles `.visible`. Sits above the app bottom-nav. */
.back-to-top {
  position: fixed;
  right: 18px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, border-color 0.15s, color 0.15s;
  z-index: 40;
}
.back-to-top:hover { border-color: var(--amber); color: var(--amber); }
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
/* Lift above the bottom nav when running as the installed app */
body.app .back-to-top { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }

/* ── User menu dropdown ──────────────────────────────────────────────── */
.user-menu-wrap { position: relative; }
.user-avatar-btn {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 12px 5px 6px; cursor: pointer; color: var(--text2);
  font-family: 'Nunito', sans-serif; transition: border-color 0.2s, color 0.2s;
}
.user-avatar-btn:hover { border-color: var(--amber); color: var(--text); }
.user-photo { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.user-initial {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--amber-dim); color: var(--amber);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-display-name {
  font-size: 13px; font-weight: 600;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px; background: var(--bg2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 200; overflow: hidden;
}
.dropdown-header { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.dropdown-header strong { display: block; font-size: 14px; color: var(--text); margin-bottom: 2px; }
.dropdown-header span { font-size: 12px; color: var(--text2); }
.dropdown-item {
  display: block; width: 100%; padding: 10px 16px; text-align: left;
  font-size: 13px; font-family: 'Nunito', sans-serif;
  color: var(--text2); background: none; border: none; cursor: pointer;
  transition: background 0.15s, color 0.15s; text-decoration: none;
}
.dropdown-item:hover { background: var(--bg3); color: var(--text); }
.dropdown-signout { color: var(--red); }
.dropdown-signout:hover { background: var(--red-dim); color: var(--red); }
@media (max-width: 600px) { .user-display-name { display: none; } }

/* ── Mission page ────────────────────────────────────────────────────── */
.mission-header {
  display: flex; align-items: center; gap: 16px;
  padding: 24px 0 0; margin-bottom: 8px;
}
.mission-prog-bar {
  flex: 1; height: 8px; background: var(--bg3);
  border-radius: 4px; overflow: hidden;
}
.mission-prog-fill {
  height: 100%; background: var(--amber);
  border-radius: 4px; transition: width 0.4s ease;
}
.mission-xp-counter {
  font-family: 'DM Mono', monospace; font-size: 13px;
  color: var(--amber); white-space: nowrap; min-width: 64px; text-align: right;
}
.mission-item-wrap { max-width: 640px; margin: 28px auto 0; }
/* UX-MISSION-META: stacked meta block — the old single flex row (subject·title
   + reason chip + bonus badge + counter) squished or clipped on phone widths.
   Row 1: subject + counter (peers, both small mono); row 2: chapter title on
   its own line with ellipsis; row 3: reason chips, wrapping, omitted when
   empty. Bonus is a counter STATE (amber ✨ counter), not a "½ XP" badge —
   halved XP shows on the rating buttons where it's earned. */
.mission-item-meta { margin-bottom: 16px; }
.mission-meta-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}
.mission-item-tag {
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: var(--text3); letter-spacing: 0.08em; text-transform: uppercase;
}
.mission-item-num {
  font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3);
  white-space: nowrap;
}
.mission-item-num--bonus { color: var(--amber); }
.mission-item-title {
  font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 700;
  color: var(--text); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mission-meta-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
/* DAILY-QUEUE / UX-ADAPTIVE-WHY: per-item "why is this here?" chip.
   Bumped from 10px DM Mono (effectively invisible) to a readable 12px Nunito
   so students actually see why the queue chose each item. */
.mission-reason {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 700;
  letter-spacing: 0.01em;
  padding: 3px 10px; border-radius: 11px; white-space: nowrap;
}
.mission-reason-icon { font-size: 12px; line-height: 1; }
.mission-reason.reason-overdue { color: var(--red, #f85149); background: rgba(248,81,73,0.12); }
.mission-reason.reason-due     { color: var(--amber);        background: var(--amber-dim); }
.mission-reason.reason-weak    { color: #d29922;             background: rgba(210,153,34,0.12); }
/* returning-lapsed-user backlog reassurance banner */
.mission-backlog-note {
  font-family: 'Nunito', sans-serif; font-size: 12.5px; color: var(--text2);
  background: var(--bg2); border: 1px solid var(--border, #30363d);
  border-radius: 8px; padding: 9px 13px; margin: 0 0 16px;
}
.mission-fc-wrap .fc-hint { display: block; }
.mission-fc-wrap.rating-shown .fc-hint { display: none; }
.mission-fc-wrap .fc-rating { display: none; }
.mission-fc-wrap.rating-shown .fc-rating { display: flex; }
.mission-next-btn { display: block; margin: 24px auto 0; }
.mission-mcq-next { display: block; margin: 20px auto 0; }
.mission-complete {
  max-width: 560px; margin: 60px auto; text-align: center; padding: 0 24px;
}
.mission-complete h2 {
  font-family: 'DM Serif Display', serif; font-size: 40px;
  color: var(--amber); margin-bottom: 8px; letter-spacing: -0.5px;
}
.mission-complete p { font-size: 16px; color: var(--text2); margin-bottom: 36px; }
.mission-complete-stats {
  display: flex; justify-content: center; gap: 40px; margin: 32px 0 40px;
}
.mission-stat { text-align: center; }
.mission-stat-val {
  font-family: 'DM Mono', monospace; font-size: 32px; color: var(--text);
  line-height: 1;
}
.mission-stat-lbl { font-size: 12px; color: var(--text2); margin-top: 6px; }
.mission-complete-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
/* UX-18: Narrow screen fix — 320px phones (Galaxy A budget series) */
@media (max-width: 400px) {
  .mission-complete-stats { gap: 20px; }
  .mission-stat-val { font-size: 26px; }
}
/* Mission formula card */
.mission-formula-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 16px;
}
.mission-formula-name {
  font-family: 'DM Mono', monospace; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); margin-bottom: 12px;
}
.mission-formula-eq {
  font-family: 'DM Mono', monospace; font-size: 22px;
  color: var(--amber); text-align: center; padding: 16px 0;
}
.mission-formula-reveal {
  border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px;
}
.mission-formula-meaning { font-size: 14px; color: var(--text); line-height: 1.6; margin-bottom: 8px; }
.mission-formula-vars { font-size: 12px; color: var(--text2); font-family: 'DM Mono', monospace; }
.mission-formula-unit { font-size: 12px; color: var(--text3); margin-top: 6px; }
.mission-formula-actions { text-align: center; margin-top: 16px; }
.mission-formula-rate { text-align: center; margin-top: 16px; }
/* Mission reaction card */
.mission-reaction-wrap {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 16px;
}
.mission-reaction-name {
  font-family: 'DM Mono', monospace; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text3); margin-bottom: 12px;
}
.mission-reaction-eq {
  font-family: 'DM Mono', monospace; font-size: 18px;
  color: var(--text); text-align: center; padding: 16px 0;
}
.mission-reaction-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.mission-reaction-type {
  font-family: 'DM Mono', monospace; font-size: 11px;
  background: var(--amber-dim); color: var(--amber);
  padding: 2px 8px; border-radius: 10px; text-transform: uppercase;
}
.mission-reaction-conditions { font-size: 12px; color: var(--text2); }

/* ── Badge toast ─────────────────────────────────────────────────────── */
.badge-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg2);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  transform: translateY(calc(100% + 32px));
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
  z-index: 1000;
  max-width: 300px;
  pointer-events: none;
}
.badge-toast.show { transform: translateY(0); }
/* UX-SAFEAREA: on narrow viewports + the app the 60px bottom-nav (plus gesture
   home-indicator inset) occupies the bottom edge — a bare 24px parked the toast
   on top of the Home/Feed/Profile tabs (z-index 1000 > nav's 200). Mirrors the
   .back-to-top body.app clearance. */
@media (max-width: 700px) {
  .badge-toast { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); right: 16px; }
}
body.app .badge-toast { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); right: 16px; }
.badge-toast-icon { font-size: 32px; line-height: 1; flex-shrink: 0; }
.badge-toast-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--amber);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.badge-toast-name { font-weight: 800; font-size: 15px; color: var(--text); margin-bottom: 2px; }
.badge-toast-desc { font-size: 12px; color: var(--text2); }

/* ── Mobile UX — UX-1 quick wins ────────────────────────────────────────
   All @media rules apply to any narrow viewport (mobile web + Capacitor app).
   The body.app rule is Capacitor-only — safe-area values are 0 on web so
   gating keeps intent explicit.
   ─────────────────────────────────────────────────────────────────────── */

/* 1. Sticky timer topbar — timer never scrolls off-screen during exam */
@media (max-width: 700px) {
  .quiz-topbar {
    position: sticky;
    /* UX-SAFEAREA: nav height is 56px + status-bar inset in the app
       (body.app .site-nav padding-top) — a bare 56px pinned the exam timer
       partially under the nav while scrolling. env() = 0 on web. */
    top: calc(56px + env(safe-area-inset-top, 0px));
    z-index: 90;
    background: var(--bg);
    padding-top: 8px;
    padding-bottom: 4px;
  }
}

/* 2. Tab overflow fade gradient — only rendered when tabs actually overflow
   (.is-overflowing class is toggled by updateTabsOverflowIndicator() in study.html) */
@media (max-width: 700px) {
  .tabs { position: relative; }
  .tabs.is-overflowing::after {
    content: '';
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 40px;
    background: linear-gradient(to right, transparent, var(--bg2));
    pointer-events: none;
    border-radius: 0 var(--radius) var(--radius) 0;
  }
}

/* 3. Q-nav buttons — 34px → 40px touch target (WCAG min 44px; 40px is a
   meaningful improvement without blowing the grid layout) */
@media (max-width: 700px) {
  .q-nav-btn { width: 40px; height: 40px; }
}

/* UX-14: enhanced q-nav — subject groups, summary bar, filter chips, collapse */
.q-nav-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }

.q-nav-summary {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text3);
  letter-spacing: 0.02em;
}

.q-nav-filters {
  display: flex;
  gap: 6px;
}
.q-nav-filter {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.q-nav-filter:hover { border-color: var(--amber); color: var(--amber); }
.q-nav-filter.active { background: var(--amber-dim); border-color: rgba(240,165,0,0.4); color: var(--amber); }

.q-nav-subject-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 6px 0 4px;
}
.q-nav-subject-label:first-child { margin-top: 0; }
.q-nav-subject-count {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--text2);
}
.q-nav-all-done {
  font-size: 13px;
  color: var(--green);
  padding: 6px 0;
}

/* Collapse behaviour — grid hidden on mobile until toggle opens it */
.q-nav-collapsible { display: flex; flex-direction: column; gap: 0; }
.q-nav-toggle { display: none; }

@media (max-width: 700px) {
  .q-nav-collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1);
  }
  .q-nav-collapsible.open { max-height: 600px; }
  .q-nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text2);
    font-size: 12px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
  }
  .q-nav-toggle:hover { border-color: var(--amber); color: var(--amber); }
}

/* 4. Reduce over-generous padding on mobile:
   - content-card: 32px → 20px/16px (study guide sections)
   - chapter/mock/quiz headers: 36px top → 16px */
@media (max-width: 700px) {
  .content-card { padding: 20px 16px; }
  .chapter-header { padding: 16px 0 12px; }
  .mock-header    { padding: 16px 0 12px; }
  .quiz-header    { padding: 16px 0 12px; }
}

/* 5. Mermaid SVG overflow — complex diagrams clip without this */
.mermaid svg { max-width: 100%; height: auto; }

/* 6. Practice paper header — stack score below meta on narrow screens */
@media (max-width: 600px) {
  .paper-header { flex-direction: column; align-items: flex-start; }
}

/* ── Confirmation bottom sheet (UX-5) ───────────────────────────────────
   Used by the exam submit flow in quiz.js. Works on web and app alike —
   replaces the native window.confirm() dialog which looks poor on Android.
   ─────────────────────────────────────────────────────────────────────── */

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0);
  transition: background 0.25s ease;
  display: flex;
  align-items: flex-end;
}
.confirm-overlay.show { background: rgba(0, 0, 0, 0.65); }

.confirm-sheet {
  width: 100%;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 28px 24px calc(24px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.confirm-overlay.show .confirm-sheet { transform: translateY(0); }

.confirm-sheet-icon  { font-size: 36px; margin-bottom: 14px; }
.confirm-sheet-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.2;
}
.confirm-sheet-body  {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 28px;
}
/* Actions stack vertically so the two buttons are far apart — prevents
   accidental double-tap ending a 3-hour exam */
.confirm-sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.confirm-sheet-actions .btn {
  width: 100%;
  justify-content: center;
  padding: 14px 20px;
  font-size: 15px;
}
.confirm-btn-cancel  { /* inherits btn btn-ghost */ }
.confirm-btn-submit  { background: var(--red) !important; color: #fff !important; border-color: var(--red) !important; }
.confirm-btn-submit:hover { opacity: 0.88; }

/* ── Mobile UX — UX-2/UX-13 bottom navigation ────────────────────────────
   Shown on all narrow viewports (≤700px) so mobile web users get the same
   thumb-zone nav as the Capacitor app. body.app overrides add safe-area
   insets for notched Android devices (Capacitor WebView only).
   ─────────────────────────────────────────────────────────────────────── */

.bottom-nav {
  display: none; /* hidden on wide screens */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  z-index: 200;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  align-items: stretch;
}

/* Show on all narrow viewports — mobile web + Capacitor app */
@media (max-width: 700px) { .bottom-nav { display: flex; } }

/* Capacitor: safe-area inset keeps content above the home indicator */
body.app .bottom-nav { display: flex; }

/* Push wrapper content above the nav bar on narrow viewports */
@media (max-width: 700px) {
  .wrapper { padding-bottom: calc(60px + 16px); }
}
/* Capacitor override: use real safe-area value instead of fixed 16px */
body.app .wrapper {
  padding-bottom: calc(60px + env(safe-area-inset-bottom));
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text3);
  font-size: 10px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  letter-spacing: 0.03em;
  transition: color 0.15s;
  padding-bottom: env(safe-area-inset-bottom);
}
.bnav-item:hover  { color: var(--text2); }
.bnav-item.active { color: var(--amber); }

.bnav-icon  { font-size: 20px; line-height: 1; position: relative; }
.bnav-label { font-size: 10px; }

/* UX-POLISH: bottom-nav notification badge (unfinished mission / new badge) */
.bnav-badge {
  position: absolute;
  top: -4px;
  right: -10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg2);
  pointer-events: none;
}
/* Countless variant — a plain dot (e.g. "mission not started yet") */
.bnav-badge--dot {
  min-width: 9px;
  width: 9px;
  height: 9px;
  padding: 0;
  top: -2px;
  right: -6px;
}

/* 7. Safe-area-inset top padding for notched/punch-hole Android devices.
   Gated on body.app (set by _applyPlatformClass in auth.js) — only applies
   inside the Capacitor WebView where browser chrome is absent. */
body.app .site-nav { padding-top: env(safe-area-inset-top); }

/* MB-4: safe-area insets for pre-auth pages (login / onboarding).
   body.app is set by _applyPlatformClass() which runs when auth.js is imported.
   These pages have no site-nav so we pad the full-screen wrapper directly. */
body.app .login-wrap,
body.app .ob-wrap {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── UX-3: TOC Drawer ───────────────────────────────────────────────── */
/* Hide sidebar TOC on narrow screens — the drawer (opened from the
   section-nav counter pill in study.html's sticky footer) replaces it.
   UX-SECNAV-2 deleted the old floating .toc-fab trigger: it overlapped the
   footer's Next button and needed per-element offset patches (UX-11 badge
   toast, UX-13 bottom nav), all now obsolete.                            */
@media (max-width: 700px) { .toc-card { display: none; } }

/* Drawer overlay — covers the whole screen, dims the backdrop.         */
.toc-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0);
  transition: background 0.25s ease;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}
.toc-drawer-overlay.show { background: rgba(0,0,0,0.65); pointer-events: all; }

/* Slide-up drawer panel.                                               */
.toc-drawer {
  width: 100%;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32,0.72,0,1);
  max-height: 70vh;
  overflow-y: auto;
}
.toc-drawer-overlay.show .toc-drawer { transform: translateY(0); }

.toc-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  color: var(--text1);
  font-size: 15px;
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 1;
}
.toc-drawer-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text3);
  padding: 4px 8px;
  line-height: 1;
}
.toc-drawer-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 20px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  font-size: 14px;
  color: var(--text2);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: background 0.1s, color 0.1s;
}
.toc-drawer-btn:active { background: var(--bg3); }
.toc-drawer-btn.active { color: var(--amber); font-weight: 700; background: rgba(243,156,18,0.07); }

/* ── Explain Differently (Task 29) ─────────────────────────────────── */
.explain-trigger { margin: 12px 0 4px; }

.explain-btn {
  background: none;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  padding: 5px 12px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.explain-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-dim);
}

.explain-panel {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius-sm);
  margin: 8px 0 16px;
  padding: 14px 16px 10px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  transition: opacity 0.2s;
}
.explain-panel.hidden { display: none; }

.explain-content { min-height: 20px; white-space: pre-wrap; word-break: break-word; }

/* Streaming cursor blink */
.explain-cursor::after {
  content: '▋';
  color: var(--teal);
  animation: explain-blink 0.8s step-end infinite;
}
@keyframes explain-blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

.explain-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.explain-footer.hidden { display: none; }

.explain-angle-btn {
  background: none;
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text2);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  padding: 3px 10px;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.explain-angle-btn:hover { border-color: var(--teal); color: var(--teal); }

.explain-angle-label {
  color: var(--text3);
  font-size: 12px;
  font-style: italic;
}

/* ── Wrong-Answer Hint (Task 30) ────────────────────────────────────── */
.hint-trigger { margin: 10px 0 4px; }

.hint-btn {
  background: none;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  padding: 4px 12px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.hint-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--amber-dim);
}
.hint-btn:disabled { opacity: 0.5; cursor: default; }

.hint-panel {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-sm);
  margin: 6px 0 14px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.hint-panel.hidden { display: none; }
.hint-content { white-space: pre-wrap; word-break: break-word; }

/* ── AI waiting panel (shared by solution.js / hint.js / explain.js) ── */
/* Shown while the Oracle VM processes a request (~30–40s). Displays a    */
/* timer + rotating educational content so the wait feels productive.     */
.ai-wait-panel {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg2);
}
.ai-wait-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text2);
}
.ai-wait-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--teal);
  min-width: 2.4ch;
}
.ai-wait-est { opacity: 0.65; }
.ai-wait-body { padding: 10px 14px 8px; }
.ai-wait-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-bottom: 5px;
}
.ai-wait-text {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 110px;
  overflow: hidden;
  /* Fade bottom edge when content overflows */
  -webkit-mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
}
.ai-wait-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 4px 12px 9px;
}
.ai-wait-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border2);
  transition: background 0.3s, transform 0.3s;
}
.ai-wait-dot.active {
  background: var(--teal);
  transform: scale(1.25);
}

/* ── Topic search results (Task 31, merged into the BROWSE CHAPTERS box) ── */
.search-status {
  font-size: 12px;
  color: var(--text3);
  margin: -8px 4px 8px;
}
.search-status:empty { display: none; }

.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.search-result-card {
  display: block;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.search-result-card:hover {
  background: var(--bg3);
  border-color: var(--teal);
}

.search-result-heading {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
}
/* Small badge marking results that came from the VM semantic tier */
.search-result-ai {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 4px;
  padding: 1px 4px;
  vertical-align: 2px;
}
.search-result-chapter {
  font-size: 12px;
  color: var(--teal);
  margin-bottom: 4px;
}
.search-result-snippet {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  /* Limit to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-no-results {
  color: var(--text3);
  font-size: 13px;
  padding: 8px 0;
}
.toc-drawer-btn[data-locked] { color: var(--text3); cursor: default; }
