/* ==========================================================================
   MBatch Learn · Premium Practice UI (mathplayground design)
   ========================================================================== */

/* -------------------- THEME TOKENS -------------------- */
:root {
  --bg: #ffffff;
  --ink: #0e1320;
  --muted: #667085;
  --ink-dim: #1f2937;

  --brand: #111827;
  --brand-ink: #ffffff;
  --accent: #2b7cff;
  --accent-ink: #ffffff;

  --ok: #16a34a;
  --bad: #e11d48;
  --warn: #f59e0b;

  --r-xs: 10px; --r-sm: 12px; --r-md: 14px; --r-lg: 16px; --r-xl: 20px; --r-2xl: 24px;
  --sh-soft: 0 8px 24px rgba(2, 8, 23, .06);
  --sh-float: 0 20px 60px rgba(2, 8, 23, .10);

  --chip: #f6f9ff;
  --chip2: #f4f6ff;

  --line: #e6eaf2;
  --line-strong: #d7ddea;

  --grad: linear-gradient(180deg, #3b82f6 0%, #2b7cff 60%, #1f63d8 100%);

  --fast: 120ms;
  --med: 220ms;
  --slow: 420ms;

  --content-w: 980px;

  /* ===== DESKTOP REDESIGN: Fluid Typography ===== */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.625rem);
  --text-2xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --text-3xl: clamp(1.875rem, 1.6rem + 1.25vw, 2.5rem);

  /* ===== DESKTOP REDESIGN: 8px Spacing Rhythm ===== */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* ===== DESKTOP REDESIGN: Fluid Gaps ===== */
  --gap-sm: clamp(0.5rem, 0.4rem + 0.5vw, 1rem);
  --gap-md: clamp(1rem, 0.8rem + 1vw, 1.5rem);
  --gap-lg: clamp(1.5rem, 1.2rem + 1.5vw, 2.5rem);
  --gap-xl: clamp(2rem, 1.5rem + 2vw, 3.5rem);

  /* ===== DESKTOP REDESIGN: Container System ===== */
  --container-max: 1800px;
  --content-w-fluid: clamp(980px, 88vw, var(--container-max));

  /* Reader variables */
  --q-scale: 1;
  --img-scale: 1;
  --reader-font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  /* Card skins */
  --card-bg: linear-gradient(180deg, color-mix(in oklab, var(--bg) 96%, #ffffff), var(--bg));
  --card-border-gradient: linear-gradient(180deg, var(--line-strong), var(--line-strong));
  --card-radius: var(--r-xl);
  --card-shadow: var(--sh-soft);
}

.theme-dark {
  --bg: #0b1220;
  --ink: #e6ecff;
  --muted: #9aa6bf;
  --ink-dim: #cdd6ee;

  --brand: #e6ecff;
  --brand-ink: #0b1220;
  --accent: #8ab4ff;
  --accent-ink: #0b1220;

  --chip: #0f172a;
  --chip2: #0e162a;

  --line: #172033;
  --line-strong: #1b2740;

  --sh-soft: 0 8px 24px rgba(0,0,0,.35);
  --sh-float: 0 20px 60px rgba(0,0,0,.45);
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.65 Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

[hidden] { display: none !important; }

::selection { background: #dbe7ff; color: #0b1220; }
.theme-dark ::selection { background: #19325e; color: #e6ecff; }

/* Scrollbar */
*::-webkit-scrollbar { height: 10px; width: 10px; }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c5d6ff, #a8c0ff);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.theme-dark *::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #31456d, #3e5b97);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

:focus-visible {
  outline: 3px solid #94bfff;
  outline-offset: 2px;
  border-radius: 10px;
}

/* -------------------- HEADER -------------------- */
.header-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 2px solid #ffd400;
  background: var(--bg);
  backdrop-filter: saturate(120%) blur(6px);
  min-height: 56px;
  max-height: 56px;
}

/* Desktop header scaling */
@media (min-width: 1024px) {
  .header-bar {
    min-height: 64px;
    max-height: 64px;
    padding: var(--space-2) var(--space-6);
    gap: var(--space-4);
  }
}
@media (min-width: 1440px) {
  .header-bar {
    min-height: 68px;
    max-height: 68px;
    padding: var(--space-3) var(--space-8);
  }
}

.header-bar.is-scrolled {
  box-shadow: var(--sh-soft);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Hide back button */
#btnBack {
  display: none;
}

.header-title-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.set-type-badge {
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent);
  line-height: 1;
}

.header-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 600px) {
  .header-title {
    font-size: 14px;
  }
}
@media (min-width: 1024px) {
  .header-title {
    font-size: var(--text-base);
    max-width: 400px;
  }
}
@media (min-width: 1440px) {
  .header-title {
    font-size: var(--text-lg);
    max-width: 500px;
  }
}

/* Hide center progress on mobile */
.header-center {
  display: none;
}

@media (min-width: 768px) {
  .header-center {
    display: block;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
}

.progress-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--chip);
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
}

.timer-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: linear-gradient(135deg, color-mix(in oklab, var(--ok) 15%, var(--chip)), color-mix(in oklab, var(--ok) 8%, var(--chip)));
  border: 1.5px solid var(--ok);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ok);
  box-shadow: 0 2px 6px color-mix(in oklab, var(--ok) 15%, transparent);
}

.timer-chip svg {
  width: 14px;
  height: 14px;
  animation: pulse 2s ease-in-out infinite;
}

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

/* -------------------- ICON BUTTONS -------------------- */
.icon-btn {
  display: grid;
  place-items: center;
  inline-size: 30px;
  block-size: 30px;
  border-radius: 8px;
  border: 1.5px solid var(--line-strong);
  background: linear-gradient(135deg, var(--chip), var(--chip2));
  cursor: pointer;
  position: relative;
  color: var(--ink);
  transition: all var(--fast) ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 3px 8px color-mix(in oklab, var(--accent) 15%, transparent);
}

.icon-btn:active { transform: translateY(0); }

/* Bookmark button */
.icon-btn.bookmark-btn {
  border-color: var(--warn);
  color: var(--warn);
}

.icon-btn.bookmark-btn:hover {
  background: linear-gradient(135deg, color-mix(in oklab, var(--warn) 12%, var(--chip)), color-mix(in oklab, var(--warn) 6%, var(--chip)));
  box-shadow: 0 3px 8px color-mix(in oklab, var(--warn) 20%, transparent);
}

.icon-btn.bookmark-btn.saved {
  background: linear-gradient(135deg, var(--warn), color-mix(in oklab, var(--warn) 80%, #000));
  border-color: var(--warn);
  color: white;
  box-shadow: 0 3px 8px color-mix(in oklab, var(--warn) 25%, transparent);
}

/* Theme toggle */
.icon-btn#btnTheme {
  border-color: #8b5cf6;
  color: #8b5cf6;
}

.icon-btn#btnTheme:hover {
  background: linear-gradient(135deg, color-mix(in oklab, #8b5cf6 12%, var(--chip)), color-mix(in oklab, #8b5cf6 6%, var(--chip)));
  box-shadow: 0 3px 8px color-mix(in oklab, #8b5cf6 20%, transparent);
}

/* Avatar/Profile */
.avatar {
  display: block;
  inline-size: 30px;
  block-size: 30px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--accent);
  background: linear-gradient(135deg, var(--chip), var(--chip2));
  box-shadow: 0 2px 6px color-mix(in oklab, var(--accent) 15%, transparent);
  transition: all var(--fast) ease;
  cursor: pointer;
}

.avatar:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px color-mix(in oklab, var(--accent) 25%, transparent);
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* -------------------- TOPIC TABS -------------------- */
.topic-tabs {
  padding: 8px 14px;
  border-bottom: 1px dashed var(--line);
  background: linear-gradient(180deg, color-mix(in oklab, var(--bg) 80%, #f7f9ff), var(--bg));
}

.tabs-scroll {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 8px;
  border: 1px dashed color-mix(in oklab, var(--accent) 25%, transparent);
  border-radius: var(--r-md);
  background: color-mix(in oklab, var(--chip) 70%, transparent);
}

.topic-tab {
  min-width: 36px;
  height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  border: 2px solid var(--brand);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
  position: relative;
  white-space: nowrap;
  transition: transform var(--fast) ease, background var(--fast) ease, border-color var(--fast) ease, box-shadow var(--fast) ease;
}

.topic-tab:hover { transform: translateY(-1px); }
.topic-tab:active { transform: translateY(0); }

.topic-tab.active {
  transform: translateY(-1.5px);
  background: color-mix(in oklab, var(--accent) 10%, var(--chip));
  border-color: var(--accent);
  box-shadow: var(--sh-soft);
}

/* -------------------- BUBBLE NAV -------------------- */
.qnav-sticky {
  position: sticky;
  top: 56px;
  z-index: 55;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 4px 8px;
}

/* Section bar (squares for topics) - inline with nav on mobile */
.section-bar {
  display: none;
  gap: 4px;
  flex-shrink: 0;
}

@media (max-width: 899px) {
  .section-bar { display: flex; }

  /* Merge section bar and nav row into single line */
  .qnav-sticky {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
  }

  .nav-row {
    flex: 1;
    min-width: 0;
  }
}

.section-square {
  min-width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid var(--brand);
  background: transparent;
  font-weight: 800;
  font-size: 10px;
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  transition: transform var(--fast) ease, background var(--fast) ease, border-color var(--fast) ease, box-shadow var(--fast) ease;
}

.section-square:hover { transform: translateY(-1px); }

.section-square.active {
  background: color-mix(in oklab, var(--accent) 15%, transparent);
  border-color: var(--accent);
  box-shadow: var(--sh-soft);
}

.section-square .section-name {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.section-square .section-count {
  display: none;
}

/* Topic-colored section squares */
.section-square[data-topic="1"] { border-color: #3b82f6; }
.section-square[data-topic="1"].active { background: color-mix(in oklab, #3b82f6 15%, transparent); border-color: #3b82f6; }
.section-square[data-topic="2"] { border-color: #10b981; }
.section-square[data-topic="2"].active { background: color-mix(in oklab, #10b981 15%, transparent); border-color: #10b981; }
.section-square[data-topic="3"] { border-color: #f59e0b; }
.section-square[data-topic="3"].active { background: color-mix(in oklab, #f59e0b 15%, transparent); border-color: #f59e0b; }
.section-square[data-topic="4"] { border-color: #8b5cf6; }
.section-square[data-topic="4"].active { background: color-mix(in oklab, #8b5cf6 15%, transparent); border-color: #8b5cf6; }

/* Nav row (arrows + circles) */
.nav-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
}

@media (max-width: 899px) {
  .nav-arrow {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
  }
}

.nav-circles {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.nav-circles::-webkit-scrollbar {
  display: none;
}

.nbtn {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid var(--brand);
  background: transparent;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: transform var(--fast) ease, background var(--fast) ease, border-color var(--fast) ease, box-shadow var(--fast) ease;
}

.nbtn:hover { transform: translateY(-1px); }

.nbtn.on {
  background: var(--ok);
  border-color: var(--ok);
  color: white;
  animation: currentPulse 1.5s ease-in-out infinite;
  z-index: 2;
}

@keyframes currentPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 color-mix(in oklab, var(--ok) 50%, transparent);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 4px color-mix(in oklab, var(--ok) 25%, transparent);
    transform: scale(1.1);
  }
}

.nbtn.ok {
  background: color-mix(in oklab, var(--ok) 12%, transparent);
  border-color: var(--ok);
}

.nbtn.bad {
  background: color-mix(in oklab, var(--bad) 12%, transparent);
  border-color: var(--bad);
}

/* Locked state for sequential question navigation */
.nbtn.locked {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--chip);
  border-color: var(--line);
  color: var(--muted);
  position: relative;
}

.nbtn.locked:hover {
  transform: none;
}

.nbtn.locked::after {
  content: '';
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  background: var(--line-strong);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  color: var(--muted);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'%3E%3C/rect%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'%3E%3C/path%3E%3C/svg%3E");
  background-size: 7px 7px;
  background-position: center;
  background-repeat: no-repeat;
}

/* Group colored frames - use box-shadow for outer ring (no overflow issues) */
.nbtn[data-group="g1"] { box-shadow: 0 0 0 3px #8b5cf6; }
.nbtn[data-group="g2"] { box-shadow: 0 0 0 3px #ec4899; }
.nbtn[data-group="g3"] { box-shadow: 0 0 0 3px #06b6d4; }
.nbtn[data-group="g4"] { box-shadow: 0 0 0 3px #f97316; }
.nbtn[data-group="g5"] { box-shadow: 0 0 0 3px #84cc16; }
.nbtn[data-group="g6"] { box-shadow: 0 0 0 3px #a855f7; }
.nbtn[data-group="g7"] { box-shadow: 0 0 0 3px #14b8a6; }
.nbtn[data-group="g8"] { box-shadow: 0 0 0 3px #f43f5e; }

/* Preserve group color when button has other states */
.nbtn[data-group="g1"].on { box-shadow: 0 0 0 3px #8b5cf6, 0 0 0 5px var(--bg) inset, 0 0 0 7px var(--ok) inset; }
.nbtn[data-group="g2"].on { box-shadow: 0 0 0 3px #ec4899, 0 0 0 5px var(--bg) inset, 0 0 0 7px var(--ok) inset; }
.nbtn[data-group="g3"].on { box-shadow: 0 0 0 3px #06b6d4, 0 0 0 5px var(--bg) inset, 0 0 0 7px var(--ok) inset; }
.nbtn[data-group="g4"].on { box-shadow: 0 0 0 3px #f97316, 0 0 0 5px var(--bg) inset, 0 0 0 7px var(--ok) inset; }
.nbtn[data-group="g5"].on { box-shadow: 0 0 0 3px #84cc16, 0 0 0 5px var(--bg) inset, 0 0 0 7px var(--ok) inset; }
.nbtn[data-group="g6"].on { box-shadow: 0 0 0 3px #a855f7, 0 0 0 5px var(--bg) inset, 0 0 0 7px var(--ok) inset; }
.nbtn[data-group="g7"].on { box-shadow: 0 0 0 3px #14b8a6, 0 0 0 5px var(--bg) inset, 0 0 0 7px var(--ok) inset; }
.nbtn[data-group="g8"].on { box-shadow: 0 0 0 3px #f43f5e, 0 0 0 5px var(--bg) inset, 0 0 0 7px var(--ok) inset; }

/* Next section button */
.next-section-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 16px;
  margin-top: 4px;
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 12%, transparent), color-mix(in oklab, var(--accent) 6%, transparent));
  border: 2px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--fast) ease;
}

.next-section-btn:hover {
  transform: translateY(-1px);
  background: color-mix(in oklab, var(--accent) 18%, transparent);
  box-shadow: var(--sh-soft);
}

@media (min-width: 900px) {
  .next-section-btn { display: none !important; }
}

.nav-arrow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink);
  transition: transform var(--fast) ease, background var(--fast) ease;
}

.nav-arrow:hover { transform: translateY(-1px); }
.nav-arrow:disabled { opacity: 0.4; cursor: not-allowed; }

/* -------------------- MAIN LAYOUT -------------------- */
.main-content {
  width: 100%;
  max-width: var(--content-w);
  margin: var(--space-4) auto;
  padding: 0 var(--space-4);
}

/* Desktop container scaling */
@media (min-width: 1024px) {
  .main-content {
    width: 92%;
    max-width: var(--content-w-fluid);
    padding: 0 var(--space-6);
  }
}
@media (min-width: 1440px) {
  .main-content {
    width: 88%;
  }
}
@media (min-width: 1920px) {
  .main-content {
    width: 85%;
  }
}

.mp-stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Stopwatch */
.stopwatch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sw-face {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 60% 30%, #ffd40022 0 55%, transparent 56%);
}

.sw-hand {
  position: absolute;
  width: 2px;
  height: 12px;
  background: var(--brand);
  top: 6px;
  left: 50%;
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(25deg);
  transition: transform 0.2s linear;
}

.sw-knob {
  position: absolute;
  width: 7px;
  height: 6px;
  background: var(--brand);
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 2px;
}

.sw-time {
  font-weight: 900;
  font-size: 16px;
  letter-spacing: .3px;
}

.topic-tag {
  font-weight: 700;
  opacity: .85;
  color: var(--ink-dim);
}

.bookmark-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 2px solid var(--brand);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform var(--fast) ease, background var(--fast) ease, box-shadow var(--fast) ease;
}

.bookmark-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-soft);
}

/* Loading / Error / Access Denied */
.loading-state, .error-state, .access-denied-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 50vh;
  text-align: center;
  padding: 32px;
}

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

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

.error-icon, .locked-icon {
  color: var(--bad);
}

/* -------------------- SPLIT LAYOUT -------------------- */
.split-layout {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  width: 100%;
}

/* Desktop: 2-column grid for passage + question */
@media (min-width: 1024px) {
  .split-layout.has-passage {
    display: grid;
    grid-template-columns: minmax(360px, 38%) 1fr;
    gap: var(--gap-lg);
    align-items: start;
  }
}
@media (min-width: 1440px) {
  .split-layout.has-passage {
    grid-template-columns: minmax(400px, 35%) 1fr;
    gap: var(--gap-xl);
  }
}
@media (min-width: 1920px) {
  .split-layout.has-passage {
    grid-template-columns: minmax(450px, 32%) 1fr;
  }
}

/* -------------------- PASSAGE PANE -------------------- */
.passage-pane {
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--sh-soft);
}

@media (min-width: 1024px) {
  .passage-pane {
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 90px);
    display: flex;
    flex-direction: column;
    border-radius: var(--r-2xl);
  }
}
@media (min-width: 1440px) {
  .passage-pane {
    top: 80px;
    max-height: calc(100vh - 100px);
  }
}

.passage-header {
  display: none;
  padding: 12px 16px;
  background: linear-gradient(135deg, #fef9e7 0%, #fff8e1 100%);
  border-bottom: 2px solid #d4af37;
  align-items: center;
  justify-content: space-between;
}

.passage-label {
  font-weight: 600;
  color: #92400e;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.passage-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.passage-action-btn {
  display: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(212, 175, 55, 0.15);
  color: #92400e;
  cursor: pointer;
  transition: all 0.15s ease;
  align-items: center;
  justify-content: center;
}

.passage-action-btn:hover {
  background: #d4af37;
  color: #1a1a1a;
}

.passage-action-btn.active {
  background: #ef4444;
  color: white;
}

.toggle-passage-btn {
  display: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: rgba(212, 175, 55, 0.15);
  color: #92400e;
  cursor: pointer;
  transition: all 0.15s ease;
}

.passage-content {
  padding: 16px;
  font-size: 15px;
  line-height: 1.8;
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* Enable flex scrolling */
  text-align: justify;
  hyphens: auto;
  white-space: pre-wrap; /* Respect line breaks */
  word-wrap: break-word;
}

/* Ensure HTML elements in passage are styled properly */
.passage-content p {
  margin-bottom: 1em;
}

.passage-content br {
  display: block;
  content: "";
  margin-top: 0.5em;
}

/* Text highlighting/marking in passage */
.passage-content.highlight-mode {
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

.passage-content .user-highlight {
  background: linear-gradient(180deg, transparent 60%, rgba(239, 68, 68, 0.3) 60%);
  border-bottom: 2px solid #ef4444;
  padding-bottom: 1px;
}

.passage-content .user-underline {
  text-decoration: underline;
  text-decoration-color: #ef4444;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* Desktop passage pane with visible header */
@media (min-width: 1024px) {
  .passage-header {
    display: flex;
  }

  .passage-action-btn {
    display: flex;
  }
}

@media (max-width: 899px) {
  .toggle-passage-btn { display: block; }
  .passage-content { max-height: 300px; }
  .passage-pane.collapsed .passage-content { display: none; }
}

/* -------------------- QUESTION CARD -------------------- */
.question-card {
  position: relative;
  border-radius: var(--card-radius);
  border: 1.5px solid transparent;
  background: var(--card-bg) padding-box, var(--card-border-gradient) border-box;
  box-shadow: var(--card-shadow);
  color: var(--ink);
  container-type: inline-size;
  min-height: 300px;
}

.question-pane {
  position: relative;
  padding-left: 40px;
  padding-right: 40px;
}

@media (max-width: 899px) {
  .question-pane {
    padding-left: 0;
    padding-right: 0;
  }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Instruction banner */
.instruction-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 8%, transparent), transparent);
  border-bottom: 1px solid var(--line);
}

/* Brand logo in instruction banner - hidden by default, shown in focus mode */
.instruction-brand {
  display: none;
  flex-shrink: 0;
}

.instruction-brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

html.focus-mode .instruction-brand {
  display: block;
}

.instruction-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.instruction-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.instruction-text {
  font-size: 14px;
  color: var(--ink);
  line-height: 1.6;
  text-align: justify;
  hyphens: auto;
}

/* Hide topic/qtype badges */
.instruction-meta {
  display: none;
}

.topic-badge, .qtype-badge {
  display: none;
}

/* Mobile Passage (below instruction on mobile) */
.mobile-passage {
  display: none;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--chip) 40%, transparent);
}

@media (max-width: 899px) {
  .mobile-passage:not([hidden]) { display: block; }
  /* Hide desktop passage pane on mobile when mobile passage is visible */
  .split-layout.has-passage .passage-pane { display: none; }
}

.mobile-passage-header {
  display: none;
}

.mobile-passage-content {
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.75;
  max-height: 250px;
  overflow-y: auto;
  text-align: justify;
  hyphens: auto;
  white-space: pre-wrap; /* Respect line breaks */
  word-wrap: break-word;
}

.mobile-passage-content p {
  margin-bottom: 1em;
}

.mobile-passage.collapsed .mobile-passage-content {
  display: none;
}

.mobile-passage.collapsed .toggle-passage-btn svg {
  transform: rotate(180deg);
}

/* Question images */
.question-images {
  padding: 16px 18px 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  overflow: auto;
}

.question-images img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 350px;
  height: auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--sh-soft);
  transition: transform var(--med) ease, box-shadow var(--med) ease, filter var(--med) ease;
  cursor: zoom-in;
  object-fit: contain;
  transform: scale(var(--img-scale, 1));
  transform-origin: center top;
}

.question-images img:hover {
  transform: translateY(-2px) scale(calc(var(--img-scale, 1) * 1.02));
  box-shadow: var(--sh-float);
  filter: saturate(1.05);
}

/* Desktop: larger images */
@media (min-width: 1024px) {
  .question-images {
    padding: 20px 24px 8px;
  }

  .question-images img {
    max-height: 450px;
    border-radius: 12px;
  }
}

@media (min-width: 1440px) {
  .question-images img {
    max-height: 500px;
  }
}

/* Question body */
.question-body {
  padding: var(--space-4);
  font-size: calc(var(--text-base) * var(--q-scale, 1));
  font-family: var(--reader-font);
  line-height: 1.7;
  white-space: pre-wrap;
  text-align: justify;
  hyphens: auto;
}

@media (min-width: 1024px) {
  .question-body {
    padding: var(--space-5);
    font-size: calc(var(--text-lg) * var(--q-scale, 1));
    line-height: 1.75;
  }
}
@media (min-width: 1440px) {
  .question-body {
    padding: var(--space-6);
    font-size: calc(1.1875rem * var(--q-scale, 1));
    line-height: 1.8;
  }
}

.question-body p { margin: 0 0 var(--space-3) 0; text-align: justify; }

.question-body .highlight {
  background: linear-gradient(180deg, #fff7cc 0, #ffef99 100%);
  border-radius: 8px;
  padding: 0 6px;
}

/* Options */
.options-grid {
  display: grid;
  gap: var(--gap-sm);
  padding: 0 var(--space-4) var(--space-4);
  grid-template-columns: 1fr;
}

/* Multi-column options on desktop for 4+ options */
@media (min-width: 1024px) {
  .options-grid {
    gap: var(--space-3);
    padding: 0 var(--space-5) var(--space-5);
  }
  .options-grid.multi-column {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }
  .options-grid.long-text {
    grid-template-columns: 1fr;
  }
}
@media (min-width: 1440px) {
  .options-grid {
    padding: 0 var(--space-6) var(--space-6);
    gap: var(--space-4);
  }
  .options-grid.multi-column {
    gap: var(--space-5);
  }
}

.option {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--space-3);
  background: color-mix(in oklab, var(--chip) 40%, transparent);
  cursor: pointer;
  position: relative;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              background var(--fast) ease,
              border-color var(--fast) ease,
              box-shadow 0.2s ease;
  /* Staggered animation */
  animation: optionFadeIn 0.3s ease-out both;
}
.option:nth-child(1) { animation-delay: 0ms; }
.option:nth-child(2) { animation-delay: 50ms; }
.option:nth-child(3) { animation-delay: 100ms; }
.option:nth-child(4) { animation-delay: 150ms; }
.option:nth-child(5) { animation-delay: 200ms; }
.option:nth-child(6) { animation-delay: 250ms; }

@keyframes optionFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .option { animation: none; }
}

.option:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow: var(--sh-soft);
}

@media (min-width: 1024px) {
  .option {
    padding: var(--space-4);
    gap: var(--space-4);
    border-radius: var(--r-xl);
  }
  .option:hover:not(.disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  }
}
@media (min-width: 1440px) {
  .option {
    padding: var(--space-4) var(--space-5);
  }
}

.option:active:not(.disabled) { transform: translateY(-1px); transition-duration: 0.05s; }
.option.disabled { opacity: .78; cursor: default; }

.option-key {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid var(--brand);
  background: var(--chip2);
  font-weight: 900;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

@media (min-width: 1024px) {
  .option-key {
    min-width: 36px;
    height: 36px;
    font-size: var(--text-base);
  }
}

.option-text {
  font-size: calc(var(--text-base) * var(--q-scale, 1));
  font-family: var(--reader-font);
  white-space: pre-wrap;
  padding-top: 2px;
  line-height: 1.6;
}

@media (min-width: 1024px) {
  .option-text {
    font-size: calc(var(--text-lg) * var(--q-scale, 1));
    line-height: 1.65;
  }
}

.option.correct {
  border-color: color-mix(in oklab, var(--ok) 60%, var(--line));
  background: linear-gradient(0deg, color-mix(in oklab, var(--ok) 18%, transparent), transparent);
}

.option.correct .option-key {
  background: var(--ok);
  border-color: var(--ok);
  color: white;
}

.option.wrong {
  border-color: color-mix(in oklab, var(--bad) 60%, var(--line));
  background: linear-gradient(0deg, color-mix(in oklab, var(--bad) 14%, transparent), transparent);
}

.option.wrong .option-key {
  background: var(--bad);
  border-color: var(--bad);
  color: white;
}

/* Feedback banner - hidden */
.feedback-banner {
  display: none !important;
}

/* Global stats - hidden */
.global-stats {
  display: none !important;
}

/* Average time display above options */
.avg-time-display {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 0 18px 8px;
  font-size: 12px;
  color: var(--muted);
}

.avg-time-display svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

.avg-time-display span {
  font-weight: 700;
}

/* Option stats inside option cards */
.option-stats {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  opacity: 0;
  transition: opacity var(--fast) ease;
}

.option.disabled .option-stats {
  opacity: 1;
}

.option-stats .stat-bar {
  width: 40px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}

.option-stats .stat-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.option.correct .option-stats .stat-fill {
  background: var(--ok);
}

.option.wrong .option-stats .stat-fill {
  background: var(--bad);
}

.option-stats .stat-percent {
  font-weight: 700;
  min-width: 32px;
  text-align: right;
}

/* -------------------- SOLUTIONS -------------------- */
.solutions-panel {
  margin-top: 16px;
  border: 2px solid var(--ok);
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, color-mix(in oklab, var(--ok) 6%, var(--bg)), var(--bg));
  box-shadow: 0 8px 32px color-mix(in oklab, var(--ok) 15%, transparent);
  animation: fadeUp var(--med) ease both;
  overflow: hidden;
}

.solutions-header {
  padding: 12px 18px;
  background: linear-gradient(135deg, color-mix(in oklab, var(--ok) 12%, transparent), color-mix(in oklab, var(--ok) 6%, transparent));
  border-bottom: 1px solid color-mix(in oklab, var(--ok) 30%, var(--line));
  display: flex;
  align-items: center;
  gap: 8px;
}

.solutions-header::before {
  content: '💡';
  font-size: 16px;
}

.solutions-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ok);
}

.solutions-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.solution-tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  background: transparent;
  border: 2px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  transition: all var(--fast) ease;
}

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

.solution-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.solutions-content {
  padding: 18px;
  font-size: calc(16px * var(--q-scale, 1));
  font-family: var(--reader-font);
  line-height: 1.75;
  white-space: pre-wrap;
  text-align: justify;
}

.solutions-content img {
  max-width: 100%;
  height: auto;
  margin: 12px 0;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}

/* -------------------- FLOATING NAV -------------------- */
.floating-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 70;
}

.floating-nav.prev { left: 2px; }
.floating-nav.next { right: 2px; }

.floating-nav-btn {
  width: 28px;
  height: 50px;
  border-radius: 6px;
  border: none;
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent) 80%, transparent), color-mix(in oklab, var(--accent) 50%, transparent));
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--accent);
  backdrop-filter: blur(4px);
  transition: all var(--fast) ease;
}

.floating-nav-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 3;
}

.floating-nav-btn:hover:not(:disabled) {
  background: var(--accent);
  color: white;
}

.floating-nav-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.floating-nav-btn:disabled {
  opacity: 0.15;
  cursor: not-allowed;
}

@media (min-width: 1024px) {
  .floating-nav.prev { left: var(--space-2); }
  .floating-nav.next { right: var(--space-2); }

  .floating-nav-btn {
    width: 36px;
    height: 64px;
    border-radius: var(--r-md);
  }

  .floating-nav-btn svg {
    width: 18px;
    height: 18px;
  }
}

@media (min-width: 1280px) {
  /* Position relative to content area, not viewport */
  .floating-nav.prev { left: calc(50% - min(44vw, 900px) - 48px); }
  .floating-nav.next { right: calc(50% - min(44vw, 900px) - 48px); }

  .floating-nav-btn {
    width: 40px;
    height: 72px;
  }
}

@media (min-width: 1920px) {
  .floating-nav.prev { left: calc(50% - 920px); }
  .floating-nav.next { right: calc(50% - 920px); }

  .floating-nav-btn {
    width: 44px;
    height: 80px;
    border-radius: var(--r-lg);
  }

  .floating-nav-btn svg {
    width: 20px;
    height: 20px;
  }
}

/* -------------------- NAV BUTTONS -------------------- */
.nav-buttons {
  display: none;
}

.nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 800;
  background: var(--bg);
  border: 2px solid var(--brand);
  border-radius: var(--r-md);
  color: var(--ink);
  cursor: pointer;
  transition: all var(--fast) ease;
}

.nav-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--sh-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* -------------------- READER DOCK -------------------- */
.reader-dock {
  position: sticky;
  bottom: 8px;
  z-index: 45;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  margin: 6px auto 0;
  max-width: var(--content-w);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in oklab, var(--chip) 60%, var(--bg));
  box-shadow: var(--sh-soft);
}

.reader-dock .rc-ic {
  appearance: none;
  border: 2px solid var(--brand);
  background: transparent;
  color: var(--ink);
  width: 36px;
  height: 32px;
  line-height: 28px;
  text-align: center;
  font-weight: 900;
  font-size: 14px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  transition: transform var(--fast) ease, background var(--fast) ease, box-shadow var(--fast) ease;
}

.reader-dock .rc-ic:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-soft);
}

.reader-dock .rc-ic:active { transform: translateY(0); }

.reader-dock .rc-sep {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: var(--line-strong);
  margin: 0 2px;
}

.theme-dark .reader-dock {
  background: color-mix(in oklab, var(--chip) 25%, var(--bg));
}

/* -------------------- SUMMARY -------------------- */
.summary-screen {
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--r-2xl);
  max-width: 600px;
  margin: 0 auto;
  box-shadow: var(--sh-float);
}

.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.summary-header h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
}

.close-summary-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}

.summary-content { padding: 24px; }

/* Score circle */
.score-circle-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.score-circle {
  position: relative;
  width: 150px;
  height: 150px;
}

.score-circle svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.score-bg {
  fill: none;
  stroke: var(--line);
  stroke-width: 10;
}

.score-arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}

.score-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-percent {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
}

.score-label {
  font-size: 12px;
  color: var(--muted);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  text-align: center;
  padding: 14px;
  background: var(--chip);
  border-radius: var(--r-md);
}

.stat-card .stat-number {
  font-size: 28px;
  font-weight: 800;
}

.stat-card .stat-name {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-card.correct .stat-number { color: var(--ok); }
.stat-card.wrong .stat-number { color: var(--bad); }

/* Marks breakdown */
.marks-breakdown {
  margin-bottom: 24px;
}

.marks-breakdown h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.marks-bar {
  height: 12px;
  background: var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 6px;
}

.marks-earned {
  height: 100%;
  background: var(--grad);
  border-radius: 6px;
  transition: width 1s ease;
}

.marks-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

/* Topic breakdown */
.topic-breakdown {
  margin-bottom: 24px;
}

.topic-breakdown h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
}

.topic-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.topic-name {
  width: 100px;
  font-weight: 600;
  font-size: 13px;
}

.topic-bar {
  flex: 1;
  height: 10px;
  background: var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.topic-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 5px;
  transition: width 1s ease;
}

.topic-percent {
  width: 40px;
  text-align: right;
  font-weight: 700;
  font-size: 13px;
}

/* Weak areas */
.weak-areas {
  margin-bottom: 24px;
}

.weak-areas h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}

.weak-areas ul {
  list-style: none;
  padding: 0;
}

.weak-areas li {
  padding: 8px 14px;
  background: color-mix(in oklab, var(--bad) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--bad) 30%, var(--line));
  border-radius: 8px;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--bad);
}

/* Review grid */
.review-grid-section {
  margin-bottom: 24px;
}

.review-grid-section h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
}

.review-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-item {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: var(--chip);
  border: 2px solid var(--line);
  transition: all var(--fast) ease;
}

.review-item:hover { transform: translateY(-2px); }

.review-item.correct {
  background: color-mix(in oklab, var(--ok) 12%, transparent);
  border-color: var(--ok);
  color: var(--ok);
}

.review-item.wrong {
  background: color-mix(in oklab, var(--bad) 12%, transparent);
  border-color: var(--bad);
  color: var(--bad);
}

/* Summary actions */
.summary-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 800;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--fast) ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--grad);
  color: var(--accent-ink);
  border: none;
  box-shadow: var(--sh-soft);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-float);
}

.btn-secondary {
  background: var(--bg);
  color: var(--ink);
  border: 2px solid var(--brand);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* -------------------- FOOTER -------------------- */
.mp-footer {
  margin: 22px auto 14px;
  max-width: var(--content-w);
  padding: 0 14px;
}

.copyright {
  text-align: center;
  color: var(--muted);
  border-top: 4px solid #ffd400;
  padding-top: 10px;
  font-size: 13.5px;
}

/* -------------------- TOAST -------------------- */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  background: var(--grad);
  color: var(--accent-ink);
  border: 0;
  padding: 10px 14px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--fast) ease, transform var(--fast) ease;
  z-index: 90;
  box-shadow: var(--sh-soft);
  font-weight: 800;
  letter-spacing: .2px;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -2px);
}

/* -------------------- MODAL -------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  width: min(480px, 92vw);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-float);
  animation: fadeUp var(--med) ease both;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
}

.modal-body {
  padding: 18px;
}

/* -------------------- WATERMARK -------------------- */
.watermark {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 5;
  pointer-events: none;
  user-select: none;
  opacity: 0.15;
}

.watermark img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

@media (min-width: 768px) {
  .watermark {
    bottom: 20px;
    right: 20px;
  }

  .watermark img {
    width: 44px;
    height: 44px;
  }
}

/* -------------------- FOCUS MODE -------------------- */
.focus-btn {
  border-color: var(--ok) !important;
  color: var(--ok) !important;
}

.focus-btn:hover {
  background: linear-gradient(135deg, color-mix(in oklab, var(--ok) 12%, var(--chip)), color-mix(in oklab, var(--ok) 6%, var(--chip))) !important;
}

/* Focus Mode Toolbar - fixed at bottom in focus mode */
.focus-toolbar {
  display: none;
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 250;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: color-mix(in oklab, var(--bg) 95%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  width: fit-content;
}

html.focus-mode .focus-toolbar {
  display: flex;
}

/* Toolbar shifts up when nav is pinned - controlled via JS class */
.focus-toolbar.nav-pinned {
  bottom: 56px;
}

.focus-tool-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--fast) ease;
}

.focus-tool-btn:hover {
  background: var(--chip);
  color: var(--ink);
  border-color: var(--line);
}

.focus-tool-btn.exit-btn:hover {
  background: color-mix(in oklab, var(--bad) 15%, var(--chip));
  color: var(--bad);
  border-color: color-mix(in oklab, var(--bad) 30%, transparent);
}

.focus-tool-btn.bookmark-btn.saved {
  color: var(--accent);
}

.focus-tool-btn.bookmark-btn.saved svg {
  fill: var(--accent);
}

.focus-timer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.focus-timer svg {
  color: var(--accent);
}

.focus-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.focus-tool-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Focus Mode Nav Panel */
.focus-nav-panel {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 195;
  min-width: 200px;
  max-width: calc(100vw - 24px);
  background: color-mix(in oklab, var(--bg) 95%, transparent);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: focusNavSlide 0.25s ease;
}

@keyframes focusNavSlide {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Pinned state - horizontal bar at bottom */
.focus-nav-panel.pinned {
  top: auto;
  bottom: 0;
  left: 0;
  right: 0;
  transform: none;
  max-width: 100%;
  min-width: 100%;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-bottom: none;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  animation: focusNavSlideUp 0.25s ease;
}

@keyframes focusNavSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.focus-nav-panel.pinned .focus-nav-header {
  padding: 4px 10px;
  border-bottom: none;
}

.focus-nav-panel.pinned .focus-nav-grid {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  max-height: none;
  padding: 4px 10px 8px;
  gap: 6px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.focus-nav-panel.pinned .focus-nav-grid::-webkit-scrollbar {
  display: none;
}

.focus-nav-panel.pinned .focus-nav-grid .nbtn {
  flex-shrink: 0;
}

.focus-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}

.focus-nav-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.focus-nav-actions {
  display: flex;
  gap: 2px;
}

.focus-nav-pin,
.focus-nav-close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--fast) ease;
}

.focus-nav-pin svg,
.focus-nav-close svg {
  width: 12px;
  height: 12px;
}

.focus-nav-pin:hover,
.focus-nav-close:hover {
  background: var(--chip);
  color: var(--ink);
}

.focus-nav-pin.active {
  color: var(--accent);
  background: color-mix(in oklab, var(--accent) 15%, transparent);
}

.focus-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px;
  max-height: 160px;
  overflow-y: auto;
}

.focus-nav-grid .nbtn {
  width: 26px;
  height: 26px;
  font-size: 10px;
  font-weight: 700;
  border-width: 1.5px;
}

/* Pinned nav - even smaller for horizontal scroll */
.focus-nav-panel.pinned .focus-nav-grid .nbtn {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

/* Inline Logo - watermark over options */
.inline-logo {
  display: none;
}

html.focus-mode .inline-logo {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
}

html.focus-mode .inline-logo img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  opacity: 0.12;
}

/* Options container needs relative positioning for watermark */
html.focus-mode .options-grid {
  position: relative;
}

/* Resizable Solutions Panel */
.solutions-panel {
  position: relative;
}

.solutions-panel .resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity var(--fast) ease;
}

.solutions-panel:hover .resize-handle {
  opacity: 1;
}

.resize-handle::before {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  opacity: 0.5;
}

.solutions-panel.resizing {
  user-select: none;
}

html.focus-mode .solutions-panel.expanded {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  max-height: 60vh;
  z-index: 190;
  border-radius: var(--r-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

/* Focus Mode Content Overlay */
.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.focus-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
}

.focus-overlay-content {
  position: relative;
  width: 100%;
  max-width: 800px;
  max-height: calc(100vh - 32px);
  background: var(--bg);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 64px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: focusOverlayIn 0.2s ease;
}

@keyframes focusOverlayIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.focus-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.focus-overlay-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.focus-overlay-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--fast) ease;
}

.focus-overlay-close:hover {
  background: var(--chip);
  color: var(--ink);
}

.focus-overlay-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: calc(16px * var(--q-scale, 1));
  font-family: var(--reader-font);
  line-height: 1.75;
  text-align: justify;
  white-space: pre-wrap;
}

.focus-overlay-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 12px auto;
  border-radius: 8px;
}

/* Image-only overlay - centered image */
.focus-overlay-body.image-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
}

.focus-overlay-body.image-view img {
  max-height: calc(100vh - 140px);
  width: auto;
  max-width: 100%;
  object-fit: contain;
  margin: 0;
}

/* Clickable elements in focus mode */
html.focus-mode .passage-content,
html.focus-mode .mobile-passage-content,
html.focus-mode .question-body,
html.focus-mode .question-images img,
html.focus-mode .solutions-content {
  cursor: zoom-in;
  transition: opacity var(--fast) ease;
}

html.focus-mode .passage-content:hover,
html.focus-mode .mobile-passage-content:hover,
html.focus-mode .question-body:hover,
html.focus-mode .solutions-content:hover {
  opacity: 0.85;
}

html.focus-mode .question-images img:hover {
  opacity: 0.8;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ================== FOCUS MODE - PREMIUM EXAM EXPERIENCE ================== */

/* Force light theme in focus mode for optimal readability */
html.focus-mode {
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --ink: #1a1a2e;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --success: #059669;
  --danger: #dc2626;
  overflow: hidden;
}

html.focus-mode body {
  overflow: hidden;
  background: #d4af37; /* Gold outer - creates outer frame */
}

/* Premium triple-frame border: Gold-Black-Gold */
html.focus-mode .main-content {
  margin: 0;
  padding: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: relative;
  /* Triple frame effect - gold outer, black middle, gold inner */
  background: #ffffff;
  border: 4px solid #d4af37;
  box-shadow:
    inset 0 0 0 4px #1a1a1a,        /* Black inner border */
    inset 0 0 0 8px #d4af37;        /* Gold innermost */
}

/* Hide UI elements in focus mode */
html.focus-mode .header-bar,
html.focus-mode .qnav-sticky,
html.focus-mode .topic-tabs,
html.focus-mode .topbar-row,
html.focus-mode .reader-dock,
html.focus-mode .mp-footer {
  display: none !important;
}

/* Keep floating nav in focus mode */
html.focus-mode .floating-nav {
  display: block !important;
  z-index: 180;
}

html.focus-mode .floating-nav-btn {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 2px solid #d4af37;
  color: #1a1a2e;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

html.focus-mode .floating-nav-btn:hover:not(:disabled) {
  background: #d4af37;
  border-color: #d4af37;
  color: #1a1a1a;
}

html.focus-mode .floating-nav-btn:disabled {
  opacity: 0.3;
  border-color: #ccc;
}

/* Main stack container - SCROLLABLE */
html.focus-mode .mp-stack {
  height: calc(100vh - 24px); /* Account for frame borders */
  margin: 12px;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  overflow: hidden;
  background: #ffffff;
  border-radius: 6px;
}

/* Split layout - flex container */
html.focus-mode .split-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

html.focus-mode .passage-pane {
  position: relative !important;
  top: auto !important;
  max-height: none;
  overflow-y: auto;
  background: #fefefe;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

html.focus-mode .question-pane {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Question card - THE SCROLLABLE CONTAINER */
html.focus-mode .question-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

/* Collapsible instruction in focus mode */
html.focus-mode .instruction-banner {
  flex-shrink: 0;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all var(--fast) ease;
  background: linear-gradient(135deg, #fef9e7 0%, #fff8e1 100%);
  border-bottom: 2px solid #d4af37;
  border-radius: 8px 8px 0 0;
}

html.focus-mode .instruction-brand {
  display: flex;
  align-items: center;
}

html.focus-mode .instruction-brand img {
  width: 24px;
  height: 24px;
  border-radius: 5px;
}

html.focus-mode .instruction-banner .instruction-content {
  flex: 1;
  min-width: 0;
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

html.focus-mode .instruction-banner .instruction-label {
  font-size: 9px;
  flex-shrink: 0;
}

html.focus-mode .instruction-banner .instruction-text {
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

html.focus-mode .instruction-banner .instruction-meta {
  display: none;
}

/* Expanded instruction overlay - PREMIUM LARGE CARD */
html.focus-mode .instruction-banner.expanded {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  z-index: 200;
  padding: 32px 36px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 3px solid #d4af37;
  border-radius: 16px;
  box-shadow:
    0 0 0 1px #1a1a1a,
    0 25px 60px rgba(0, 0, 0, 0.35),
    0 10px 30px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
  cursor: default;
}

html.focus-mode .instruction-banner.expanded::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: -1;
  pointer-events: none;
}

html.focus-mode .instruction-banner.expanded .instruction-brand {
  margin-bottom: 16px;
}

html.focus-mode .instruction-banner.expanded .instruction-brand img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  border: 2px solid #d4af37;
}

html.focus-mode .instruction-banner.expanded .instruction-content {
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

html.focus-mode .instruction-banner.expanded .instruction-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #92400e;
  background: #fde68a;
  padding: 4px 12px;
  border-radius: 20px;
}

html.focus-mode .instruction-banner.expanded .instruction-text {
  font-size: 20px;
  line-height: 1.75;
  max-height: none;
  overflow: visible;
  white-space: normal;
  color: #1a1a2e;
  font-family: var(--reader-font);
}

/* Close hint */
html.focus-mode .instruction-banner.expanded::after {
  content: 'Click outside to close';
  display: block;
  margin-top: 24px;
  font-size: 12px;
  color: #92400e;
  text-align: center;
  opacity: 0.7;
}

/* Desktop expanded overlay - even larger */
@media (min-width: 1024px) {
  html.focus-mode .instruction-banner.expanded {
    max-width: 800px;
    padding: 40px 48px;
  }

  html.focus-mode .instruction-banner.expanded .instruction-brand img {
    width: 56px;
    height: 56px;
  }

  html.focus-mode .instruction-banner.expanded .instruction-text {
    font-size: 22px;
    line-height: 1.8;
  }
}

@media (min-width: 1440px) {
  html.focus-mode .instruction-banner.expanded {
    max-width: 900px;
    padding: 48px 56px;
  }

  html.focus-mode .instruction-banner.expanded .instruction-text {
    font-size: 24px;
  }
}

/* Question card inner content - all in scrollable flow */
html.focus-mode .question-card-inner {
  display: flex;
  flex-direction: column;
  min-height: min-content;
}

html.focus-mode .mobile-passage {
  flex-shrink: 0;
  max-height: 150px;
  overflow-y: auto;
  background: #fffbeb;
  border-bottom: 1px solid #fcd34d;
}

html.focus-mode .mobile-passage-content {
  padding: 12px 16px;
  font-size: calc(14px * var(--q-scale, 1));
  font-family: var(--reader-font);
  line-height: 1.7;
  color: #1a1a2e;
}

html.focus-mode .question-images {
  flex-shrink: 0;
  padding: 12px 16px 8px;
  text-align: center;
}

html.focus-mode .question-images img {
  max-height: 120px;
  max-width: 100%;
  width: auto;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

html.focus-mode .question-body {
  flex-shrink: 0;
  padding: 16px 18px;
  font-size: calc(16px * var(--q-scale, 1));
  font-family: var(--reader-font);
  line-height: 1.75;
  color: #1a1a2e;
}

html.focus-mode .options-grid {
  flex-shrink: 0;
  padding: 8px 18px 18px;
  gap: 10px;
}

html.focus-mode .option {
  padding: 12px 14px;
  font-family: var(--reader-font);
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  transition: all 0.15s ease;
}

html.focus-mode .option:hover:not(.disabled) {
  border-color: #d4af37;
  background: #fffbeb;
}

html.focus-mode .option.correct {
  background: #d1fae5;
  border-color: #059669;
}

html.focus-mode .option.wrong {
  background: #fee2e2;
  border-color: #dc2626;
}

html.focus-mode .option-text {
  font-size: calc(15px * var(--q-scale, 1));
  color: #1a1a2e;
}

html.focus-mode .option-key {
  background: #f3f4f6;
  color: #1a1a2e;
  border: 1px solid #d1d5db;
}

html.focus-mode .feedback-banner {
  flex-shrink: 0;
  margin: 0 18px 12px;
  padding: 12px 16px;
  border-radius: 8px;
}

html.focus-mode .feedback-banner.correct {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border: 1px solid #059669;
}

html.focus-mode .feedback-banner.wrong {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 1px solid #dc2626;
}

html.focus-mode .global-stats {
  flex-shrink: 0;
  padding: 12px 18px;
  gap: 20px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

html.focus-mode .solutions-panel {
  flex-shrink: 0;
  margin: 0 18px 14px;
  max-height: 250px;
  overflow-y: auto;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

/* Hide bottom nav buttons in focus mode - use floating nav instead */
html.focus-mode .nav-buttons {
  display: none !important;
}

html.focus-mode .watermark {
  bottom: 60px;
  right: 50%;
  transform: translateX(50%);
  z-index: 150;
  opacity: 0.12;
}

/* -------------------- FOCUS MODE DESKTOP - PREMIUM EXAM -------------------- */
@media (min-width: 1024px) {
  /* Premium triple frame for desktop */
  html.focus-mode .main-content {
    box-shadow:
      inset 0 0 0 4px #d4af37,        /* Inner gold */
      inset 0 0 0 10px #1a1a1a,       /* Middle black */
      inset 0 0 0 14px #d4af37,       /* Outer gold */
      0 0 0 6px #1a1a1a;              /* Outside black edge */
  }

  /* Full screen utilization */
  html.focus-mode .mp-stack {
    height: calc(100vh - 28px);
    margin: 14px;
    padding: 24px;
    gap: 16px;
    max-width: 1800px;
    margin-left: auto;
    margin-right: auto;
  }

  html.focus-mode .split-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 24px;
    overflow: hidden;
  }

  /* Long passage (>200 chars): Split layout - passage left, question right */
  html.focus-mode .split-layout.has-passage.long-passage {
    display: grid;
    grid-template-columns: minmax(380px, 42%) 1fr;
    gap: 28px;
  }

  /* ===== PASSAGE PANE - GOLD FRAME ===== */
  html.focus-mode .split-layout.has-passage.long-passage .passage-pane {
    display: flex;
    flex-direction: column;
    background: #fffdf7;
    border-radius: 16px;
    border: 3px solid #d4af37;
    overflow: hidden;
    box-shadow:
      0 0 0 1px rgba(0,0,0,0.1),
      0 8px 32px rgba(212, 175, 55, 0.15),
      inset 0 1px 0 rgba(255,255,255,0.8);
  }

  html.focus-mode .split-layout.has-passage.long-passage .passage-header {
    display: flex;
    padding: 14px 20px;
    background: linear-gradient(135deg, #fef9e7 0%, #fde68a 100%);
    border-bottom: 2px solid #d4af37;
  }

  html.focus-mode .split-layout.has-passage.long-passage .passage-label {
    font-weight: 700;
    color: #92400e;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
  }

  html.focus-mode .split-layout.has-passage.long-passage .passage-action-btn {
    display: flex;
  }

  html.focus-mode .split-layout.has-passage.long-passage .passage-content {
    flex: 1;
    min-height: 0;
    padding: 24px 28px;
    font-size: calc(17px * var(--q-scale, 1));
    font-family: var(--reader-font);
    line-height: 1.9;
    overflow-y: auto;
    overflow-x: hidden;
    color: #1a1a2e;
    white-space: pre-wrap;
    word-wrap: break-word;
    user-select: text;
    -webkit-user-select: text;
  }

  html.focus-mode .split-layout.has-passage.long-passage .passage-content p {
    margin-bottom: 1.2em;
  }

  /* ===== QUESTION PANE - BLUE/SILVER FRAME ===== */
  html.focus-mode .split-layout.has-passage.long-passage .question-pane {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  html.focus-mode .split-layout.has-passage.long-passage .question-card {
    flex: 1;
    min-height: 0;
    background: #ffffff;
    border-radius: 16px;
    border: 3px solid #6366f1;
    box-shadow:
      0 0 0 1px rgba(0,0,0,0.1),
      0 8px 32px rgba(99, 102, 241, 0.12),
      inset 0 1px 0 rgba(255,255,255,0.8);
    overflow-y: auto;
  }

  html.focus-mode .split-layout.has-passage.long-passage .instruction-banner {
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
    border-bottom: 2px solid #6366f1;
  }

  html.focus-mode .split-layout.has-passage.long-passage .instruction-label {
    color: #4338ca;
  }

  html.focus-mode .split-layout.has-passage.long-passage .instruction-text {
    color: #3730a3;
  }

  /* Short passage (<=200 chars) or no passage: Centered stacked layout */
  html.focus-mode .split-layout:not(.long-passage) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
  }

  html.focus-mode .split-layout:not(.long-passage) .passage-pane {
    display: none !important;
  }

  html.focus-mode .split-layout:not(.long-passage) .question-pane {
    width: 100%;
    max-width: 920px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  /* Premium question card for stacked layout */
  html.focus-mode .split-layout:not(.long-passage) .question-card {
    flex: 1;
    min-height: 0;
    background: #ffffff;
    border-radius: 16px;
    border: 3px solid #d4af37;
    box-shadow:
      0 0 0 1px #1a1a1a,
      0 8px 32px rgba(0,0,0,0.12);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }

  /* Instruction banner - premium gold header */
  html.focus-mode .split-layout:not(.long-passage) .instruction-banner {
    padding: 14px 28px;
    background: linear-gradient(135deg, #fef9e7 0%, #fff8e1 100%);
    border-bottom: 2px solid #d4af37;
    border-radius: 13px 13px 0 0;
  }

  html.focus-mode .split-layout:not(.long-passage) .instruction-text {
    font-size: 14px;
    color: #92400e;
  }

  /* Short passage inline in stacked */
  html.focus-mode .split-layout.has-passage.short-passage .mobile-passage {
    display: block !important;
    max-height: none;
    background: #fffbeb;
    border-bottom: 2px solid #fcd34d;
  }

  html.focus-mode .split-layout.has-passage.short-passage .mobile-passage-content {
    max-height: none;
    font-size: 16px;
    padding: 18px 28px;
    line-height: 1.8;
    color: #1a1a2e;
  }

  /* Question body - large readable text */
  html.focus-mode .split-layout:not(.long-passage) .question-body {
    font-size: calc(20px * var(--q-scale, 1));
    padding: 28px 32px;
    line-height: 1.85;
    color: #1a1a2e;
    flex-shrink: 0;
  }

  /* Question images */
  html.focus-mode .split-layout:not(.long-passage) .question-images {
    padding: 16px 32px;
    text-align: center;
  }

  html.focus-mode .split-layout:not(.long-passage) .question-images img {
    max-height: 220px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
  }

  /* Options - 2 column grid for 4+ options */
  html.focus-mode .split-layout:not(.long-passage) .options-grid {
    padding: 16px 32px 28px;
    gap: 14px;
  }

  html.focus-mode .split-layout:not(.long-passage) .options-grid.multi-column {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  html.focus-mode .split-layout:not(.long-passage) .option {
    padding: 16px 20px;
    font-size: 17px;
    border-radius: 10px;
    border-width: 2px;
  }

  html.focus-mode .split-layout:not(.long-passage) .option:hover:not(.disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
  }

  html.focus-mode .split-layout:not(.long-passage) .option-text {
    font-size: calc(17px * var(--q-scale, 1));
  }

  /* Feedback banner */
  html.focus-mode .split-layout:not(.long-passage) .feedback-banner {
    margin: 0 32px 16px;
    padding: 16px 24px;
    border-radius: 10px;
  }

  /* Global stats */
  html.focus-mode .split-layout:not(.long-passage) .global-stats {
    padding: 16px 32px;
    gap: 32px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
  }

  /* Solutions panel */
  html.focus-mode .split-layout:not(.long-passage) .solutions-panel {
    margin: 0 32px 24px;
    max-height: 320px;
    border-radius: 10px;
  }

  /* Question card for split layout (long passage) - styles */
  html.focus-mode .split-layout.long-passage .instruction-banner {
    padding: 12px 20px;
    background: linear-gradient(135deg, #fef9e7 0%, #fff8e1 100%);
    border-bottom: 2px solid #d4af37;
    border-radius: 10px 10px 0 0;
  }

  html.focus-mode .split-layout.long-passage .question-body {
    font-size: calc(17px * var(--q-scale, 1));
    padding: 20px 24px;
    line-height: 1.8;
    color: #1a1a2e;
  }

  html.focus-mode .split-layout.long-passage .options-grid {
    padding: 12px 24px 20px;
    gap: 10px;
  }

  html.focus-mode .split-layout.long-passage .option {
    padding: 12px 16px;
    border-width: 2px;
  }

  html.focus-mode .split-layout.long-passage .option-text {
    font-size: calc(15px * var(--q-scale, 1));
  }

  /* Hide mobile passage in split layout (use desktop pane) */
  html.focus-mode .split-layout.long-passage .mobile-passage {
    display: none !important;
  }

  /* Watermark */
  html.focus-mode .watermark {
    bottom: 24px;
    right: 24px;
    transform: none;
    opacity: 0.06;
  }

  /* Floating nav - premium styled */
  html.focus-mode .floating-nav {
    top: 50%;
    transform: translateY(-50%);
  }

  html.focus-mode .floating-nav.prev {
    left: 20px;
  }

  html.focus-mode .floating-nav.next {
    right: 20px;
  }

  html.focus-mode .floating-nav-btn {
    width: 48px;
    height: 96px;
    border-radius: 12px;
    border-width: 2px;
    font-size: 20px;
  }
}

/* ===== PASSAGE EXPANDED OVERLAY ===== */
.passage-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  padding: 40px;
  overflow-y: auto;
}

.passage-overlay.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.passage-overlay-card {
  width: 100%;
  max-width: 900px;
  max-height: calc(100vh - 80px);
  background: #fffdf7;
  border-radius: 20px;
  border: 4px solid #d4af37;
  box-shadow:
    0 0 0 2px #1a1a1a,
    0 30px 80px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.passage-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: linear-gradient(135deg, #fef9e7 0%, #fde68a 100%);
  border-bottom: 3px solid #d4af37;
}

.passage-overlay-title {
  font-size: 16px;
  font-weight: 700;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.passage-overlay-close {
  width: 40px;
  height: 40px;
  border: 2px solid #d4af37;
  border-radius: 10px;
  background: rgba(255,255,255,0.8);
  color: #92400e;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.passage-overlay-close:hover {
  background: #d4af37;
  color: #1a1a1a;
}

.passage-overlay-content {
  flex: 1;
  min-height: 0;
  padding: 32px 36px;
  font-size: calc(20px * var(--q-scale, 1));
  font-family: var(--reader-font);
  line-height: 2;
  color: #1a1a2e;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.passage-overlay-content p {
  margin-bottom: 1.5em;
}

.passage-overlay-content .user-highlight {
  background: linear-gradient(180deg, transparent 55%, rgba(239, 68, 68, 0.35) 55%);
  border-bottom: 3px solid #ef4444;
}

@media (min-width: 1440px) {
  .passage-overlay {
    padding: 60px;
  }

  .passage-overlay-card {
    max-width: 1000px;
  }

  .passage-overlay-content {
    font-size: calc(22px * var(--q-scale, 1));
    padding: 40px 48px;
  }
}

/* Larger screens - more breathing room */
@media (min-width: 1440px) {
  html.focus-mode .mp-stack {
    padding: 32px;
    max-width: 1600px;
  }

  html.focus-mode .split-layout.has-passage.long-passage {
    grid-template-columns: minmax(440px, 40%) 1fr;
    gap: 36px;
  }

  html.focus-mode .split-layout:not(.long-passage) .question-pane {
    max-width: 1000px;
  }

  html.focus-mode .split-layout:not(.long-passage) .question-body {
    font-size: calc(22px * var(--q-scale, 1));
    padding: 32px 40px;
  }

  html.focus-mode .split-layout:not(.long-passage) .option {
    padding: 18px 24px;
    font-size: 18px;
  }

  html.focus-mode .floating-nav.prev {
    left: 28px;
  }

  html.focus-mode .floating-nav.next {
    right: 28px;
  }
}

/* Ultra-wide screens */
@media (min-width: 1920px) {
  html.focus-mode .main-content {
    box-shadow:
      inset 0 0 0 5px #d4af37,
      inset 0 0 0 12px #1a1a1a,
      inset 0 0 0 17px #d4af37,
      0 0 0 8px #1a1a1a;
  }

  html.focus-mode .mp-stack {
    max-width: 1800px;
  }

  html.focus-mode .split-layout.has-passage.long-passage {
    grid-template-columns: minmax(500px, 38%) 1fr;
  }

  html.focus-mode .split-layout:not(.long-passage) .question-pane {
    max-width: 1100px;
  }

  html.focus-mode .floating-nav.prev {
    left: 36px;
  }

  html.focus-mode .floating-nav.next {
    right: 36px;
  }

  html.focus-mode .floating-nav-btn {
    width: 52px;
    height: 104px;
  }
}

/* Tablet focus mode */
@media (min-width: 900px) and (max-width: 1023px) {
  html.focus-mode .split-layout.has-passage {
    display: grid;
    grid-template-columns: 42% 1fr;
    gap: 16px;
  }

  html.focus-mode .watermark {
    bottom: 20px;
    right: 20px;
    transform: none;
  }
}

/* -------------------- UTILITIES -------------------- */
.nocopy {
  -webkit-user-select: none;
  user-select: none;
}

.hide { display: none !important; }
.muted { color: var(--muted); }

/* -------------------- MATHJAX -------------------- */
.MathJax, .MathJax * { color: inherit !important; }
.MathJax_SVG, .MathJax_SVG * { fill: currentColor !important; stroke: currentColor !important; }

.theme-dark mjx-container,
.theme-dark mjx-container * {
  color: var(--ink) !important;
  fill: var(--ink) !important;
  stroke: var(--ink) !important;
}

.mjx-container { max-width: 100%; overflow-x: auto; }

/* -------------------- MOBILE RESPONSIVE -------------------- */
@media (max-width: 899px) {
  /* Hide topic tabs on mobile - use section bar instead */
  .topic-tabs { display: none; }
}

@media (max-width: 768px) {
  .header-bar { gap: 8px; }
  .header-right { gap: 5px; }
  .header-title { font-size: 11px; }

  .qnav-sticky { padding: 5px 6px; }
  .section-bar { gap: 3px; }
  .section-square { min-width: 26px; height: 26px; padding: 2px 5px; }
  .section-square .section-name { font-size: 8px; }
  .nav-circles { gap: 4px; }
  .nbtn { min-width: 26px; height: 26px; font-size: 11px; }
  .nav-arrow { width: 24px; height: 24px; }

  .main-content { margin: 12px auto; padding: 0 12px; }

  .instruction-banner { flex-direction: column; padding: 12px 14px; }
  .instruction-meta { align-self: flex-start; }

  .question-body { padding: 14px; }
  .options-grid { padding: 0 14px 14px; gap: 8px; }
  .option { padding: 10px 12px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .reader-dock { padding: 4px 6px; gap: 4px; }
  .reader-dock .rc-ic { width: 32px; height: 28px; font-size: 12px; }
}

@media (max-width: 480px) {
  .header-bar { padding: 6px 8px; gap: 6px; }
  .header-right { gap: 4px; }
  .icon-btn { width: 26px; height: 26px; border-radius: 6px; }
  .icon-btn svg { width: 14px; height: 14px; }
  .avatar { width: 26px; height: 26px; border-radius: 6px; }
  .timer-chip { padding: 3px 6px; font-size: 10px; border-radius: 6px; }
  .timer-chip svg { width: 12px; height: 12px; }

  .set-type-badge { font-size: 7px; }
  .header-title { font-size: 10px; }

  .qnav-sticky { padding: 4px 5px; gap: 4px; }
  .section-bar { gap: 2px; }
  .section-square { min-width: 24px; height: 24px; padding: 2px 4px; border-radius: 5px; }
  .section-square .section-name { font-size: 7px; }
  .nav-circles { gap: 3px; }
  .nbtn { min-width: 24px; height: 24px; font-size: 10px; }
  .nav-arrow { width: 22px; height: 22px; }

  .option-key { min-width: 24px; height: 24px; font-size: 12px; }
  .option-text { font-size: 14px; }

  .sw-face { width: 32px; height: 32px; }
  .sw-time { font-size: 14px; }

  .reader-dock .rc-ic { width: 28px; height: 26px; font-size: 11px; }
}

/* ==================== WORLD-CLASS SKIN OVERRIDES ==================== */

/* ===== CLASSIC LIGHT SKINS ===== */

/* Paper - Authentic aged paper with subtle texture */
:root[data-skin="paper"] {
  --card-bg:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E"),
    repeating-linear-gradient(0deg, #fffdf6, #fffdf6 28px, #faf5e8 29px),
    linear-gradient(180deg, #fffef9, #fdf8ed) padding-box;
  --card-border-gradient: linear-gradient(180deg, #c9b896, #e8d9b8, #c9b896);
  --card-shadow: 0 8px 32px rgba(139, 119, 73, 0.12), 0 2px 8px rgba(139, 119, 73, 0.08);
  --ink: #3d3427;
}

/* Exam - Clean examination sheet with blue margin */
:root[data-skin="exam"] {
  --card-bg:
    linear-gradient(90deg, transparent 58px, #e8f0ff 58px, #e8f0ff 60px, transparent 60px),
    repeating-linear-gradient(0deg, #ffffff, #ffffff 24px, #f0f4ff 25px),
    linear-gradient(180deg, #ffffff, #fafcff) padding-box;
  --card-border-gradient: linear-gradient(180deg, #7c9eff, #a8c0ff, #7c9eff);
  --card-shadow: 0 8px 32px rgba(99, 132, 255, 0.12), 0 2px 8px rgba(99, 132, 255, 0.06);
  --ink: #1e3a5f;
}

/* Book - Warm sepia with leather-like border */
:root[data-skin="book"] {
  --card-bg:
    linear-gradient(180deg, #fefbf3 0%, #f8f0e0 50%, #f3e8d4 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #8b6914, #c49a3d, #8b6914);
  --card-shadow:
    0 12px 40px rgba(139, 105, 20, 0.15),
    0 4px 12px rgba(139, 105, 20, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --ink: #4a3c1f;
}

/* Notebook - Grid pattern with blue spiral binding effect */
:root[data-skin="notebook"] {
  --card-bg:
    linear-gradient(90deg, #fef8f8 0px, transparent 4px),
    radial-gradient(circle at 16px 16px, rgba(100, 149, 237, 0.08) 2px, transparent 2px),
    linear-gradient(180deg, #ffffff, #fcfcff) padding-box;
  --card-border-gradient: linear-gradient(180deg, #5b8cff, #8eb4ff, #5b8cff);
  --card-shadow: 0 8px 28px rgba(91, 140, 255, 0.12), -4px 0 0 #dc2626;
  --ink: #1a365d;
}

/* Neon - Vibrant gradient with glow effect */
:root[data-skin="neon"] {
  --card-bg: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(248,250,255,0.98)) padding-box;
  --card-border-gradient: linear-gradient(135deg, #8b5cf6, #3b82f6, #06b6d4);
  --card-shadow:
    0 0 20px rgba(139, 92, 246, 0.2),
    0 0 40px rgba(59, 130, 246, 0.1),
    0 12px 40px rgba(99, 102, 241, 0.15);
  --ink: #1e1b4b;
}

/* ===== PREMIUM LIGHT MODE SKINS ===== */

/* Mint - Fresh garden feel with dew drops */
:root[data-skin="mint"] {
  --card-bg:
    radial-gradient(circle at 90% 10%, rgba(74, 222, 128, 0.1) 0%, transparent 50%),
    linear-gradient(180deg, #f0fdf4 0%, #dcfce7 50%, #d1fae5 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #22c55e, #4ade80, #22c55e);
  --card-shadow:
    0 10px 40px rgba(34, 197, 94, 0.12),
    0 4px 12px rgba(34, 197, 94, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  --ink: #14532d;
}

/* Lavender - Dreamy purple with soft glow */
:root[data-skin="lavender"] {
  --card-bg:
    radial-gradient(ellipse at 20% 0%, rgba(196, 181, 253, 0.2) 0%, transparent 50%),
    linear-gradient(180deg, #faf5ff 0%, #f3e8ff 60%, #ede9fe 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #a855f7, #c084fc, #a855f7);
  --card-shadow:
    0 10px 40px rgba(168, 85, 247, 0.12),
    0 0 30px rgba(192, 132, 252, 0.08);
  --ink: #3b0764;
}

/* Peach - Warm sunset gradient */
:root[data-skin="peach"] {
  --card-bg:
    radial-gradient(circle at 80% 20%, rgba(251, 146, 60, 0.12) 0%, transparent 40%),
    linear-gradient(180deg, #fff7ed 0%, #ffedd5 50%, #fed7aa 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #ea580c, #fb923c, #ea580c);
  --card-shadow:
    0 10px 40px rgba(234, 88, 12, 0.12),
    0 4px 12px rgba(251, 146, 60, 0.08);
  --ink: #7c2d12;
}

/* Slate - Professional minimal with depth */
:root[data-skin="slate"] {
  --card-bg: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #94a3b8, #64748b);
  --card-shadow: 0 12px 32px rgba(100, 116, 139, 0.15);
}

/* Ocean - Calm deep blue */
:root[data-skin="ocean"] {
  --card-bg: linear-gradient(180deg, #f0f9ff, #e0f2fe) padding-box;
  --card-border-gradient: linear-gradient(180deg, #38bdf8, #0ea5e9);
  --card-shadow: 0 12px 32px rgba(14, 165, 233, 0.12);
}

/* Light mode versions of dark-exclusive skins (so they work in light mode too) */

/* Midnight Light - Indigo elegance */
:root[data-skin="midnight"] {
  --card-bg: linear-gradient(180deg, #eef2ff, #e0e7ff) padding-box;
  --card-border-gradient: linear-gradient(180deg, #6366f1, #818cf8);
  --card-shadow: 0 12px 32px rgba(99, 102, 241, 0.15);
}

/* Ember Light - Warm rose */
:root[data-skin="ember"] {
  --card-bg: linear-gradient(180deg, #fef2f2, #fee2e2) padding-box;
  --card-border-gradient: linear-gradient(180deg, #ef4444, #f97316);
  --card-shadow: 0 12px 32px rgba(239, 68, 68, 0.12);
}

/* Forest Light - Fresh nature */
:root[data-skin="forest"] {
  --card-bg: linear-gradient(180deg, #f0fdf4, #d1fae5) padding-box;
  --card-border-gradient: linear-gradient(180deg, #16a34a, #4ade80);
  --card-shadow: 0 12px 32px rgba(22, 163, 74, 0.12);
}

/* Amethyst Light - Soft violet */
:root[data-skin="amethyst"] {
  --card-bg: linear-gradient(180deg, #faf5ff, #ede9fe) padding-box;
  --card-border-gradient: linear-gradient(180deg, #9333ea, #c084fc);
  --card-shadow: 0 12px 32px rgba(147, 51, 234, 0.12);
}

/* Carbon Light - Crisp teal */
:root[data-skin="carbon"] {
  --card-bg: linear-gradient(180deg, #ecfeff, #cffafe) padding-box;
  --card-border-gradient: linear-gradient(180deg, #06b6d4, #22d3ee);
  --card-shadow: 0 12px 32px rgba(6, 182, 212, 0.12);
}

/* ==================== WORLD-CLASS DARK MODE SKINS ==================== */

/* Paper Dark - Aged parchment in candlelight */
.theme-dark[data-skin="paper"] {
  --card-bg:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E"),
    repeating-linear-gradient(0deg, #1a1610, #1a1610 28px, #1f1b14 29px),
    linear-gradient(180deg, #1c1812, #15120d) padding-box;
  --card-border-gradient: linear-gradient(180deg, #8b7355, #c9a66b, #8b7355);
  --card-shadow: 0 12px 40px rgba(201, 166, 107, 0.15), 0 0 60px rgba(201, 166, 107, 0.05);
  --ink: #e8dcc8;
}

/* Exam Dark - Night study mode with blue glow */
.theme-dark[data-skin="exam"] {
  --card-bg:
    linear-gradient(90deg, transparent 58px, rgba(99, 132, 255, 0.08) 58px, rgba(99, 132, 255, 0.08) 60px, transparent 60px),
    repeating-linear-gradient(0deg, #0a0f1a, #0a0f1a 24px, #0d1424 25px),
    linear-gradient(180deg, #0c1220, #080d18) padding-box;
  --card-border-gradient: linear-gradient(180deg, #6384ff, #91a8ff, #6384ff);
  --card-shadow: 0 12px 40px rgba(99, 132, 255, 0.2), 0 0 40px rgba(99, 132, 255, 0.08);
  --ink: #d1deff;
}

/* Book Dark - Leather-bound antique */
.theme-dark[data-skin="book"] {
  --card-bg: linear-gradient(180deg, #1a150f 0%, #14100a 50%, #0f0c08 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #b8860b, #daa520, #b8860b);
  --card-shadow:
    0 12px 48px rgba(218, 165, 32, 0.15),
    0 4px 16px rgba(184, 134, 11, 0.1),
    inset 0 1px 0 rgba(218, 165, 32, 0.1);
  --ink: #f5e6c8;
}

/* Notebook Dark - Blueprints & schematics */
.theme-dark[data-skin="notebook"] {
  --card-bg:
    linear-gradient(90deg, rgba(91, 140, 255, 0.1) 0px, transparent 4px),
    radial-gradient(circle at 16px 16px, rgba(91, 140, 255, 0.12) 2px, transparent 2px),
    linear-gradient(180deg, #080c14, #0a1020) padding-box;
  --card-border-gradient: linear-gradient(180deg, #5b8cff, #88b4ff, #5b8cff);
  --card-shadow: 0 12px 40px rgba(91, 140, 255, 0.2), -4px 0 0 #ef4444;
  --ink: #c8d9ff;
}

/* Neon Dark - Cyberpunk with animated glow */
.theme-dark[data-skin="neon"] {
  --card-bg: linear-gradient(135deg, rgba(15, 15, 25, 0.95), rgba(20, 20, 35, 0.98)) padding-box;
  --card-border-gradient: linear-gradient(135deg, #a855f7, #6366f1, #06b6d4);
  --card-shadow:
    0 0 30px rgba(168, 85, 247, 0.3),
    0 0 60px rgba(99, 102, 241, 0.15),
    0 20px 50px rgba(6, 182, 212, 0.15);
  --ink: #e0e7ff;
}

/* ===== PREMIUM DARK MODE SKINS - HIGH CONTRAST ===== */

/* Mint Dark - Bioluminescent forest */
.theme-dark[data-skin="mint"] {
  --card-bg:
    radial-gradient(ellipse at 30% 20%, rgba(74, 222, 128, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, #041f0f 0%, #052e16 50%, #0a3d1f 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #22c55e, #4ade80, #22c55e);
  --card-shadow:
    0 0 40px rgba(74, 222, 128, 0.2),
    0 16px 48px rgba(34, 197, 94, 0.15);
  --ink: #bbf7d0;
}

/* Lavender Dark - Mystical purple void */
.theme-dark[data-skin="lavender"] {
  --card-bg:
    radial-gradient(ellipse at 70% 10%, rgba(192, 132, 252, 0.12) 0%, transparent 50%),
    linear-gradient(180deg, #13091f 0%, #1e0f35 50%, #2a1650 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #a855f7, #c084fc, #a855f7);
  --card-shadow:
    0 0 50px rgba(168, 85, 247, 0.25),
    0 16px 48px rgba(192, 132, 252, 0.15);
  --ink: #e9d5ff;
}

/* Peach Dark - Volcanic ember */
.theme-dark[data-skin="peach"] {
  --card-bg:
    radial-gradient(circle at 80% 80%, rgba(251, 146, 60, 0.1) 0%, transparent 40%),
    linear-gradient(180deg, #1a0f0a 0%, #2d1408 50%, #3d1a0a 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #ea580c, #fb923c, #ea580c);
  --card-shadow:
    0 0 40px rgba(234, 88, 12, 0.25),
    0 16px 48px rgba(251, 146, 60, 0.15);
  --ink: #fed7aa;
}

/* Slate Dark - Command center */
.theme-dark[data-skin="slate"] {
  --card-bg:
    linear-gradient(180deg, #0c1221 0%, #111827 50%, #1f2937 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #94a3b8, #cbd5e1);
  --card-shadow: 0 18px 40px rgba(148, 163, 184, 0.15);
}

/* Ocean Dark - Deep sea */
.theme-dark[data-skin="ocean"] {
  --card-bg: linear-gradient(180deg, #0c1929, #0c4a6e) padding-box;
  --card-border-gradient: linear-gradient(180deg, #38bdf8, #0ea5e9);
  --card-shadow: 0 18px 40px rgba(56, 189, 248, 0.2);
}

/* ===== ADDITIONAL EXCLUSIVE DARK SKINS ===== */

/* Midnight - Deep blue black with stars effect */
/* Ocean Dark - Deep sea abyss */
.theme-dark[data-skin="ocean"] {
  --card-bg:
    radial-gradient(ellipse at 50% 100%, rgba(14, 165, 233, 0.1) 0%, transparent 50%),
    linear-gradient(180deg, #051525 0%, #082030 50%, #0a2a40 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #0ea5e9, #38bdf8, #0ea5e9);
  --card-shadow:
    0 0 50px rgba(14, 165, 233, 0.2),
    0 16px 48px rgba(56, 189, 248, 0.15);
  --ink: #bae6fd;
}

/* ===== EXCLUSIVE DARK MODE SKINS ===== */

/* Midnight - Starfield infinity */
.theme-dark[data-skin="midnight"] {
  --card-bg:
    radial-gradient(1.5px 1.5px at 10% 20%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 25% 45%, rgba(255, 255, 255, 0.25), transparent),
    radial-gradient(1.5px 1.5px at 40% 15%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1px 1px at 55% 55%, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(2px 2px at 70% 25%, rgba(255, 255, 255, 0.45), transparent),
    radial-gradient(1px 1px at 85% 60%, rgba(255, 255, 255, 0.3), transparent),
    radial-gradient(1.5px 1.5px at 95% 10%, rgba(255, 255, 255, 0.25), transparent),
    radial-gradient(ellipse at 30% 70%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    linear-gradient(180deg, #020617 0%, #0a0f24 50%, #0f172a 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #4f46e5, #818cf8, #4f46e5);
  --card-shadow:
    0 0 60px rgba(99, 102, 241, 0.25),
    0 20px 60px rgba(79, 70, 229, 0.2);
  --ink: #c7d2fe;
}

/* Ember - Volcanic fire */
.theme-dark[data-skin="ember"] {
  --card-bg:
    radial-gradient(ellipse at 50% 100%, rgba(239, 68, 68, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(249, 115, 22, 0.1) 0%, transparent 40%),
    linear-gradient(180deg, #1a0808 0%, #2d0f0f 50%, #3d1515 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #dc2626, #f97316, #dc2626);
  --card-shadow:
    0 0 50px rgba(220, 38, 38, 0.3),
    0 0 100px rgba(249, 115, 22, 0.15),
    0 20px 60px rgba(239, 68, 68, 0.2);
  --ink: #fecaca;
}

/* Forest - Ancient woodland */
.theme-dark[data-skin="forest"] {
  --card-bg:
    radial-gradient(ellipse at 20% 80%, rgba(74, 222, 128, 0.08) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 20%, rgba(22, 163, 74, 0.06) 0%, transparent 40%),
    linear-gradient(180deg, #061208 0%, #0a1f10 50%, #0f2d18 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #15803d, #4ade80, #15803d);
  --card-shadow:
    0 0 50px rgba(74, 222, 128, 0.2),
    0 20px 60px rgba(22, 163, 74, 0.15);
  --ink: #bbf7d0;
}

/* Amethyst - Crystal cavern */
.theme-dark[data-skin="amethyst"] {
  --card-bg:
    radial-gradient(ellipse at 70% 30%, rgba(192, 132, 252, 0.12) 0%, transparent 40%),
    radial-gradient(ellipse at 30% 70%, rgba(147, 51, 234, 0.08) 0%, transparent 40%),
    linear-gradient(180deg, #120820 0%, #1a0f2e 50%, #2d1b4e 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #7c3aed, #c084fc, #7c3aed);
  --card-shadow:
    0 0 60px rgba(147, 51, 234, 0.3),
    0 0 100px rgba(192, 132, 252, 0.15),
    0 20px 60px rgba(124, 58, 237, 0.2);
  --ink: #e9d5ff;
}

/* Carbon - OLED true black */
.theme-dark[data-skin="carbon"] {
  --card-bg:
    radial-gradient(ellipse at 50% 0%, rgba(6, 182, 212, 0.05) 0%, transparent 50%),
    linear-gradient(180deg, #000000 0%, #030303 50%, #050505 100%) padding-box;
  --card-border-gradient: linear-gradient(180deg, #0891b2, #22d3ee, #0891b2);
  --card-shadow:
    0 0 40px rgba(6, 182, 212, 0.25),
    0 0 80px rgba(34, 211, 238, 0.1),
    0 16px 48px rgba(8, 145, 178, 0.2);
  --ink: #cffafe;
}

/* -------------------- XP TOAST -------------------- */
.xp-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 10px 14px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, #fcd34d 100%);
  border: 2px solid #f59e0b;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.35), 0 0 40px rgba(245, 158, 11, 0.2);
  font-size: 14px;
  font-weight: 800;
  color: #92400e;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.xp-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.xp-toast .xp-icon {
  font-size: 18px;
  animation: xpBounce 0.6s ease-out;
}

.xp-toast .xp-plus {
  letter-spacing: 0.5px;
}

@keyframes xpBounce {
  0% { transform: scale(0.5); }
  50% { transform: scale(1.3); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* Dark mode XP toast */
.theme-dark .xp-toast {
  background: linear-gradient(135deg, #78350f 0%, #92400e 50%, #b45309 100%);
  border-color: #fbbf24;
  color: #fef3c7;
  box-shadow: 0 8px 24px rgba(251, 191, 36, 0.35), 0 0 40px rgba(251, 191, 36, 0.2);
}

/* Streak bonus badge in XP toast */
.xp-toast .xp-streak-bonus {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  margin-left: 6px;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  animation: streakPulse 0.5s ease-out;
}

@keyframes streakPulse {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* Streak milestone toast */
.streak-milestone-toast {
  position: fixed;
  top: 140px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px) scale(0.8);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border: 2px solid #fca5a5;
  border-radius: 999px;
  box-shadow: 0 8px 32px rgba(220, 38, 38, 0.5);
  font-size: 16px;
  font-weight: 800;
  color: white;
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.streak-milestone-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.streak-milestone-toast .streak-icon {
  font-size: 24px;
  animation: fireShake 0.6s ease-out;
}

@keyframes fireShake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

/* Live XP display in header */
#xpDisplay {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 1px solid #f59e0b;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #92400e;
}

@media (min-width: 1024px) {
  #xpDisplay {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-base);
    gap: var(--space-2);
  }
}
@media (min-width: 1440px) {
  #xpDisplay {
    padding: var(--space-2) var(--space-5);
    font-size: 1.0625rem;
  }
}

.theme-dark #xpDisplay {
  background: linear-gradient(135deg, #78350f 0%, #92400e 100%);
  border-color: #fbbf24;
  color: #fef3c7;
}

#xpDisplay .xp-icon-small {
  font-size: 14px;
}
@media (min-width: 1024px) {
  #xpDisplay .xp-icon-small {
    font-size: 18px;
  }
}

/* Live streak display */
#streakDisplay {
  display: none;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 1px solid #f87171;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #991b1b;
}

.theme-dark #streakDisplay {
  background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%);
  border-color: #f87171;
  color: #fecaca;
}

#streakDisplay .streak-fire {
  animation: firePulse 1s ease-in-out infinite;
}

@keyframes firePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Completion bonus in results */
.completion-bonus {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 4px 12px;
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  animation: bonusPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bonusPopIn {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   START/RESUME SCREEN
   ========================================================================== */

.start-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 150px);
  padding: 24px;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.start-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  box-shadow: var(--sh-float);
  max-width: 520px;
  width: 100%;
  padding: var(--space-10);
  text-align: center;
}

@media (min-width: 1024px) {
  .start-card {
    max-width: 600px;
    padding: var(--space-12);
    border-radius: 32px;
  }
}
@media (min-width: 1440px) {
  .start-card {
    max-width: 680px;
    padding: var(--space-16);
  }
}

.start-header {
  margin-bottom: var(--space-8);
}

.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 20px;
  margin-bottom: 16px;
}

.start-card h1 {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 var(--space-2);
  line-height: 1.2;
}

@media (min-width: 1024px) {
  .start-card h1 {
    font-size: var(--text-3xl);
  }
}
@media (min-width: 1440px) {
  .start-card h1 {
    font-size: clamp(2rem, 1.8rem + 1vw, 2.5rem);
  }
}

.start-desc {
  font-size: 15px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.start-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}

.start-stat {
  display: flex;
  align-items: center;
  gap: 12px;
}

.start-stat-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chip);
  border-radius: 12px;
  color: var(--accent);
}

.start-stat-content {
  text-align: left;
}

.start-stat-value {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.start-stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Progress Section */
.start-progress {
  background: var(--chip);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 24px;
  text-align: left;
}

.start-progress h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 12px;
}

.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar {
  flex: 1;
  height: 10px;
  background: var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #1d4ed8);
  border-radius: 5px;
  transition: width 0.5s ease;
}

.progress-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 13px;
}

.correct-count {
  color: var(--ok);
  font-weight: 600;
}

.accuracy {
  color: var(--muted);
}

/* Start Actions */
.start-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.start-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--r-lg);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.start-actions .btn-primary {
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  box-shadow: 0 4px 16px rgba(43, 124, 255, 0.35);
}

.start-actions .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(43, 124, 255, 0.45);
}

.start-actions .btn-secondary {
  background: var(--chip);
  color: var(--ink);
  border: 1px solid var(--line);
}

.start-actions .btn-secondary:hover {
  background: var(--line);
}

.start-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  transition: color 0.2s;
}

.start-back-link:hover {
  color: var(--accent);
}

/* ==========================================================================
   COMPLETION SCREEN
   ========================================================================== */

.completion-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 150px);
  padding: 24px;
  animation: fadeIn 0.4s ease-out;
}

.completion-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  box-shadow: var(--sh-float);
  max-width: 560px;
  width: 100%;
  padding: var(--space-10);
  text-align: center;
  position: relative;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .completion-card {
    max-width: 680px;
    padding: var(--space-12);
    border-radius: 32px;
  }
}
@media (min-width: 1440px) {
  .completion-card {
    max-width: 760px;
    padding: var(--space-16);
  }
}

.completion-confetti {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(16, 185, 129, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(59, 130, 246, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(245, 158, 11, 0.08) 0%, transparent 40%);
  pointer-events: none;
}

.completion-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto 24px;
  background: linear-gradient(135deg, #10b981, #059669);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  animation: bounceIn 0.6s ease-out;
  box-shadow: 0 8px 32px rgba(16, 185, 129, 0.35);
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.15); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.completion-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--ink);
  margin: 0 0 var(--space-2);
}

@media (min-width: 1024px) {
  .completion-title {
    font-size: var(--text-3xl);
  }
}
@media (min-width: 1440px) {
  .completion-title {
    font-size: clamp(2rem, 1.8rem + 1vw, 2.5rem);
  }
}

.completion-subtitle {
  font-size: 16px;
  color: var(--muted);
  margin: 0 0 32px;
}

.completion-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.comp-stat {
  background: var(--chip);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  min-width: 90px;
}

.comp-stat.highlight {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.1));
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.comp-stat.xp {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(245, 158, 11, 0.15));
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.comp-stat-value {
  display: block;
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
}

.comp-stat.highlight .comp-stat-value {
  color: var(--ok);
}

.comp-stat.xp .comp-stat-value {
  color: #d97706;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* XP breakdown in completion screen */
.comp-stat.xp .xp-total {
  font-size: 28px;
  font-weight: 800;
  color: #d97706;
}

.comp-stat.xp .xp-session {
  font-size: 12px;
  font-weight: 500;
  color: #92400e;
  opacity: 0.8;
}

.comp-stat.xp .completion-bonus {
  margin-left: 0;
  margin-top: 6px;
  font-size: 11px;
  padding: 3px 10px;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #1a1a2e;
  animation: bonusPopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
}

.comp-stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Performance Breakdown */
.comp-breakdown {
  background: var(--chip);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 28px;
}

.comp-breakdown h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 12px;
}

.breakdown-bar {
  display: flex;
  height: 16px;
  background: var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.breakdown-segment {
  transition: width 0.6s ease;
}

.breakdown-segment.correct {
  background: linear-gradient(90deg, #10b981, #059669);
}

.breakdown-segment.wrong {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

.breakdown-segment.skipped {
  background: linear-gradient(90deg, #9ca3af, #6b7280);
}

.breakdown-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.legend-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-item.correct .dot { background: #10b981; }
.legend-item.wrong .dot { background: #ef4444; }
.legend-item.skipped .dot { background: #9ca3af; }

/* Completion Actions */
.completion-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.completion-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--r-lg);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.completion-actions .btn-primary {
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  box-shadow: 0 4px 16px rgba(43, 124, 255, 0.35);
}

.completion-actions .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(43, 124, 255, 0.45);
}

.completion-actions .btn-secondary {
  background: var(--chip);
  color: var(--ink);
  border: 1px solid var(--line);
}

.completion-actions .btn-secondary:hover {
  background: var(--line);
}

.completion-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  transition: color 0.2s;
}

.completion-back-link:hover {
  color: var(--accent);
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .start-card, .completion-card {
    padding: 28px 20px;
  }

  .start-card h1 {
    font-size: 22px;
  }

  .start-stats {
    flex-direction: column;
    gap: 16px;
  }

  .start-stat {
    justify-content: center;
  }

  .start-actions, .completion-actions {
    flex-direction: column;
  }

  .start-actions .btn, .completion-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .completion-stats {
    gap: 12px;
  }

  .comp-stat {
    min-width: 75px;
    padding: 12px 14px;
  }

  .comp-stat-value {
    font-size: 20px;
  }

  .breakdown-legend {
    gap: 12px;
  }
}

/* Dark mode */
.theme-dark .start-card,
.theme-dark .completion-card {
  background: var(--bg);
  border-color: var(--line);
}

.theme-dark .start-progress,
.theme-dark .comp-breakdown {
  background: rgba(255, 255, 255, 0.05);
}

.theme-dark .start-stat-icon,
.theme-dark .comp-stat {
  background: rgba(255, 255, 255, 0.08);
}

/* ========== Submit Spinner & Error Banners ========== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.spinner-ring {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#submit-spinner {
  pointer-events: none;
}

#error-banner,
#offline-banner,
#session-warning {
  animation: slideDown 0.3s ease-out;
}

#error-banner button,
#offline-banner button,
#session-warning button {
  font-family: inherit;
}

/* Adjust main content when banners are shown */
body:has(#error-banner),
body:has(#offline-banner),
body:has(#session-warning) {
  padding-top: 52px;
}

/* Mobile adjustments for banners */
@media (max-width: 640px) {
  #error-banner,
  #offline-banner,
  #session-warning {
    font-size: 13px;
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  #error-banner span,
  #offline-banner span,
  #session-warning span {
    flex: 1 1 100%;
    text-align: center;
  }
}
