/* ==========================================================================
   QWIK CA — MATHSCAPE-STYLE READER, 3D PAGE FLIP, NOTES BOX & MOBILE UI
   ========================================================================== */

:root {
  --bg-desk: #d6dde6;
  --bg-paper: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-tint: #f1f5f9;
  --text-ink: #0f172a;
  --text-muted: #475569;
  --border-line: #cbd5e1;

  --royal: #1e3a8a;
  --royal-light: #eff6ff;
  --gold: #b45309;
  --gold-light: #fef3c7;
  --emerald: #059669;
  --emerald-light: #d1fae5;
  --crimson: #e11d48;
  --crimson-light: #ffe4e6;
  --purple: #7c3aed;
  --purple-light: #ede9fe;

  --shadow-book: 0 20px 44px rgba(15, 23, 42, 0.22), 0 4px 12px rgba(15, 23, 42, 0.1);
}

[data-theme="dark"] {
  --bg-desk: #090d16;
  --bg-paper: #111827;
  --bg-subtle: #1e293b;
  --bg-tint: #1f2937;
  --text-ink: #f8fafc;
  --text-muted: #94a3b8;
  --border-line: #334155;

  --royal: #60a5fa;
  --royal-light: rgba(96, 165, 250, 0.14);
  --gold: #fbbf24;
  --gold-light: rgba(251, 191, 36, 0.14);
  --emerald: #34d399;
  --emerald-light: rgba(52, 211, 153, 0.14);
  --crimson: #fb7185;
  --crimson-light: rgba(251, 113, 133, 0.14);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background-color: var(--bg-desk);
  color: var(--text-ink);
  font-family: 'Plus Jakarta Sans', 'Noto Sans Devanagari', sans-serif;
  line-height: 1.5;
}

/* ==========================================================================
   1. CLEAN RESPONSIVE TOP NAVBAR
   ========================================================================== */
.app-navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #0f172a;
  color: #ffffff;
  border-bottom: 1px solid #1e293b;
  padding: 8px 0;
}

.nav-inner {
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.back-pill {
  text-decoration: none;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.back-pill:hover { background: #2563eb; color: #fff; }

.brand-logo {
  display: flex;
  align-items: center;
  gap: 7px;
}
.nav-logo-img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  background: #ffffff;
  padding: 2px;
}
.brand-title {
  font-weight: 800;
  font-size: 1.02rem;
  white-space: nowrap;
}
.brand-title span { color: #fbbf24; }

.mode-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.1);
  padding: 3px;
  border-radius: 999px;
  gap: 4px;
}
.mode-tab {
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: 0.2s;
}
.mode-tab.active {
  background: #fbbf24;
  color: #0f172a;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.date-select {
  background: #1e293b;
  color: #fff;
  border: 1px solid #475569;
  padding: 5px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.74rem;
}

.lang-toggle {
  display: inline-flex;
  background: #1e293b;
  border: 1px solid #fbbf24;
  border-radius: 999px;
  padding: 2px;
  cursor: pointer;
}
.lang-opt {
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  color: #94a3b8;
}
.lang-opt.active { background: #fbbf24; color: #0f172a; }

.btn-pdf {
  background: #ef4444;
  color: #ffffff;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 800;
  font-size: 0.74rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-pdf:hover { background: #dc2626; }

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #475569;
  background: #1e293b;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-section { display: none; }
.view-section.active { display: block; }

/* ==========================================================================
   2. BOOKLET STAGE & REALISTIC 3D PAGE-CURL ANIMATION
   ========================================================================== */
.booklet-viewport {
  position: relative;
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: 16px 54px 68px;
  min-height: calc(100vh - 54px);
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2200px;
}

.side-flip-arrow {
  position: fixed;
  top: 48%;
  transform: translateY(-50%);
  width: 42px;
  height: 74px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.82);
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}
.side-flip-arrow:hover:not(:disabled) { background: #1e3a8a; }
.side-flip-arrow:disabled { opacity: 0.2; cursor: not-allowed; }
.side-flip-arrow.left { left: 10px; }
.side-flip-arrow.right { right: 10px; }

.magazine-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  perspective: 2000px;
}

.book-spread {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  width: 100%;
  max-width: 1140px;
  background: var(--bg-paper);
  border-radius: 6px;
  box-shadow: var(--shadow-book);
  border: 1px solid var(--border-line);
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
}

.book-spread.single-page-view {
  grid-template-columns: 1fr;
  max-width: 550px;
}

/* Realistic Physical Book Page-Turn Keyframes */
.book-spread.flip-next-anim {
  animation: bookTurnNext 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}
.book-spread.flip-prev-anim {
  animation: bookTurnPrev 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes bookTurnNext {
  0% { transform: rotateY(14deg) scale(0.97); opacity: 0.75; box-shadow: -25px 15px 40px rgba(0,0,0,0.3); }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}
@keyframes bookTurnPrev {
  0% { transform: rotateY(-14deg) scale(0.97); opacity: 0.75; box-shadow: 25px 15px 40px rgba(0,0,0,0.3); }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}

/* Center Book Spine Shadow */
.book-spread:not(.single-page-view)::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 28px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(0,0,0,0.01) 0%, rgba(0,0,0,0.14) 50%, rgba(0,0,0,0.01) 100%);
  pointer-events: none;
  z-index: 5;
}

.a4-page {
  width: 100%;
  min-height: 750px;
  padding: 20px 24px 16px;
  background: var(--bg-paper);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  border-right: 1px solid var(--border-line);
  overflow: hidden;
}
.a4-page:last-child { border-right: none; }

.page-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-32deg);
  font-size: 2.8rem;
  font-weight: 900;
  color: rgba(30, 58, 138, 0.04);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  letter-spacing: 0.1em;
}

.page-content-layer { position: relative; z-index: 2; }

/* Running Header & Footer with Clickable Brand Links */
.page-running-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--royal);
  padding-bottom: 5px;
  margin-bottom: 10px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
}
.running-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--royal);
  font-weight: 900;
  text-decoration: none;
}
.running-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 3px;
}

.page-running-footer {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--border-line);
  padding-top: 6px;
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
}
.footer-brand-link {
  color: var(--text-muted);
  text-decoration: none;
}
.page-num-circle {
  background: var(--royal);
  color: #ffffff;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
}

/* ==========================================================================
   3. MATHSCAPE-STYLE FULL-WIDTH BOTTOM CONTROLLER BAR
   ========================================================================== */
.ebook-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: #090d16;
  color: #e2e8f0;
  border-top: 1px solid #1e293b;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

/* Auto-hide state for Mobile Swipe mode */
.ebook-bottom-bar.bar-hidden {
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
}

.ebook-bar-left, .ebook-bar-center, .ebook-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eb-icon-btn, .eb-nav-btn {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid transparent;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: 0.15s;
}
.eb-icon-btn:hover, .eb-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}
.eb-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.eb-page-box {
  background: #ffffff;
  color: #0f172a;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 3px 14px;
  border-radius: 4px;
  min-width: 68px;
  text-align: center;
}

.eb-cta-btn {
  background: var(--emerald);
  color: #ffffff;
  border: none;
  padding: 6px 13px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* ==========================================================================
   4. COVER PAGE, BACK COVER & NEWS PAGE WITH "MY EXAM NOTES" SPACE
   ========================================================================== */
.cover-page {
  background: linear-gradient(150deg, #0f172a 0%, #1e3a8a 58%, #172554 100%) !important;
  color: #ffffff !important;
  text-align: center;
  padding: 34px 22px !important;
  border: 6px double #fbbf24 !important;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.cover-top-badge {
  display: inline-block;
  background: rgba(251, 191, 36, 0.18) !important;
  border: 1.5px solid #fbbf24;
  color: #fde68a !important;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 5px 15px;
  border-radius: 999px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.cover-hero-logo-box {
  margin: 20px auto 16px;
  width: 136px;
  height: 136px;
  border-radius: 26px;
  background: #ffffff !important;
  padding: 14px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(251, 191, 36, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover-hero-logo { width: 100%; height: 100%; object-fit: contain; }

.cover-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(1.65rem, 4.2vw, 2.3rem);
  font-weight: 900;
  color: #ffffff !important;
  line-height: 1.15;
  margin-bottom: 6px;
}

.cover-subtitle {
  font-size: 0.85rem;
  color: #cbd5e1 !important;
  font-weight: 600;
  margin-bottom: 16px;
}

.cover-date-banner {
  background: #fbbf24 !important;
  color: #0f172a !important;
  font-weight: 900;
  font-size: 0.9rem;
  padding: 8px 20px;
  border-radius: 8px;
  display: inline-block;
  text-transform: uppercase;
}

.cover-stats-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 20px;
}
.cover-stat-card {
  background: rgba(255, 255, 255, 0.09) !important;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 11px 8px;
  border-radius: 10px;
}
.cover-stat-card strong { display: block; font-size: 1.08rem; color: #fbbf24 !important; font-weight: 800; }
.cover-stat-card span { font-size: 0.7rem; color: #e2e8f0 !important; font-weight: 600; }

/* Back Cover Practice CTA Button (Fixed Overflow on Mobile & PDF!) */
.back-cover-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  background: #fbbf24 !important;
  color: #0f172a !important;
  font-weight: 900;
  font-size: 0.88rem;
  padding: 12px 16px;
  border-radius: 999px;
  border: none;
  text-decoration: none;
  cursor: pointer;
  white-space: normal;
  text-align: center;
  line-height: 1.3;
  margin-bottom: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

/* Section Index Page */
.index-heading {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--royal);
  margin-bottom: 4px;
}
.index-sub { font-size: 0.76rem; color: var(--text-muted); margin-bottom: 12px; }
.section-index-list { display: flex; flex-direction: column; gap: 9px; }
.sec-index-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 13px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  border-left: 4px solid var(--royal);
  border-radius: 8px;
  cursor: pointer;
  gap: 8px;
}
.sec-idx-left { display: flex; align-items: center; gap: 10px; }
.sec-idx-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--royal-light);
  color: var(--royal);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sec-idx-title { font-weight: 800; font-size: 0.86rem; color: var(--text-ink); }
.sec-idx-desc { font-size: 0.7rem; color: var(--text-muted); }
.sec-idx-pages {
  background: var(--royal);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* News Page Content */
.news-top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.news-page-cat {
  background: var(--royal-light);
  color: var(--royal);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 4px;
  text-transform: uppercase;
}
.zoom-pill-hint {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--royal);
  background: var(--royal-light);
  padding: 2px 8px;
  border-radius: 999px;
}
.news-page-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.28;
  margin-bottom: 10px;
  color: var(--text-ink);
}
.detail-section-box { margin-bottom: 10px; }
.sec-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--royal);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.detail-para { font-size: 0.82rem; line-height: 1.58; margin-bottom: 8px; }
.detail-bullets { padding-left: 17px; font-size: 0.8rem; line-height: 1.54; display: flex; flex-direction: column; gap: 5px; }

.static-booster-box {
  background: var(--gold-light);
  border-left: 4px solid var(--gold);
  padding: 9px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 0.78rem;
  margin-bottom: 8px;
}
.static-booster-title { font-weight: 800; color: var(--gold); font-size: 0.68rem; text-transform: uppercase; margin-bottom: 2px; }

.extra-exam-note {
  background: var(--emerald-light);
  border-left: 4px solid var(--emerald);
  padding: 8px 11px;
  border-radius: 0 8px 8px 0;
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 10px;
}

/* Ruled "My Exam Notes & Key Takeaways" Box to Fill Blank Space Productively */
.student-notes-box {
  border: 1px dashed var(--border-line);
  background: var(--bg-subtle);
  border-radius: 8px;
  padding: 8px 12px 10px;
  margin-top: auto;
}
.notes-box-header {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}
.notes-ruled-line {
  height: 18px;
  border-bottom: 1px dotted var(--border-line);
}

/* One-Liners & Cheat Sheet */
.oneliner-list { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.oneliner-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  border-left: 3.5px solid var(--royal);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 0.8rem;
  line-height: 1.48;
}
.oneliner-num { font-weight: 800; color: var(--royal); margin-right: 4px; }

.short-summary-box {
  background: var(--bg-subtle);
  border: 1.5px solid var(--royal);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.short-grid { display: flex; flex-direction: column; gap: 5px; }
.short-row {
  display: grid;
  grid-template-columns: 125px 1fr;
  gap: 8px;
  font-size: 0.78rem;
  border-bottom: 1px dashed var(--border-line);
  padding-bottom: 4px;
}
.short-row:last-child { border-bottom: none; }
.short-key { font-weight: 700; color: var(--text-muted); }
.short-val { font-weight: 800; color: var(--text-ink); }

/* ==========================================================================
   5. UNIFIED 4-STAGE PRACTICE (PERFECT MOBILE & DESKTOP LAYOUT)
   ========================================================================== */
.practice-wrapper {
  max-width: 1260px;
  margin: 12px auto 40px;
  padding: 0 12px;
}

/* 4-Column Grid Stepper (Never overflows or cuts off on mobile!) */
.stage-stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--bg-paper);
  border: 1px solid var(--border-line);
  border-radius: 12px;
  padding: 6px;
  margin-bottom: 14px;
}
.step-pill {
  border: 1px solid transparent;
  background: var(--bg-subtle);
  color: var(--text-muted);
  padding: 8px 6px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
}
.step-pill.active {
  background: var(--royal);
  color: #ffffff;
}
.step-num {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: rgba(0,0,0,0.14);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  flex-shrink: 0;
}

.stage-box { display: none; }
.stage-box.active { display: block; }

/* Stage 1: Recall Layout with Palette */
.tcs-exam-layout {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 16px;
  align-items: start;
}
.tcs-left-panel, .tcs-right-palette {
  background: var(--bg-paper);
  border: 1px solid var(--border-line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.tcs-section-bar {
  background: #1e3a8a;
  color: #fff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 800;
}
.tcs-q-header {
  padding: 10px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 800;
  gap: 8px;
  flex-wrap: wrap;
}
.tcs-q-body { padding: 18px 16px; }
.tcs-q-prompt { font-size: 0.98rem; font-weight: 800; margin-bottom: 14px; }
.tcs-options-list { display: flex; flex-direction: column; gap: 8px; }
.tcs-radio-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border-line);
  background: var(--bg-subtle);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
}
.tcs-radio-opt.correct { border-color: var(--emerald); background: var(--emerald-light); color: var(--emerald); font-weight: 800; }
.tcs-radio-opt.wrong { border-color: var(--crimson); background: var(--crimson-light); color: var(--crimson); font-weight: 800; }

.mark-read-unlock-btn {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px dashed var(--royal);
  background: var(--royal-light);
  color: var(--royal);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.mark-read-unlock-btn:hover { background: var(--royal); color: #fff; }

.recall-question-box {
  margin-top: 14px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--purple);
  border-radius: 10px;
  padding: 14px;
}
.rq-badge {
  display: inline-block;
  background: var(--purple-light);
  color: var(--purple);
  font-size: 0.68rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.rq-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.rq-opt {
  background: var(--bg-paper);
  border: 1.5px solid var(--border-line);
  padding: 9px 11px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-ink);
  cursor: pointer;
  text-align: left;
}
.rq-opt.correct { background: var(--emerald-light); border-color: var(--emerald); color: var(--emerald); font-weight: 800; }
.rq-opt.wrong { background: var(--crimson-light); border-color: var(--crimson); color: var(--crimson); font-weight: 800; }

.tcs-exp-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--royal-light);
  border-left: 4px solid var(--royal);
  font-size: 0.8rem;
}

.tcs-action-footer {
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tcs-btn {
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid var(--border-line);
  background: var(--bg-paper);
  color: var(--text-ink);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tcs-btn.review { background: var(--purple-light); color: var(--purple); border-color: var(--purple); }
.tcs-btn.save-next { background: #1e3a8a; color: #fff; border-color: #1e3a8a; }
.tcs-btn.submit-exam { background: var(--emerald); color: #fff; border-color: var(--emerald); }

.tcs-right-palette { padding: 14px; }
.palette-legend {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 12px;
}
.leg-item { display: flex; align-items: center; gap: 6px; }
.leg-dot { width: 15px; height: 15px; border-radius: 4px; display: inline-block; }
.leg-dot.ans { background: var(--emerald); }
.leg-dot.not-ans { background: var(--crimson); }
.leg-dot.rev { background: var(--purple); border-radius: 50%; }
.leg-dot.not-vis { background: var(--bg-tint); border: 1px solid var(--border-line); }

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-bottom: 14px;
}
.p-num-btn {
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border-line);
  background: var(--bg-subtle);
  color: var(--text-ink);
  font-weight: 800;
  font-size: 0.8rem;
  cursor: pointer;
}
.p-num-btn.current { outline: 2.5px solid #fbbf24; }
.p-num-btn.answered { background: var(--emerald); color: #fff; border-color: var(--emerald); }
.p-num-btn.wrong-ans { background: var(--crimson); color: #fff; border-color: var(--crimson); }
.p-num-btn.review { background: var(--purple); color: #fff; border-radius: 50%; }

/* Final Scorecard & Share Card */
.result-summary-card {
  background: var(--bg-paper);
  border: 1px solid var(--border-line);
  border-radius: 16px;
  padding: 22px;
  text-align: center;
  margin-bottom: 18px;
}
.result-3col-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0;
  text-align: left;
}
.res-sec-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  border-top: 4px solid var(--royal);
  border-radius: 10px;
  padding: 12px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 22, 0.78);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: var(--bg-paper);
  color: var(--text-ink);
  max-width: 430px;
  width: 100%;
  border-radius: 16px;
  padding: 22px;
  text-align: center;
}
.modal-icon { font-size: 2.2rem; margin-bottom: 6px; }
.modal-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 6px; }
.modal-desc { font-size: 0.83rem; color: var(--text-muted); margin-bottom: 12px; }
.modal-score-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-line);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 14px;
  font-weight: 800;
}
.modal-actions { display: flex; justify-content: center; gap: 10px; }

.zoom-modal-card {
  background: var(--bg-paper);
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.zoom-modal-header {
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.zoom-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 0.8rem; color: #fbbf24; }
.zoom-logo { width: 24px; height: 24px; background: #fff; border-radius: 5px; padding: 2px; }
.zoom-actions { display: flex; gap: 6px; }
.zoom-close-btn { background: #ef4444; color: #fff; border: none; padding: 5px 11px; border-radius: 6px; font-weight: 800; cursor: pointer; }
.zoom-modal-body { padding: 18px; overflow-y: auto; }

.toast-msg {
  position: fixed;
  bottom: 60px;
  right: 16px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s;
  z-index: 2500;
}
.toast-msg.show { opacity: 1; }

.print-only-booklet { display: none; }

/* ==========================================================================
   6. MOBILE BREAKPOINTS
   ========================================================================== */
@media (max-width: 960px) {
  .booklet-viewport { padding: 10px 10px 64px; min-height: auto; }
  .side-flip-arrow { display: none; }
  .book-spread { grid-template-columns: 1fr; max-width: 540px; }
  .book-spread::after { display: none; }
  .a4-page { min-height: auto; padding: 18px 15px; }
  .tcs-exam-layout { grid-template-columns: 1fr; }
  .result-3col-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .hide-xs, .hide-sm { display: none; }
  .nav-inner { padding: 0 8px; gap: 6px; }
  .mode-tabs { order: 3; width: 100%; }
  .mode-tab { flex: 1; justify-content: center; padding: 7px 8px; font-size: 0.76rem; }
  .step-pill { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 0.68rem; }
  .short-row { grid-template-columns: 100px 1fr; }
  .rq-options { grid-template-columns: 1fr; }
  .ebook-bottom-bar { padding: 0 8px; }
  .eb-page-box { min-width: 52px; padding: 3px 8px; font-size: 0.72rem; }
}

/* ==========================================================================
   7. PRINT & PDF EXPORT ENGINE (IDENTICAL COVER & FULL A4 PAGES)
   ========================================================================== */
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { background: #ffffff !important; color: #0f172a !important; }
  .no-print { display: none !important; }
  #view-booklet, .print-only-booklet { display: block !important; }
  .print-only-booklet .a4-page {
    width: 210mm !important;
    height: 296mm !important;
    min-height: 296mm !important;
    padding: 12mm 15mm !important;
    page-break-after: always !important;
    break-after: page !important;
    border: none !important;
    box-shadow: none !important;
  }
}