/* ============================================================
   FOREX COURSE — Design System
   Inspired by: Notion, Linear, GitBook
   Palette: Zinc/Slate neutral + muted teal accent
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  /* Base neutral palette */
  --zinc-50: #fafafa;
  --zinc-100: #f4f4f5;
  --zinc-200: #e4e4e7;
  --zinc-300: #d4d4d8;
  --zinc-400: #a1a1aa;
  --zinc-500: #71717a;
  --zinc-600: #52525b;
  --zinc-700: #3f3f46;
  --zinc-800: #27272a;
  --zinc-850: #1f1f23;
  --zinc-900: #18181b;
  --zinc-950: #09090b;

  /* Accent — muted teal */
  --accent: #5eead4;
  --accent-muted: #2dd4bf;
  --accent-dim: rgba(94, 234, 212, 0.15);
  --accent-text: #14b8a6;

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Transition */
  --transition: 150ms ease;
  --transition-slow: 250ms ease;

  /* Reader font size (set by JS) */
  --reader-font-size: 1rem;
}

/* ---------- Dark Theme (default) ---------- */
[data-theme="dark"] {
  --bg-primary: var(--zinc-950);
  --bg-secondary: var(--zinc-900);
  --bg-card: var(--zinc-850);
  --bg-card-hover: var(--zinc-800);
  --bg-elevated: var(--zinc-800);
  --bg-input: var(--zinc-800);
  --border: var(--zinc-700);
  --border-subtle: var(--zinc-800);
  --text-primary: var(--zinc-100);
  --text-secondary: var(--zinc-400);
  --text-muted: var(--zinc-500);
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.5);
}

/* ---------- Light Theme ---------- */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: var(--zinc-50);
  --bg-card: #ffffff;
  --bg-card-hover: var(--zinc-50);
  --bg-elevated: #ffffff;
  --bg-input: var(--zinc-100);
  --border: var(--zinc-200);
  --border-subtle: var(--zinc-100);
  --text-primary: var(--zinc-900);
  --text-secondary: var(--zinc-600);
  --text-muted: var(--zinc-500);
  --accent-text: #0d9488;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition-slow), color var(--transition-slow);
}

a {
  color: var(--accent-text);
  text-decoration: none;
  transition: opacity var(--transition);
}
a:hover { opacity: 0.8; }

/* ---------- HEADER ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}
.logo:hover { opacity: 1; }
.logo-icon { color: var(--accent); font-size: 1.3rem; }
.logo-accent { color: var(--accent-text); }

.nav {
  display: flex;
  gap: var(--space-xs);
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
  opacity: 1;
}
.nav-link.active {
  color: var(--accent-text);
  background: var(--accent-dim);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: all var(--transition);
}
.theme-toggle:hover {
  border-color: var(--accent-text);
  background: var(--accent-dim);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

/* ---------- PAGE LAYOUT ---------- */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
  min-height: calc(100vh - 56px - 80px);
}

.page-header {
  margin-bottom: var(--space-xl);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-xs);
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ---------- WIDGETS ---------- */
.widget {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: border-color var(--transition);
}
.widget:hover {
  border-color: var(--border);
}

.widget h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

/* Progress Widget */
.widget-progress {
  margin-bottom: var(--space-xl);
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.progress-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-text);
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 999px;
  margin: var(--space-md) 0 var(--space-sm);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-text), var(--accent));
  border-radius: 999px;
  transition: width 0.5s ease;
  min-width: 0;
}

.progress-detail {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

/* Continue Card */
.continue-card {
  cursor: pointer;
  padding: var(--space-md);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition);
  position: relative;
}
.continue-card:hover {
  border-color: var(--accent-text);
  background: var(--accent-dim);
}
.continue-card h4 {
  margin: var(--space-sm) 0 var(--space-xs);
  font-size: 0.95rem;
}
.continue-arrow {
  position: absolute;
  right: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-text);
  font-size: 1.2rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.stat-item {
  text-align: center;
  padding: var(--space-md) var(--space-sm);
  border-radius: var(--radius);
  background: var(--bg-input);
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-text);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Bookmark List */
.bookmark-list {
  list-style: none;
}

.bookmark-item {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}
.bookmark-item:last-child { border-bottom: none; }
.bookmark-item:hover {
  background: var(--bg-card-hover);
}

/* Badge Grid */
.badge-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.badge-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-dim);
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-icon { font-size: 1rem; }

/* Quiz Level Grid */
.quiz-level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.quiz-level-card {
  padding: var(--space-md);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
  position: relative;
}
.quiz-level-card:hover {
  border-color: var(--accent-text);
  background: var(--accent-dim);
}
.quiz-score {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: var(--space-sm);
}
.quiz-score.pass { color: #34d399; }
.quiz-score.fail { color: #f87171; }

/* ---------- LEVEL BADGES ---------- */
.level-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.level-foundation { background: var(--zinc-700); color: var(--zinc-200); }
.level-beginner { background: rgba(52, 211, 153, 0.15); color: #34d399; }
.level-intermediate { background: rgba(96, 165, 250, 0.15); color: #60a5fa; }
.level-advanced { background: rgba(251, 146, 60, 0.15); color: #fb923c; }
.level-professional { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

[data-theme="light"] .level-foundation { background: var(--zinc-200); color: var(--zinc-600); }

/* Status Badge */
.status-badge {
  font-size: 0.75rem;
  font-weight: 500;
}
.status-done { color: #34d399; }
.status-pending { color: var(--text-muted); }

/* ---------- FILTER BAR ---------- */
.filter-bar {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-group select,
.filter-group input {
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition);
  min-width: 160px;
}

.filter-group select:focus,
.filter-group input:focus {
  border-color: var(--accent-text);
}

.filter-search { flex: 1; min-width: 200px; }
.filter-search input { width: 100%; }

/* ---------- COURSE LIST ---------- */
.course-section {
  margin-bottom: var(--space-2xl);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
}

.section-icon { font-size: 1.3rem; }

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subsection-group {
  margin-bottom: var(--space-xl);
}

.subsection-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Module Cards */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

.module-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all var(--transition);
}
.module-card:hover {
  border-color: var(--border);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.module-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.bookmark-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-muted);
  padding: 2px;
  transition: all var(--transition);
}
.bookmark-btn.bookmarked { color: #fbbf24; }
.bookmark-btn:hover { color: #fbbf24; transform: scale(1.2); }

.module-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  line-height: 1.4;
}

.module-card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.module-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- READER LAYOUT ---------- */
.reader-layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg);
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: var(--space-2xl);
  min-height: calc(100vh - 56px - 80px);
  position: relative;
}

.reader-main {
  max-width: 720px;
  width: 100%;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8rem;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent-text); }
.breadcrumb-sep { color: var(--text-muted); }
.breadcrumb span:last-child { color: var(--text-secondary); }

/* Reader Header */
.reader-header {
  margin-bottom: var(--space-xl);
}

.reader-meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.reading-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.reader-title {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

/* Reader Content */
.reader-content {
  line-height: 1.75;
  font-size: var(--reader-font-size);
  color: var(--text-primary);
}

.reader-content h1 { font-size: 1.6rem; margin: 2rem 0 1rem; font-weight: 700; letter-spacing: -0.02em; }
.reader-content h2 { font-size: 1.35rem; margin: 1.75rem 0 0.75rem; font-weight: 700; letter-spacing: -0.01em; padding-bottom: 0.3rem; border-bottom: 1px solid var(--border-subtle); }
.reader-content h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; font-weight: 600; }
.reader-content h4 { font-size: 1rem; margin: 1.25rem 0 0.5rem; font-weight: 600; color: var(--text-secondary); }

.reader-content p { margin-bottom: 1rem; }

.reader-content ul, .reader-content ol {
  margin: 0.5rem 0 1rem 1.5rem;
}
.reader-content li { margin-bottom: 0.3rem; }

.reader-content blockquote {
  border-left: 3px solid var(--accent-text);
  padding: var(--space-md) var(--space-lg);
  margin: 1rem 0;
  background: var(--accent-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.reader-content code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
}

.reader-content pre {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: var(--space-lg);
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.875rem;
  line-height: 1.6;
}
.reader-content pre code {
  background: none;
  padding: 0;
}

.reader-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
  overflow-x: auto;
  display: block;
}
.reader-content thead { background: var(--bg-input); }
.reader-content th, .reader-content td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.reader-content th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

.reader-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1rem 0;
}

.reader-content strong { font-weight: 600; }
.reader-content hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 2rem 0;
}

/* TOC Sidebar */
.reader-toc {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: var(--space-md);
}

.toc-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: all var(--transition);
  line-height: 1.4;
}
.toc-link:hover {
  color: var(--text-primary);
  border-left-color: var(--accent-text);
  opacity: 1;
}
.toc-h3 { padding-left: 20px; font-size: 0.75rem; }

/* Reader Navigation */
.reader-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--border-subtle);
}

.reader-nav-btn {
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  transition: all var(--transition);
  color: var(--text-primary);
}
.reader-nav-btn:hover {
  border-color: var(--accent-text);
  background: var(--accent-dim);
  opacity: 1;
}
.nav-next { text-align: right; }
.nav-direction {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.nav-title {
  font-size: 0.9rem;
  font-weight: 500;
}

/* Floating Bookmark */
.floating-bookmark {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition);
  z-index: 50;
  color: var(--text-muted);
}
.floating-bookmark:hover {
  border-color: #fbbf24;
  transform: scale(1.1);
}
.floating-bookmark.bookmarked { color: #fbbf24; }

/* ---------- QUIZ STYLES ---------- */
.quiz-start-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}
.quiz-start-card p {
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
}

.quiz-timer {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent-text);
  margin-bottom: var(--space-xl);
  padding: var(--space-md);
  background: var(--accent-dim);
  border-radius: var(--radius);
  position: sticky;
  top: 64px;
  z-index: 10;
}

.quiz-question {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.question-number {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

.question-text {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
}

.options-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.option-label {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.9rem;
}
.option-label:hover {
  border-color: var(--border);
  background: var(--bg-card-hover);
}
.option-label input[type="radio"] {
  accent-color: var(--accent-text);
}

.btn-submit-quiz {
  width: 100%;
  margin-top: var(--space-md);
}

/* Quiz Results */
.quiz-result { max-width: 720px; }
.quiz-result-header {
  text-align: center;
  margin-bottom: var(--space-xl);
  padding: var(--space-xl);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}
.quiz-final-score {
  font-size: 3rem;
  font-weight: 700;
  margin: var(--space-md) 0;
}
.quiz-final-score.pass { color: #34d399; }
.quiz-final-score.fail { color: #f87171; }
.badge-earned { color: #fbbf24; font-weight: 600; }

.quiz-review {
  padding: var(--space-lg);
  border-radius: var(--radius);
  margin-bottom: var(--space-md);
  border-left: 3px solid;
}
.review-correct {
  background: rgba(52, 211, 153, 0.08);
  border-color: #34d399;
}
.review-wrong {
  background: rgba(248, 113, 113, 0.08);
  border-color: #f87171;
}
.quiz-review h4 { margin-bottom: var(--space-sm); font-size: 0.95rem; }
.your-answer { font-size: 0.9rem; margin-bottom: var(--space-xs); }
.correct-answer { font-size: 0.9rem; color: #34d399; margin-bottom: var(--space-xs); }
.explanation { font-size: 0.85rem; color: var(--text-secondary); margin-top: var(--space-sm); font-style: italic; }

.quiz-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

.prev-score-widget {
  margin-bottom: var(--space-lg);
}
.prev-score {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-text);
  color: #000;
  border-color: var(--accent-text);
}
.btn-primary:hover {
  opacity: 0.9;
  color: #000;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-text);
  color: var(--text-primary);
}

/* ---------- UTILITIES ---------- */
.text-muted { color: var(--text-muted); font-size: 0.85rem; }
.link { color: var(--accent-text); font-weight: 500; }
.link:hover { opacity: 0.8; }
.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}
.empty-state .btn { margin-top: var(--space-lg); }

.content-loading {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

.error-state {
  text-align: center;
  padding: var(--space-xl);
  color: #f87171;
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-text);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto var(--space-md);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- TOAST ---------- */
#toast-container {
  position: fixed;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  white-space: nowrap;
}
.toast-show { opacity: 1; transform: translateY(0); }
.toast-hide { opacity: 0; transform: translateY(10px); }

.toast-success { border-color: rgba(52, 211, 153, 0.3); }
.toast-info { border-color: rgba(96, 165, 250, 0.3); }
.toast-warning { border-color: rgba(251, 146, 60, 0.3); }

.toast-icon { font-size: 1rem; }

/* ---------- FOOTER ---------- */
.footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-lg);
  text-align: center;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-disclaimer {
  margin-top: var(--space-xs);
  font-size: 0.75rem;
}

/* ---------- SETTINGS ---------- */
.settings-section {
  margin-bottom: var(--space-lg);
}

.settings-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.settings-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.settings-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}
.settings-input:focus {
  border-color: var(--accent-text);
}

.settings-actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

/* Font Size Controls */
.font-size-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
}

.font-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md) var(--space-sm);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  font-size: 0.75rem;
}
.font-btn:hover {
  border-color: var(--border);
  background: var(--bg-card-hover);
}
.font-btn.active {
  border-color: var(--accent-text);
  background: var(--accent-dim);
  color: var(--accent-text);
}

.font-preview { font-weight: 700; }
.font-preview.font-small { font-size: 0.9rem; }
.font-preview.font-medium { font-size: 1.15rem; }
.font-preview.font-large { font-size: 1.4rem; }
.font-preview.font-xlarge { font-size: 1.65rem; }

/* Danger Button */
.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.modal-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-card h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}
.modal-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
  .reader-layout {
    grid-template-columns: 1fr;
  }
  .reader-toc {
    display: none; /* Hide TOC sidebar on tablet */
  }
}

@media (max-width: 768px) {
  .header-inner {
    padding: 0 var(--space-md);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .nav {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: var(--space-md);
    flex-direction: column;
    gap: var(--space-xs);
    display: none;
    z-index: 99;
  }
  .nav.nav-open { display: flex; }

  .page-container {
    padding: var(--space-lg) var(--space-md);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .quiz-level-grid {
    grid-template-columns: 1fr;
  }

  .modules-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group select,
  .filter-group input {
    width: 100%;
    min-width: unset;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .reader-layout {
    padding: var(--space-md);
  }

  .reader-main {
    max-width: 100%;
  }

  .reader-nav {
    grid-template-columns: 1fr;
  }

  .reader-title { font-size: 1.4rem; }

  .quiz-actions {
    flex-direction: column;
  }

  .floating-bookmark {
    bottom: var(--space-md);
    right: var(--space-md);
    width: 42px;
    height: 42px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
  }
  .stat-value { font-size: 1.25rem; }
}
