/* ============================================================
   CTRR INTERACTIVE BOOK — Global Styles
   Design: Dark mode, purple-violet theme, premium feel
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --bg-primary:    #0d0f1a;
  --bg-secondary:  #12152b;
  --bg-card:       #181c35;
  --bg-highlight:  #1e2340;
  --bg-glass:      rgba(30,35,80,0.55);

  --accent-1:      #7c3aed;   /* purple */
  --accent-2:      #a855f7;   /* light purple */
  --accent-3:      #6366f1;   /* indigo */
  --accent-amber:  #f59e0b;
  --accent-cyan:   #22d3ee;
  --accent-rose:   #f43f5e;
  --accent-emerald:#10b981;

  --text-primary:  #e2e8f0;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;
  --text-inverse:  #0d0f1a;

  --border:        rgba(124,58,237,0.25);
  --border-bright: rgba(168,85,247,0.5);
  --shadow-card:   0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow:   0 0 30px rgba(124,58,237,0.3);

  --sidebar-w:     280px;
  --topbar-h:      60px;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;

  --font-body:     'Be Vietnam Pro', sans-serif;
  --font-mono:     'JetBrains Mono', monospace;

  --transition:    0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.7;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--accent-1); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-2); }

/* ── Layout ────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.sidebar-logo .book-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(124,58,237,0.5);
}

.sidebar-logo .logo-text { line-height: 1.2; }
.sidebar-logo .logo-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.sidebar-logo .logo-subtitle { font-size: 11px; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-section-label {
  padding: 10px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1px 8px 1px 0;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-highlight);
  border-left-color: var(--accent-1);
}

.nav-item.active {
  color: var(--accent-2);
  background: rgba(124,58,237,0.15);
  border-left-color: var(--accent-2);
  font-weight: 600;
}

.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8; }
.nav-item.active .nav-icon { opacity: 1; }

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 700;
  background: rgba(124,58,237,0.2);
  color: var(--accent-2);
}

/* Chapter progress indicator */
.chapter-progress-bar {
  height: 3px;
  background: var(--bg-highlight);
  margin: 0 20px 12px;
  border-radius: 99px;
  overflow: hidden;
}
.chapter-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  border-radius: 99px;
  transition: width 0.5s ease;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

.main-content.full-width { margin-left: 0; }

/* Top Bar */
.topbar {
  position: sticky; top: 0;
  height: var(--topbar-h);
  background: rgba(13,15,26,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-toggle {
  background: none; border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.topbar-toggle:hover { background: var(--bg-highlight); color: var(--text-primary); }

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-secondary);
  flex: 1;
}
.topbar-breadcrumb span { color: var(--text-primary); font-weight: 600; }
.topbar-breadcrumb .sep { color: var(--text-muted); }

.topbar-actions { display: flex; gap: 8px; }

.topbar-btn {
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
  display: flex; align-items: center; gap: 6px;
}
.topbar-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }

/* Page Content */
.page-content {
  padding: 32px 40px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* ── Typography ────────────────────────────────────────────── */
.page-hero {
  margin-bottom: 40px;
  position: relative;
}

.chapter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-2);
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(168,85,247,0.3);
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 16px;
}

.page-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 800;
  line-height: 1.15;
  background: linear-gradient(135deg, #e2e8f0 0%, var(--accent-2) 60%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.page-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 700px;
  line-height: 1.65;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 40px 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::before {
  content: '';
  display: block;
  width: 4px; height: 24px;
  background: linear-gradient(to bottom, var(--accent-1), var(--accent-2));
  border-radius: 2px;
  flex-shrink: 0;
}

.subsection-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-2);
  margin: 24px 0 12px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-bright); box-shadow: var(--shadow-glow); }

.card-glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.card-accent { border-left: 4px solid var(--accent-1); }
.card-amber  { border-left: 4px solid var(--accent-amber); }
.card-cyan   { border-left: 4px solid var(--accent-cyan); }
.card-rose   { border-left: 4px solid var(--accent-rose); }
.card-emerald{ border-left: 4px solid var(--accent-emerald); }

.card-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.card-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.card-desc  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Alert Boxes ───────────────────────────────────────────── */
.alert {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin: 16px 0;
  border: 1px solid;
}
.alert-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }
.alert-content { flex: 1; }
.alert-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.alert-body  { font-size: 13.5px; line-height: 1.6; }

.alert-tip     { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.35); }
.alert-tip     .alert-icon, .alert-tip .alert-title { color: var(--accent-emerald); }

.alert-warning { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.35); }
.alert-warning .alert-icon, .alert-warning .alert-title { color: var(--accent-amber); }

.alert-info    { background: rgba(99,102,241,0.08); border-color: rgba(99,102,241,0.35); }
.alert-info    .alert-icon, .alert-info    .alert-title { color: #818cf8; }

.alert-danger  { background: rgba(244,63,94,0.08); border-color: rgba(244,63,94,0.35); }
.alert-danger  .alert-icon, .alert-danger  .alert-title { color: var(--accent-rose); }

/* ── Formula / Math blocks ─────────────────────────────────── */
.formula-block {
  background: var(--bg-highlight);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 16px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.formula-block::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(124,58,237,0.05) 0%, transparent 60%);
  pointer-events: none;
}

.formula-block .formula-label {
  position: absolute;
  top: 8px; right: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-1);
  background: rgba(124,58,237,0.15);
  padding: 2px 8px;
  border-radius: 99px;
}

.formula-main {
  font-size: 1.2rem;
  color: var(--text-primary);
  margin: 8px 0 4px;
}

.formula-note { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ── Template / Steps ──────────────────────────────────────── */
.steps-container { margin: 16px 0; }

.step-item {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  position: relative;
}

.step-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 18px; top: 44px;
  width: 2px;
  bottom: -8px;
  background: linear-gradient(to bottom, var(--accent-1), transparent);
}

.step-num {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 0 14px rgba(124,58,237,0.4);
}

.step-content { flex: 1; padding-top: 6px; }
.step-title { font-size: 14px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.step-desc  { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; }

/* ── Code / Solution blocks ────────────────────────────────── */
.solution-block {
  background: #0a0c18;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 16px 0;
  font-family: var(--font-mono);
}

.solution-header {
  background: var(--bg-highlight);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}

.solution-dots { display: flex; gap: 6px; }
.solution-dot  { width: 10px; height: 10px; border-radius: 50%; }
.dot-red   { background: #f87171; }
.dot-yellow{ background: #fbbf24; }
.dot-green { background: #4ade80; }

.solution-title {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  flex: 1; text-align: center;
  font-family: var(--font-body);
}

.solution-body {
  padding: 20px 24px;
  font-size: 14px;
  line-height: 2;
  color: var(--text-primary);
}

.solution-line {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 16px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.solution-line:last-child { border-bottom: none; }

.solution-line .math { color: var(--text-primary); }
.solution-line .rule {
  font-size: 11px;
  color: var(--accent-2);
  background: rgba(168,85,247,0.1);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-family: var(--font-body);
  font-weight: 600;
}

.solution-line .premise { color: var(--accent-cyan); font-size: 11px; font-weight: 600; }
.solution-line .conclusion { color: var(--accent-emerald); font-weight: 700; }

/* ── Table ─────────────────────────────────────────────────── */
.styled-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 16px 0;
}

.styled-table th {
  background: rgba(124,58,237,0.2);
  color: var(--accent-2);
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--accent-1);
}

.styled-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.styled-table tr:hover td { background: var(--bg-highlight); color: var(--text-primary); }

.styled-table .highlight-row td { color: var(--text-primary); background: rgba(124,58,237,0.05); }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs-container { margin: 20px 0; }

.tabs-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 10px 20px;
  font-size: 13.5px; font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: -2px;
  font-family: var(--font-body);
  display: flex; align-items: center; gap: 6px;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
  background: rgba(168,85,247,0.06);
}

.tab-panel {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 24px;
  animation: fadeIn 0.2s ease;
}
.tab-panel.active { display: block; }

/* ── Badge / Chips ─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 12px;
  border-radius: 99px;
  font-size: 12px; font-weight: 700;
}
.badge-purple  { background: rgba(124,58,237,0.2); color: var(--accent-2); border: 1px solid rgba(124,58,237,0.4); }
.badge-amber   { background: rgba(245,158,11,0.15); color: var(--accent-amber); border: 1px solid rgba(245,158,11,0.4); }
.badge-cyan    { background: rgba(34,211,238,0.1); color: var(--accent-cyan); border: 1px solid rgba(34,211,238,0.3); }
.badge-rose    { background: rgba(244,63,94,0.1); color: var(--accent-rose); border: 1px solid rgba(244,63,94,0.3); }
.badge-emerald { background: rgba(16,185,129,0.1); color: var(--accent-emerald); border: 1px solid rgba(16,185,129,0.3); }

/* ── Hasse Diagram ─────────────────────────────────────────── */
.hasse-svg-container {
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
}

/* ── Grid layouts ──────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 16px; }

@media (max-width: 768px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes pulse-glow { 0%,100% { box-shadow: 0 0 16px rgba(124,58,237,0.3); } 50% { box-shadow: 0 0 32px rgba(124,58,237,0.6); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

.animate-fade   { animation: fadeIn 0.4s ease both; }
.animate-slide  { animation: slideInLeft 0.4s ease both; }
.animate-float  { animation: float 3s ease-in-out infinite; }
.animate-glow   { animation: pulse-glow 2s ease-in-out infinite; }

/* ── Interactive highlight ─────────────────────────────────── */
.highlight-box {
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(168,85,247,0.05));
  border: 1px solid rgba(168,85,247,0.3);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 12px 0;
  position: relative;
  overflow: hidden;
}

.highlight-box::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(to bottom, var(--accent-1), var(--accent-2));
}

/* ── Sidebar overlay (mobile) ──────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* ── Footer nav ────────────────────────────────────────────── */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 32px 0 48px;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

.chapter-nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px; font-weight: 600;
  transition: all var(--transition);
}
.chapter-nav-btn:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
  background: rgba(168,85,247,0.08);
}
.chapter-nav-btn .label { font-size: 11px; color: var(--text-muted); font-weight: 400; display: block; margin-bottom: 2px; }

/* ── Tricks panel ──────────────────────────────────────────── */
.trick-card {
  background: linear-gradient(135deg, rgba(245,158,11,0.12), rgba(245,158,11,0.04));
  border: 1px solid rgba(245,158,11,0.35);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 16px 0;
}
.trick-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
  font-size: 13px; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-amber);
}
.trick-body { font-size: 13.5px; color: var(--text-secondary); line-height: 1.7; }

/* ── Stats / Overview ──────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  transform: scaleX(0);
  transition: transform var(--transition);
}
.stat-card:hover::after { transform: scaleX(1); }
.stat-card:hover { border-color: var(--border-bright); }

.stat-value { font-size: 36px; font-weight: 800; color: var(--accent-2); line-height: 1; margin-bottom: 6px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Definition list ───────────────────────────────────────── */
.def-list { margin: 12px 0; }
.def-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.def-item:last-child { border-bottom: none; }
.def-term { font-weight: 700; color: var(--accent-2); min-width: 200px; font-size: 14px; flex-shrink: 0; }
.def-desc { color: var(--text-secondary); font-size: 14px; line-height: 1.6; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay { display: block; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 24px 20px; }
  .def-item { flex-direction: column; gap: 4px; }
  .def-term { min-width: unset; }
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar { display: none; }
  .main-content { margin-left: 0; }
  .page-content { padding: 0; }
}

/* ── MathJax override ──────────────────────────────────────── */
.MathJax { color: var(--text-primary) !important; }

/* ── Checklist ─────────────────────────────────────────────── */
.checklist { list-style: none; margin: 12px 0; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: color var(--transition);
}
.checklist li:last-child { border-bottom: none; }
.checklist li:hover { color: var(--text-primary); }
.checklist li.done { color: var(--accent-emerald); text-decoration: line-through; }
.checklist li .check-box {
  width: 18px; height: 18px;
  border: 2px solid var(--border-bright);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  transition: all var(--transition);
}
.checklist li.done .check-box {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
  color: white;
}

/* ════════════════════════════════════════════════════════════
   LIGHT MODE
   Applied via [data-theme="light"] on <html>
   ════════════════════════════════════════════════════════════ */
[data-theme="light"] {
  --bg-primary:    #f4f5fb;
  --bg-secondary:  #eceef8;
  --bg-card:       #ffffff;
  --bg-highlight:  #ede9fd;
  --bg-glass:      rgba(237,233,253,0.8);

  --accent-1:      #6d28d9;
  --accent-2:      #7c3aed;
  --accent-amber:  #d97706;
  --accent-cyan:   #0891b2;
  --accent-rose:   #e11d48;
  --accent-emerald:#059669;

  --text-primary:  #1e1b4b;
  --text-secondary:#4c4a6e;
  --text-muted:    #9094b5;

  --border:        rgba(109,40,217,0.15);
  --border-bright: rgba(124,58,237,0.4);
  --shadow-card:   0 4px 24px rgba(109,40,217,0.08);
  --shadow-glow:   0 0 20px rgba(109,40,217,0.12);
}

[data-theme="light"] body { transition: background 0.3s, color 0.3s; }

/* Page title gradient (lighter) */
[data-theme="light"] .page-title {
  background: linear-gradient(135deg, #3b0764 0%, #6d28d9 55%, #0891b2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Solution block */
[data-theme="light"] .solution-block { background: #f5f3ff; }
[data-theme="light"] .solution-header { background: #ede9fd; }
[data-theme="light"] .solution-body { color: var(--text-primary); }
[data-theme="light"] .solution-line { border-bottom-color: rgba(0,0,0,0.04); }
[data-theme="light"] .solution-line .math { color: #1e1b4b; }
[data-theme="light"] .solution-line .rule { background: rgba(109,40,217,0.1); color: #6d28d9; }
[data-theme="light"] .solution-line .premise { color: #0891b2; }
[data-theme="light"] .solution-line .conclusion { color: #059669; }

/* Topbar */
[data-theme="light"] .topbar { background: rgba(244,245,251,0.92); }
[data-theme="light"] .topbar-btn { background: #ede9fd; }
[data-theme="light"] .topbar-toggle:hover { background: #ede9fd; }

/* Sidebar */
[data-theme="light"] .nav-item.active { background: rgba(109,40,217,0.1); }
[data-theme="light"] .nav-item:hover  { background: rgba(109,40,217,0.06); }
[data-theme="light"] .nav-item .nav-badge { background: rgba(109,40,217,0.12); }

/* Formula / Highlight */
[data-theme="light"] .formula-block { background: #f5f3ff; }
[data-theme="light"] .formula-block::before { background: none; }
[data-theme="light"] .formula-block .formula-label { background: rgba(109,40,217,0.12); }
[data-theme="light"] .highlight-box { background: linear-gradient(135deg,rgba(109,40,217,0.06),rgba(124,58,237,0.02)); }
[data-theme="light"] .highlight-box::before { background: linear-gradient(to bottom,#6d28d9,#7c3aed); }

/* Trick card */
[data-theme="light"] .trick-card { background: linear-gradient(135deg,rgba(217,119,6,0.07),rgba(217,119,6,0.02)); border-color: rgba(217,119,6,0.3); }

/* Alerts */
[data-theme="light"] .alert-tip     { background: rgba(5,150,105,0.06); }
[data-theme="light"] .alert-warning { background: rgba(217,119,6,0.06); }
[data-theme="light"] .alert-info    { background: rgba(99,102,241,0.06); }
[data-theme="light"] .alert-danger  { background: rgba(225,29,72,0.05); }

/* Table */
[data-theme="light"] .styled-table th { background: rgba(109,40,217,0.08); }
[data-theme="light"] .styled-table td { border-bottom-color: rgba(109,40,217,0.1); color: var(--text-secondary); }
[data-theme="light"] .styled-table tr:hover td { background: #ede9fd; color: var(--text-primary); }

/* Tabs */
[data-theme="light"] .tab-panel { background: #ffffff; }
[data-theme="light"] .tab-btn { color: var(--text-muted); }
[data-theme="light"] .tab-btn:hover { color: var(--text-primary); }

/* Badges */
[data-theme="light"] .badge-purple { background: rgba(109,40,217,0.1); color: #6d28d9; border-color: rgba(109,40,217,0.3); }
[data-theme="light"] .badge-amber  { background: rgba(217,119,6,0.1); color: #d97706; border-color: rgba(217,119,6,0.3); }
[data-theme="light"] .badge-cyan   { background: rgba(8,145,178,0.1); color: #0891b2; border-color: rgba(8,145,178,0.3); }
[data-theme="light"] .badge-rose   { background: rgba(225,29,72,0.08); color: #e11d48; border-color: rgba(225,29,72,0.25); }
[data-theme="light"] .badge-emerald{ background: rgba(5,150,105,0.08); color: #059669; border-color: rgba(5,150,105,0.25); }

/* Stat cards */
[data-theme="light"] .stat-value { color: #6d28d9; }
[data-theme="light"] .stat-card  { box-shadow: 0 2px 12px rgba(109,40,217,0.06); }

/* Hasse */
[data-theme="light"] .hasse-svg-container { background: #f5f3ff; }

/* Scrollbar */
[data-theme="light"] ::-webkit-scrollbar-track { background: #eceef8; }

/* Checklist */
[data-theme="light"] .checklist li { color: var(--text-secondary); }
[data-theme="light"] .checklist li:hover { color: var(--text-primary); }

/* Chapter progress */
[data-theme="light"] .chapter-progress-bar { background: #ddd9f7; }

/* Section title bar */
[data-theme="light"] .section-title { color: #1e1b4b; }

/* Definition list */
[data-theme="light"] .def-term { color: #6d28d9; }
[data-theme="light"] .def-item { border-bottom-color: rgba(109,40,217,0.1); }

/* Steps */
[data-theme="light"] .step-desc { color: var(--text-secondary); }

/* Chapter nav buttons */
[data-theme="light"] .chapter-nav-btn { background: #ffffff; }
[data-theme="light"] .chapter-nav-btn:hover { background: #ede9fd; color: #6d28d9; border-color: #6d28d9; }
[data-theme="light"] .chapter-nav { border-top-color: var(--border); }

/* Card left borders stay the same in light mode */

/* ── Theme Toggle Button ────────────────────────────────────── */
.theme-toggle {
  background: var(--bg-highlight);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent-2); color: var(--accent-2); }
/* Dark: show sun icon (switch to light). Light: show moon icon (switch to dark). */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none;  }
[data-theme="light"] .theme-toggle .icon-moon { display: none;  }
[data-theme="light"] .theme-toggle .icon-sun  { display: block; }

/* ── Exam solution specifics ────────────────────────────────── */
.exam-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 14px;
  border-radius: 99px;
  font-size: 11px; font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.exam-badge-hk1 { background: rgba(124,58,237,0.15); color: var(--accent-2); border: 1px solid rgba(168,85,247,0.35); }
.exam-badge-hk2 { background: rgba(34,211,238,0.1); color: var(--accent-cyan); border: 1px solid rgba(34,211,238,0.3); }

.exam-question {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  margin-bottom: 24px;
  transition: border-color var(--transition);
}
.exam-question:hover { border-color: var(--border-bright); }

.exam-q-header {
  background: var(--bg-highlight);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.exam-q-num {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800;
  color: white; flex-shrink: 0;
}
.exam-q-title { flex: 1; font-weight: 700; font-size: 15px; color: var(--text-primary); }
.exam-q-points { font-size: 12px; font-weight: 700; color: var(--accent-amber); }
.exam-q-chevron {
  color: var(--text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.exam-question.open .exam-q-chevron { transform: rotate(180deg); }

.exam-q-body { display: none; padding: 20px; }
.exam-question.open .exam-q-body { display: block; }

.exam-sub {
  margin: 12px 0;
  padding: 14px 16px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-3);
}
.exam-sub-label { font-size: 12px; font-weight: 800; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.exam-sub-text  { font-size: 13.5px; color: var(--text-secondary); line-height: 1.7; }

[data-theme="light"] .exam-sub { background: #f8f7ff; }
[data-theme="light"] .exam-q-header { background: #ede9fd; }

