/* ==========================================================================
   AQA GCSE Science Recall — Light, Eye-Care (Warm), and Dark Themes
   ========================================================================== */

:root {
  color-scheme: light;

  --bg-page: #f5f7fa;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-tint: #f8fafc;
  --bg-input: #ffffff;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --backdrop-bg: rgba(15, 23, 42, 0.38);

  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #0f766e;
  --primary-btn: #0f766e;
  --primary-btn-hover: #0d625c;
  --primary-btn-text: #ffffff;
  --primary-soft: #f0fdfa;
  --primary-soft-border: #99f6e4;
  --primary-soft-text: #134e4a;
  --primary-ring: rgba(15, 118, 110, 0.22);

  --btn-dark-bg: #0f172a;
  --btn-dark-hover: #1e293b;
  --btn-dark-text: #ffffff;
  --btn-dark-border: transparent;

  --dot-current-bg: #0f172a;
  --dot-current-text: #ffffff;

  --pill-track-bg: #eef2f6;
  --pill-active-bg: #ffffff;
  --pill-active-border: rgba(15, 23, 42, 0.08);

  --emerald: #059669;
  --emerald-bg: #ecfdf5;
  --emerald-bg-hover: #d1fae5;
  --emerald-border: #a7f3d0;
  --emerald-text: #065f46;

  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --amber-text: #78350f;
  --amber-strong: #92400e;

  --rose: #e11d48;
  --rose-bg: #fff1f2;
  --rose-border: #fecdd3;
  --rose-text: #9f1239;

  --indigo: #4f46e5;
  --indigo-bg: #eef2ff;

  --banner-chip-bg: rgba(255, 255, 255, 0.78);
  --blurt-hit-bg: #bbf7d0;
  --blurt-hit-text: #064e3b;
  --blurt-hit-underline: #34d399;
  --blurt-miss-card-bg: rgba(255, 255, 255, 0.86);
  --blurt-miss-card-border: #fcd34d;

  /* Topic Card Accents */
  --acc-teal: #0f766e; --acc-teal-soft: #f0fdfa; --acc-teal-ring: rgba(15, 118, 110, 0.18);
  --acc-indigo: #4f46e5; --acc-indigo-soft: #eef2ff; --acc-indigo-ring: rgba(79, 70, 229, 0.16);
  --acc-amber: #b45309; --acc-amber-soft: #fffbeb; --acc-amber-ring: rgba(217, 119, 6, 0.18);
  --acc-rose: #be123c; --acc-rose-soft: #fff1f2; --acc-rose-ring: rgba(225, 29, 72, 0.16);
  --acc-emerald: #047857; --acc-emerald-soft: #ecfdf5; --acc-emerald-ring: rgba(5, 150, 105, 0.18);

  /* Periodic Table Category Swatches */
  --pt-alkali-bg: #fee2e2; --pt-alkali-border: #fca5a5;
  --pt-alkaline-bg: #ffedd5; --pt-alkaline-border: #fdba74;
  --pt-transition-bg: #fef9c3; --pt-transition-border: #fde047;
  --pt-metal-bg: #e0f2fe; --pt-metal-border: #7dd3fc;
  --pt-metalloid-bg: #f3e8ff; --pt-metalloid-border: #d8b4fe;
  --pt-nonmetal-bg: #dcfce7; --pt-nonmetal-border: #86efac;
  --pt-halogen-bg: #ccfbf1; --pt-halogen-border: #5eead4;
  --pt-noble-bg: #e0e7ff; --pt-noble-border: #a5b4fc;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-drawer: -12px 0 40px rgba(15, 23, 42, 0.14);

  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Cascadia Code", "Consolas", "SFMono-Regular", Menlo, Monaco, monospace;
}

/* ==========================================================================
   Eye-Care Mode — Warm Low-Blue-Light Parchment Palette (Easy on the Eyes)
   ========================================================================== */
:root[data-theme="eyecare"] {
  color-scheme: light;

  --bg-page: #f2ece0;
  --bg-card: #faf5eb;
  --bg-subtle: #e9e0cf;
  --bg-tint: #f4ede0;
  --bg-input: #fdfaf3;
  --topbar-bg: rgba(250, 245, 235, 0.94);
  --backdrop-bg: rgba(45, 38, 30, 0.34);

  --text-main: #2c251d;
  --text-body: #4a4034;
  --text-muted: #766858;

  --border: #ddd2be;
  --border-strong: #c8ba9f;

  --primary: #1f6d5a;
  --primary-btn: #1f6d5a;
  --primary-btn-hover: #185848;
  --primary-btn-text: #fdfaf3;
  --primary-soft: #e5f0ea;
  --primary-soft-border: #a7d1be;
  --primary-soft-text: #1b4d3e;
  --primary-ring: rgba(31, 109, 90, 0.22);

  --btn-dark-bg: #3b3227;
  --btn-dark-hover: #2c251d;
  --btn-dark-text: #faf5eb;
  --btn-dark-border: transparent;

  --dot-current-bg: #3b3227;
  --dot-current-text: #faf5eb;

  --pill-track-bg: #e7decb;
  --pill-active-bg: #fdfaf3;
  --pill-active-border: rgba(45, 38, 30, 0.12);

  --emerald: #237455;
  --emerald-bg: #e7f2ea;
  --emerald-bg-hover: #d7e8dc;
  --emerald-border: #aad2b8;
  --emerald-text: #1c543e;

  --amber: #a86416;
  --amber-bg: #f6ecd7;
  --amber-border: #dfc28e;
  --amber-text: #6e4210;
  --amber-strong: #7e4b12;

  --rose: #b4394d;
  --rose-bg: #f6e7e7;
  --rose-border: #e0b7bb;
  --rose-text: #812433;

  --indigo: #4b509c;
  --indigo-bg: #e9e8f3;

  --banner-chip-bg: rgba(253, 250, 243, 0.78);
  --blurt-hit-bg: #cbe6cf;
  --blurt-hit-text: #184a33;
  --blurt-hit-underline: #6bb587;
  --blurt-miss-card-bg: rgba(253, 250, 243, 0.85);
  --blurt-miss-card-border: #d9bb84;

  /* Softened Warm Topic Accents */
  --acc-teal: #1f6d5a; --acc-teal-soft: #e5f0ea; --acc-teal-ring: rgba(31, 109, 90, 0.18);
  --acc-indigo: #4b509c; --acc-indigo-soft: #e9e8f3; --acc-indigo-ring: rgba(75, 80, 156, 0.16);
  --acc-amber: #9c5b14; --acc-amber-soft: #f5ebd5; --acc-amber-ring: rgba(156, 91, 20, 0.18);
  --acc-rose: #a3384a; --acc-rose-soft: #f5e6e6; --acc-rose-ring: rgba(163, 56, 74, 0.16);
  --acc-emerald: #256f51; --acc-emerald-soft: #e6f1e9; --acc-emerald-ring: rgba(37, 111, 81, 0.18);

  /* Warm-Tinted Periodic Table Swatches */
  --pt-alkali-bg: #f3d9d4; --pt-alkali-border: #d9aba3;
  --pt-alkaline-bg: #f5e2cb; --pt-alkaline-border: #dbb991;
  --pt-transition-bg: #f3ecc9; --pt-transition-border: #d6c889;
  --pt-metal-bg: #dce8ec; --pt-metal-border: #a5c3cc;
  --pt-metalloid-bg: #eae1ee; --pt-metalloid-border: #c5b1ce;
  --pt-nonmetal-bg: #dcebd9; --pt-nonmetal-border: #a3c79d;
  --pt-halogen-bg: #d7ebe3; --pt-halogen-border: #96c7b5;
  --pt-noble-bg: #e1e3f0; --pt-noble-border: #b2b7d4;

  --shadow-xs: 0 1px 2px rgba(45, 38, 30, 0.05);
  --shadow-sm: 0 2px 8px rgba(45, 38, 30, 0.06), 0 1px 2px rgba(45, 38, 30, 0.04);
  --shadow-md: 0 10px 26px rgba(45, 38, 30, 0.09);
  --shadow-drawer: -12px 0 36px rgba(45, 38, 30, 0.16);
}

/* ==========================================================================
   Dark Mode — Deep Slate Night Palette (Zero Harsh OLED Halation)
   ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-page: #0e141b;
  --bg-card: #161f2b;
  --bg-subtle: #1f2b3a;
  --bg-tint: #1b2533;
  --bg-input: #101822;
  --topbar-bg: rgba(16, 23, 33, 0.92);
  --backdrop-bg: rgba(3, 7, 12, 0.65);

  --text-main: #e6edf5;
  --text-body: #cbd5e1;
  --text-muted: #94a3b8;

  --border: #283649;
  --border-strong: #3b4e68;

  --primary: #2dd4bf;
  --primary-btn: #0d9488;
  --primary-btn-hover: #0f766e;
  --primary-btn-text: #ffffff;
  --primary-soft: rgba(45, 212, 191, 0.13);
  --primary-soft-border: rgba(45, 212, 191, 0.34);
  --primary-soft-text: #99f6e4;
  --primary-ring: rgba(45, 212, 191, 0.28);

  --btn-dark-bg: #243244;
  --btn-dark-hover: #2f4056;
  --btn-dark-text: #f1f5f9;
  --btn-dark-border: #3a4d66;

  --dot-current-bg: #2dd4bf;
  --dot-current-text: #062825;

  --pill-track-bg: #0f1620;
  --pill-active-bg: #243347;
  --pill-active-border: rgba(45, 212, 191, 0.34);

  --emerald: #34d399;
  --emerald-bg: rgba(16, 185, 129, 0.14);
  --emerald-bg-hover: rgba(16, 185, 129, 0.24);
  --emerald-border: rgba(52, 211, 153, 0.36);
  --emerald-text: #a7f3d0;

  --amber: #fbbf24;
  --amber-bg: rgba(245, 158, 11, 0.14);
  --amber-border: rgba(251, 191, 36, 0.35);
  --amber-text: #fde68a;
  --amber-strong: #fcd34d;

  --rose: #fb7185;
  --rose-bg: rgba(244, 63, 94, 0.14);
  --rose-border: rgba(251, 113, 133, 0.36);
  --rose-text: #fecdd3;

  --indigo: #a5b4fc;
  --indigo-bg: rgba(99, 102, 241, 0.18);

  --banner-chip-bg: rgba(14, 20, 27, 0.55);
  --blurt-hit-bg: rgba(16, 185, 129, 0.28);
  --blurt-hit-text: #a7f3d0;
  --blurt-hit-underline: #34d399;
  --blurt-miss-card-bg: rgba(14, 20, 27, 0.52);
  --blurt-miss-card-border: rgba(251, 191, 36, 0.32);

  /* Dark-Tuned Topic Accents */
  --acc-teal: #2dd4bf; --acc-teal-soft: rgba(45, 212, 191, 0.14); --acc-teal-ring: rgba(45, 212, 191, 0.26);
  --acc-indigo: #a5b4fc; --acc-indigo-soft: rgba(129, 140, 248, 0.16); --acc-indigo-ring: rgba(129, 140, 248, 0.26);
  --acc-amber: #fbbf24; --acc-amber-soft: rgba(251, 191, 36, 0.14); --acc-amber-ring: rgba(251, 191, 36, 0.24);
  --acc-rose: #fb7185; --acc-rose-soft: rgba(251, 113, 133, 0.15); --acc-rose-ring: rgba(251, 113, 133, 0.24);
  --acc-emerald: #34d399; --acc-emerald-soft: rgba(52, 211, 153, 0.14); --acc-emerald-ring: rgba(52, 211, 153, 0.24);

  /* Dark-Tuned Periodic Table Swatches */
  --pt-alkali-bg: rgba(239, 68, 68, 0.22); --pt-alkali-border: rgba(248, 113, 113, 0.42);
  --pt-alkaline-bg: rgba(249, 115, 22, 0.22); --pt-alkaline-border: rgba(251, 146, 60, 0.42);
  --pt-transition-bg: rgba(234, 179, 8, 0.18); --pt-transition-border: rgba(250, 204, 21, 0.36);
  --pt-metal-bg: rgba(14, 165, 233, 0.2); --pt-metal-border: rgba(56, 189, 248, 0.4);
  --pt-metalloid-bg: rgba(168, 85, 247, 0.22); --pt-metalloid-border: rgba(192, 132, 252, 0.42);
  --pt-nonmetal-bg: rgba(34, 197, 94, 0.2); --pt-nonmetal-border: rgba(74, 222, 128, 0.4);
  --pt-halogen-bg: rgba(20, 184, 166, 0.22); --pt-halogen-border: rgba(45, 212, 191, 0.42);
  --pt-noble-bg: rgba(99, 102, 241, 0.22); --pt-noble-border: rgba(129, 140, 248, 0.42);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.32);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.36);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.46);
  --shadow-drawer: -12px 0 42px rgba(0, 0, 0, 0.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-main);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

button,
input,
textarea {
  font-family: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-subtle);
  padding: 0.12em 0.4em;
  border-radius: 5px;
  color: var(--text-main);
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.08rem 0.38rem;
  color: var(--text-body);
}

/* ==========================================================================
   Sticky Top Bar
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0.62rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-btn), #14b8a6);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  box-shadow: 0 2px 6px rgba(15, 118, 110, 0.25);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 0.94rem;
  letter-spacing: -0.015em;
}

.brand-text small {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Segmented Mode Switcher */
.mode-switcher {
  display: inline-flex;
  background: var(--pill-track-bg);
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  gap: 2px;
}

.mode-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.82rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  white-space: nowrap;
}

.mode-btn:hover {
  color: var(--text-main);
}

.mode-btn.is-active {
  background: var(--pill-active-bg);
  border-color: var(--pill-active-border);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

/* Theme Switcher (Light / Eye-Care / Dark) */
.theme-switcher {
  display: inline-flex;
  background: var(--pill-track-bg);
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  gap: 2px;
}

.theme-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.33rem 0.6rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.theme-btn:hover {
  color: var(--text-main);
}

:root:not([data-theme]) .theme-btn[data-theme-choice="light"],
:root[data-theme="light"] .theme-btn[data-theme-choice="light"],
:root[data-theme="eyecare"] .theme-btn[data-theme-choice="eyecare"],
:root[data-theme="dark"] .theme-btn[data-theme-choice="dark"] {
  background: var(--pill-active-bg);
  border-color: var(--pill-active-border);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.overall-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-body);
  background: var(--bg-tint);
  border: 1px solid var(--border);
  padding: 0.38rem 0.7rem;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.overall-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
}

.btn-install {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-soft-border);
  border-radius: var(--radius-pill);
  padding: 0.4rem 0.78rem;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-install:hover {
  background: var(--primary-btn);
  color: var(--primary-btn-text);
  border-color: var(--primary-btn);
}

.btn-reference {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  background: var(--btn-dark-bg);
  color: var(--btn-dark-text);
  border: 1px solid var(--btn-dark-border);
  border-radius: var(--radius-pill);
  padding: 0.42rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
  white-space: nowrap;
}

.btn-reference:hover {
  background: var(--btn-dark-hover);
}

.btn-reference .kbd-hint {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--btn-dark-text);
  font-size: 0.66rem;
}

/* ==========================================================================
   Main Layout Shell
   ========================================================================== */
.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.section-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.link-reset {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
}

.link-reset:hover {
  color: var(--rose);
  background: var(--rose-bg);
}

/* ==========================================================================
   Topic Cards Grid (with Mastery Progress Bar per Topic)
   ========================================================================== */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.topic-card {
  position: relative;
  text-align: left;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem 0.9rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.14s ease, background-color 0.18s ease;
}

.topic-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.topic-card.is-selected {
  border-color: var(--topic-accent, var(--primary));
  box-shadow: 0 0 0 3px var(--topic-ring, var(--primary-ring)), var(--shadow-sm);
}

.topic-card[data-accent="teal"] { --topic-accent: var(--acc-teal); --topic-ring: var(--acc-teal-ring); --topic-soft: var(--acc-teal-soft); }
.topic-card[data-accent="indigo"] { --topic-accent: var(--acc-indigo); --topic-ring: var(--acc-indigo-ring); --topic-soft: var(--acc-indigo-soft); }
.topic-card[data-accent="amber"] { --topic-accent: var(--acc-amber); --topic-ring: var(--acc-amber-ring); --topic-soft: var(--acc-amber-soft); }
.topic-card[data-accent="rose"] { --topic-accent: var(--acc-rose); --topic-ring: var(--acc-rose-ring); --topic-soft: var(--acc-rose-soft); }
.topic-card[data-accent="emerald"] { --topic-accent: var(--acc-emerald); --topic-ring: var(--acc-emerald-ring); --topic-soft: var(--acc-emerald-soft); }

.topic-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.topic-subject-pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--topic-accent, var(--primary));
  background: var(--topic-soft, var(--primary-soft));
  padding: 0.16rem 0.5rem;
  border-radius: var(--radius-pill);
}

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

.topic-card-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.28;
}

.topic-progress-wrap {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.topic-progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.topic-progress-labels .is-done {
  color: var(--emerald);
}

.progress-track {
  width: 100%;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--topic-accent, var(--primary));
  transition: width 0.3s ease;
}

.progress-fill.is-complete {
  background: var(--emerald);
}

/* ==========================================================================
   Workspace Panel (Cheat Sheet + Single Question)
   ========================================================================== */
.workspace-panel {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* 3-Bullet Exam Cheat Sheet Card */
.cheat-sheet-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-xs);
}

.cheat-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.cheat-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.subject-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
}

.cheat-heading {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.cheat-list {
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.cheat-list li {
  background: var(--bg-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  font-size: 0.855rem;
  color: var(--text-body);
  line-height: 1.5;
}

.cheat-list li strong {
  color: var(--text-main);
}

/* Single Question Card */
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.question-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
}

.question-meta-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.q-counter {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 0.15rem;
}

.q-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.2rem 0.62rem;
  border-radius: var(--radius-pill);
}

.q-badge-cmd {
  background: var(--indigo-bg);
  color: var(--indigo);
}

.q-badge-marks {
  background: var(--bg-subtle);
  color: var(--text-body);
}

.q-badge-mastered {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}

.question-nav-inline {
  display: flex;
  gap: 0.35rem;
}

.btn-icon-nav {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-body);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.btn-icon-nav:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

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

/* 1..12 Compact Mastery Pills */
.q-dots-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.36rem;
  padding-bottom: 1.1rem;
  margin-bottom: 1.15rem;
  border-bottom: 1px solid var(--border);
}

.q-dot-btn {
  min-width: 30px;
  height: 28px;
  padding: 0 0.45rem;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: var(--bg-tint);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.14s ease;
}

.q-dot-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-main);
}

.q-dot-btn.is-mastered {
  background: var(--emerald-bg);
  border-color: var(--emerald-border);
  color: var(--emerald);
}

.q-dot-btn.is-attempted {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber);
}

.q-dot-btn.is-current {
  border-color: var(--dot-current-bg);
  background: var(--dot-current-bg);
  color: var(--dot-current-text);
}

.q-dot-btn.is-current.is-mastered {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #ffffff;
}

/* Question Prompt & Input */
.question-prompt {
  margin: 0 0 0.4rem;
  font-size: 1.16rem;
  font-weight: 600;
  line-height: 1.48;
  color: var(--text-main);
}

.question-subprompt {
  margin: 0 0 1.05rem;
  font-size: 0.87rem;
  color: var(--text-muted);
}

.answer-input-area {
  margin-bottom: 0.8rem;
}

.text-answer-input,
.extended-textarea {
  width: 100%;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  font-size: 1rem;
  color: var(--text-main);
  background: var(--bg-input);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-answer-input::placeholder,
.extended-textarea::placeholder,
.blurt-textarea::placeholder,
.ref-search::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}

.text-answer-input.is-mono {
  font-family: var(--font-mono);
  font-size: 1.04rem;
  letter-spacing: 0.01em;
}

.text-answer-input:focus,
.extended-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px var(--primary-ring);
}

.extended-textarea {
  resize: vertical;
  min-height: 112px;
  line-height: 1.6;
}

/* MCQ Options */
.mcq-list {
  display: grid;
  gap: 0.6rem;
}

.mcq-option {
  width: 100%;
  text-align: left;
  background: var(--bg-tint);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.82rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  cursor: pointer;
  font-size: 0.94rem;
  color: var(--text-main);
  transition: border-color 0.14s ease, background 0.14s ease, box-shadow 0.14s ease;
}

.mcq-option:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.mcq-option.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.mcq-option.is-correct-choice {
  border-color: var(--emerald);
  background: var(--emerald-bg);
}

.mcq-option.is-wrong-choice {
  border-color: var(--rose);
  background: var(--rose-bg);
}

.mcq-letter {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-body);
  flex-shrink: 0;
  margin-top: 1px;
}

.mcq-option.is-selected .mcq-letter {
  background: var(--primary-btn);
  border-color: var(--primary-btn);
  color: var(--primary-btn-text);
}

/* Quick Symbol Insert Toolbar */
.symbol-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.95rem;
}

.symbol-toolbar-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.15rem;
}

.sym-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-tint);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.22rem 0.52rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.sym-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.symbol-toolbar-note {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-left: 0.35rem;
}

/* Hint Box */
.hint-box {
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  padding: 0.72rem 0.95rem;
  font-size: 0.87rem;
  color: var(--amber-text);
  margin-bottom: 1rem;
}

/* Buttons */
.question-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn-primary {
  background: var(--primary-btn);
  color: var(--primary-btn-text);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover {
  background: var(--primary-btn-hover);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.05rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.btn-secondary:hover {
  background: var(--bg-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost:hover {
  color: var(--text-main);
  background: var(--bg-subtle);
}

.btn-ghost-sm {
  background: var(--bg-subtle);
  color: var(--text-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.3rem 0.78rem;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost-sm:hover {
  background: var(--border);
}

.btn-ghost-emerald {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-sm);
  padding: 0.58rem 0.95rem;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost-emerald:hover {
  background: var(--emerald-bg-hover);
}

/* ==========================================================================
   Feedback & Mark Scheme Panel
   ========================================================================== */
.feedback-panel {
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1.5px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeSlideIn 0.2s ease-out;
}

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

.feedback-banner {
  border-radius: var(--radius-md);
  padding: 0.95rem 1.1rem;
  border: 1.5px solid var(--border);
}

.feedback-banner.is-correct {
  background: var(--emerald-bg);
  border-color: var(--emerald-border);
  color: var(--emerald-text);
}

.feedback-banner.is-partial {
  background: var(--amber-bg);
  border-color: var(--amber-border);
  color: var(--amber-strong);
}

.feedback-banner.is-incorrect {
  background: var(--rose-bg);
  border-color: var(--rose-border);
  color: var(--rose-text);
}

.feedback-banner-left {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}

.feedback-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.95rem;
  flex-shrink: 0;
  background: var(--banner-chip-bg);
}

.feedback-title-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.score-chip {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--banner-chip-bg);
  padding: 0.14rem 0.55rem;
  border-radius: var(--radius-pill);
}

.feedback-msg {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}

.mini-heading {
  margin: 0 0 0.5rem;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.mark-points-box {
  background: var(--bg-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.05rem;
}

.mark-points-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.mark-points-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.88rem;
}

.mp-badge {
  font-weight: 800;
  flex-shrink: 0;
  width: 18px;
}

.mp-hit {
  color: var(--emerald-text);
}

.mp-miss {
  color: var(--amber-strong);
}

.scheme-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 0.85rem;
}

.model-answer-box,
.mark-scheme-box {
  background: var(--bg-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.95rem 1.05rem;
}

.model-answer-text {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-main);
}

.model-answer-text.is-mono {
  font-family: var(--font-mono);
  font-size: 1.04rem;
  color: var(--primary);
}

.mark-scheme-list {
  margin: 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--text-body);
}

.feedback-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.3rem;
}

.feedback-footer-left,
.feedback-footer-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   Mode 2: 5-Minute Blurting Mode
   ========================================================================== */
.blurt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.45rem 1.55rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.blurt-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.blurt-title {
  margin: 0.45rem 0 0.3rem;
  font-size: 1.28rem;
  letter-spacing: -0.015em;
}

.blurt-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 58ch;
}

.timer-widget {
  background: var(--bg-tint);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.78rem 1rem;
  min-width: 196px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.timer-widget.is-running {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.timer-widget.is-finished {
  border-color: var(--rose);
  background: var(--rose-bg);
}

.timer-display {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.05;
  color: var(--text-main);
}

.timer-bar-track {
  width: 100%;
  height: 5px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--primary);
  transition: width 0.5s linear;
}

.timer-controls {
  display: flex;
  gap: 0.4rem;
  width: 100%;
}

.btn-timer {
  flex: 1;
  border: 1px solid var(--primary-btn);
  background: var(--primary-btn);
  color: var(--primary-btn-text);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.32rem 0.6rem;
  border-radius: 7px;
  cursor: pointer;
}

.btn-timer-muted {
  border-color: var(--border-strong);
  background: var(--bg-card);
  color: var(--text-body);
}

.blurt-editor-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.blurt-best-pill {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
  padding: 0.14rem 0.58rem;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
}

.blurt-textarea {
  width: 100%;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--text-main);
  background: var(--bg-input);
  resize: vertical;
  min-height: 210px;
}

.blurt-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px var(--primary-ring);
}

.blurt-actions {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* Blurt Results */
.blurt-results {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  animation: fadeSlideIn 0.2s ease-out;
}

.blurt-score-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-tint);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
}

.blurt-score-heading {
  margin: 0 0 0.2rem;
  font-size: 1.06rem;
}

.blurt-score-sub {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.blurt-pct-ring {
  min-width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--emerald-bg);
  border: 3px solid var(--emerald);
  color: var(--emerald);
  display: grid;
  place-items: center;
  font-size: 1.12rem;
  font-weight: 800;
  flex-shrink: 0;
}

.blurt-annotated-box {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
}

.blurt-highlighted-text {
  font-size: 0.96rem;
  line-height: 1.75;
  color: var(--text-body);
  white-space: pre-wrap;
  word-break: break-word;
}

mark.blurt-hit {
  background: var(--blurt-hit-bg);
  color: var(--blurt-hit-text);
  font-weight: 700;
  padding: 0.1em 0.34em;
  border-radius: 5px;
  box-shadow: inset 0 -1px 0 var(--blurt-hit-underline);
}

.blurt-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr);
  gap: 1rem;
}

.blurt-col {
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
}

.blurt-col-hit {
  background: var(--emerald-bg);
  border-color: var(--emerald-border);
}

.blurt-col-miss {
  background: var(--amber-bg);
  border-color: var(--amber-border);
}

.blurt-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.blurt-chip-hit {
  background: var(--bg-card);
  color: var(--emerald-text);
  border: 1px solid var(--emerald-border);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.62rem;
  border-radius: var(--radius-pill);
}

.blurt-missed-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.blurt-missed-list li {
  background: var(--blurt-miss-card-bg);
  border: 1px solid var(--blurt-miss-card-border);
  border-radius: var(--radius-sm);
  padding: 0.58rem 0.78rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-body);
}

.blurt-missed-list li strong {
  display: block;
  color: var(--amber-strong);
  margin-bottom: 0.12rem;
}

.blurt-results-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   Reference Slide-Over Drawer
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop-bg);
  backdrop-filter: blur(2px);
  z-index: 90;
}

.reference-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  height: 100vh;
  height: 100dvh;
  width: min(96vw, 680px);
  background: var(--bg-card);
  color: var(--text-main);
  border-left: 1px solid var(--border);
  z-index: 100;
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  visibility: hidden;
}

.reference-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

.drawer-header {
  padding: 1.05rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.drawer-title {
  margin: 0;
  font-size: 1.08rem;
}

.drawer-sub {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-close-drawer {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-tint);
  color: var(--text-body);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-close-drawer:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 1.25rem;
  gap: 0.3rem;
  background: var(--bg-tint);
}

.drawer-tab {
  border: 0;
  background: transparent;
  padding: 0.72rem 0.9rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1px;
}

.drawer-tab:hover {
  color: var(--text-main);
}

.drawer-tab.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.15rem 1.25rem 1.8rem;
}

.ref-search-wrap {
  margin-bottom: 1rem;
}

.ref-search {
  width: 100%;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.58rem 0.85rem;
  font-size: 0.88rem;
  background: var(--bg-input);
  color: var(--text-main);
}

.ref-section-heading {
  margin: 1.25rem 0 0.65rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.formula-group {
  margin-bottom: 1.15rem;
}

.formula-group-title {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
}

.formula-grid {
  display: grid;
  gap: 0.5rem;
}

.formula-item {
  border: 1px solid var(--border);
  background: var(--bg-tint);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.formula-name {
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-main);
}

.formula-words {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.formula-units {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.formula-sym {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.28rem 0.62rem;
  border-radius: 7px;
  white-space: nowrap;
}

/* Ions & Reactivity */
.swap-drop-tip {
  background: var(--primary-soft);
  border: 1px solid var(--primary-soft-border);
  border-radius: var(--radius-sm);
  padding: 0.72rem 0.9rem;
  font-size: 0.84rem;
  color: var(--primary-soft-text);
  margin-bottom: 1rem;
}

.ions-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.ion-col-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  background: var(--bg-tint);
}

.ion-col-card h3 {
  margin: 0 0 0.65rem;
  font-size: 0.86rem;
}

.ion-group-block {
  margin-bottom: 0.75rem;
}

.ion-group-block:last-child {
  margin-bottom: 0;
}

.ion-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.ion-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.ion-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.25rem 0.52rem;
  font-size: 0.79rem;
  color: var(--text-body);
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.ion-chip strong {
  font-family: var(--font-mono);
  color: var(--primary);
}

.reactivity-list {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.react-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.42rem 0.72rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 0.82rem;
  color: var(--text-main);
}

.react-row.is-ref {
  background: var(--amber-bg);
  border-color: var(--amber-border);
}

.react-sym {
  font-family: var(--font-mono);
  font-weight: 800;
  width: 28px;
  color: var(--primary);
}

.react-name {
  font-weight: 700;
  min-width: 82px;
}

.react-note {
  color: var(--text-muted);
  font-size: 0.77rem;
}

/* Mini Periodic Table */
.pt-hint {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.element-inspector {
  background: var(--bg-tint);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.inspector-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.inspector-tile {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: var(--primary-btn);
  color: var(--primary-btn-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
}

.inspector-tile small {
  font-size: 0.64rem;
  opacity: 0.9;
}

.inspector-tile strong {
  font-size: 1.15rem;
}

.inspector-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.95rem;
  font-size: 0.8rem;
  color: var(--text-body);
}

.inspector-stats span strong {
  color: var(--text-main);
}

.pt-scroll-wrap {
  overflow-x: auto;
  padding-bottom: 0.35rem;
}

.periodic-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(31px, 1fr));
  gap: 3px;
  min-width: 590px;
}

.pt-group-head {
  text-align: center;
  font-size: 0.64rem;
  font-weight: 800;
  color: var(--text-muted);
  padding-bottom: 2px;
}

.pt-cell {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 1px;
  min-height: 40px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.pt-cell:hover {
  transform: scale(1.08);
  z-index: 2;
  border-color: var(--text-main);
}

.pt-cell.is-selected {
  outline: 2px solid var(--text-main);
  z-index: 3;
}

.pt-ar {
  font-size: 0.53rem;
  color: var(--text-muted);
}

.pt-sym {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-main);
}

.pt-z {
  font-size: 0.54rem;
  color: var(--text-muted);
}

.cat-alkali { background: var(--pt-alkali-bg); border-color: var(--pt-alkali-border); }
.cat-alkaline { background: var(--pt-alkaline-bg); border-color: var(--pt-alkaline-border); }
.cat-transition { background: var(--pt-transition-bg); border-color: var(--pt-transition-border); }
.cat-metal { background: var(--pt-metal-bg); border-color: var(--pt-metal-border); }
.cat-metalloid { background: var(--pt-metalloid-bg); border-color: var(--pt-metalloid-border); }
.cat-nonmetal { background: var(--pt-nonmetal-bg); border-color: var(--pt-nonmetal-border); }
.cat-halogen { background: var(--pt-halogen-bg); border-color: var(--pt-halogen-border); }
.cat-noble { background: var(--pt-noble-bg); border-color: var(--pt-noble-border); }

.ref-mini-sub {
  margin: 0.9rem 0 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.heavy-elements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.pt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.9rem;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.leg-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.leg-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  display: inline-block;
}

/* Footer */
.app-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Responsive Breakpoints (Tablet & Mobile — Zero Horizontal Overflow)
   ========================================================================== */
@media (max-width: 1080px) {
  .overall-pill {
    display: none;
  }
}

@media (max-width: 960px) {
  .topic-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .cheat-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar-inner {
    padding: 0.6rem 0.9rem;
    gap: 0.55rem;
  }
  .mode-switcher {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .mode-btn {
    flex: 1;
    justify-content: center;
    padding: 0.44rem 0.6rem;
    font-size: 0.8rem;
  }
  .btn-reference .kbd-hint {
    display: none;
  }
  .theme-btn .theme-label {
    display: none;
  }
  .theme-btn {
    padding: 0.36rem 0.52rem;
    font-size: 0.84rem;
  }
  .app-shell {
    padding: 0.95rem 0.9rem 2rem;
  }
  .topic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .question-card,
  .blurt-card {
    padding: 1.1rem 1rem 1.2rem;
  }
  .scheme-grid,
  .blurt-columns,
  .ions-two-col {
    grid-template-columns: 1fr;
  }
  .timer-widget {
    width: 100%;
  }
  .feedback-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .feedback-footer-left,
  .feedback-footer-right {
    justify-content: stretch;
  }
  .feedback-footer-right button,
  .feedback-footer-left button {
    flex: 1;
  }
}

@media (max-width: 440px) {
  .topic-grid {
    grid-template-columns: 1fr;
  }
  .brand-text small {
    display: none;
  }
  .btn-ref-label {
    display: none;
  }
}
