/* ========================================
   QuranRoots — Illuminated Codex
   A visual language inspired by Islamic
   manuscript illumination and scholarly tradition
   ======================================== */

@font-face {
  font-family: 'Jameel Noori Nastaleeq';
  src: url('/static/fonts/JameelNooriNastaleeq.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Mehr Nastaliq';
  src: url('/static/fonts/MehrNastaliq.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

/* ========================================
   Design Tokens
   ======================================== */

:root {
  /* Typography — Arabic 2.5x body text rule */
  --font-display: 'Cormorant Garamond', 'Georgia', serif;
  --font-body: 'Crimson Pro', 'Georgia', serif;
  --arabic-font: 'Amiri', serif;
  --arabic-size: 32px;
  --arabic-line-height: 2.2;
  --urdu-font: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif;

  /* Root letter highlighting */
  --root-highlight: #8b6914;

  /* Palette — Warm Parchment */
  --bg-primary: #f5f0e6;
  --bg-card: #faf7f0;
  --bg-nav: #1e1710;
  --bg-accent: #ede6d6;
  --bg-highlight: #f5e6b8;
  --bg-page-texture: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");

  /* Text */
  --text-primary: #2c1810;
  --text-secondary: #5c4a3a;
  --text-muted: #9a8a7a;
  --text-nav: #f5f0e6;
  --text-arabic: #1a0e06;

  /* Borders & Lines */
  --border: #ddd4c4;
  --border-ornament: #c4a86a;
  --border-focus: #8b6914;

  /* Accent — Burnished Gold */
  --accent: #8b6914;
  --accent-hover: #725610;
  --accent-light: #f5e6b8;
  --accent-glow: rgba(139, 105, 20, 0.12);

  /* Secondary — Manuscript Teal */
  --teal: #1a6b5a;
  --teal-light: #e0f0ec;

  /* Rating Buttons */
  --btn-again: #a83232;
  --btn-again-hover: #8c2828;
  --btn-hard: #b87a1e;
  --btn-hard-hover: #9a6618;
  --btn-good: #2d7a4a;
  --btn-good-hover: #256640;
  --btn-easy: #2e5c8a;
  --btn-easy-hover: #264d74;

  /* Elevation */
  --shadow-sm: 0 1px 3px rgba(44, 24, 16, 0.06), 0 1px 2px rgba(44, 24, 16, 0.04);
  --shadow-md: 0 4px 12px rgba(44, 24, 16, 0.08), 0 2px 4px rgba(44, 24, 16, 0.04);
  --shadow-lg: 0 12px 32px rgba(44, 24, 16, 0.1), 0 4px 8px rgba(44, 24, 16, 0.06);
  --shadow-card: 0 1px 0 rgba(44, 24, 16, 0.04), 0 2px 8px rgba(44, 24, 16, 0.06);

  /* Radii */
  --radius: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;
}

/* ========================================
   Reset & Base
   ======================================== */

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

/* Force body font on all form elements — browsers default to system fonts */
button, input, select, textarea, label {
  font-family: var(--font-body);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15px;
  background: var(--bg-primary);
  background-image: var(--bg-page-texture);
  color: var(--text-primary);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent-light);
  color: var(--text-primary);
}

/* ========================================
   Navigation — Dark mahogany bar
   ======================================== */

.nav {
  background: var(--bg-nav);
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.nav::-webkit-scrollbar {
  display: none; /* Chrome/Safari/Webkit */
}

/* Hamburger toggle — hidden on desktop, fully reset browser appearance */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid rgba(196, 168, 106, 0.3);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  color: inherit;
}

/* Three-bar hamburger icon */
.nav-toggle__icon {
  display: block;
  position: relative;
  width: 18px;
  height: 2px;
  background: var(--text-nav);
  transition: background 0.25s ease;
}

.nav-toggle__icon::before,
.nav-toggle__icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: var(--text-nav);
  transition: transform 0.25s ease, top 0.25s ease, bottom 0.25s ease;
}

.nav-toggle__icon::before { top: -6px; }
.nav-toggle__icon::after  { bottom: -6px; }

/* Animate to × when active */
.nav-toggle--active .nav-toggle__icon            { background: transparent; }
.nav-toggle--active .nav-toggle__icon::before    { top: 0; transform: rotate(45deg); }
.nav-toggle--active .nav-toggle__icon::after     { bottom: 0; transform: rotate(-45deg); }

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  min-width: 600px; /* Reduced slightly to fit better but still force scroll */
}

.nav-brand {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-brand__logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.nav-brand__en {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-nav);
  letter-spacing: -0.3px;
}

.nav-brand__ar {
  font-family: var(--arabic-font);
  font-size: 22px;
  color: #c4a86a;
  opacity: 0.9;
}

.nav-links {
  display: flex;
  gap: 2px;
  list-style: none;
  align-items: center;
}

.nav-links a {
  color: rgba(245, 240, 230, 0.82);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: color 0.2s ease, background 0.2s ease;
}

.nav-links a:hover {
  color: var(--text-nav);
  background: rgba(255, 255, 255, 0.07);
}

.nav-links a.active {
  color: #c4a86a;
  background: rgba(196, 168, 106, 0.1);
}

/* Gold ornamental bottom border */
.nav-border-ornament {
  height: 3px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    #c4a86a22 15%,
    #c4a86a 35%,
    #dab96e 50%,
    #c4a86a 65%,
    #c4a86a22 85%,
    transparent 100%
  );
}

/* ========================================
   Language Switcher
   ======================================== */

.lang-switcher {
  margin-inline-start: 10px;
}

.lang-select {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(245, 240, 230, 0.7);
  border: 1px solid rgba(196, 168, 106, 0.25);
  border-radius: var(--radius);
  padding: 5px 10px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.lang-select:hover {
  border-color: rgba(196, 168, 106, 0.5);
  color: var(--text-nav);
}

.lang-select option {
  background: var(--bg-nav);
  color: var(--text-nav);
}

/* ========================================
   Layout
   ======================================== */

.page {
  max-width: 740px;
  margin: 0 auto;
  padding: 40px 28px 64px;
  animation: pageReveal 0.4s ease-out;
}

.page-wide {
  max-width: 960px;
}

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

/* ========================================
   Typography
   ======================================== */

.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.page-subtitle {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-style: italic;
}

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.3px;
}

/* ========================================
   Cards
   ======================================== */

.card {
  background: var(--bg-card);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  padding: 24px;
  margin-bottom: 16px;
  position: relative;
  transition: box-shadow 0.2s ease;
}

.card-lg {
  padding: 32px;
}

/* Subtle gold top-edge on cards */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-ornament), transparent);
  opacity: 0.4;
  border-radius: 1px;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
  letter-spacing: 0.2px;
}

.btn-primary {
  background: var(--accent);
  color: #faf7f0;
  box-shadow: 0 1px 3px rgba(139, 105, 20, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(139, 105, 20, 0.35);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

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

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
  border-radius: var(--radius-lg);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* ========================================
   Stats Row
   ======================================== */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: var(--border-ornament);
  opacity: 0.2;
  border-radius: 1px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 6px;
  font-weight: 500;
}

/* ========================================
   Arabic Text
   ======================================== */

.arabic {
  font-family: var(--arabic-font);
  font-size: var(--arabic-size);
  direction: rtl;
  text-align: right;
  line-height: var(--arabic-line-height, 2.2);
  color: var(--text-arabic);
}

.arabic-lg {
  font-size: calc(var(--arabic-size) * 1.5);
}

.arabic-sm {
  font-size: calc(var(--arabic-size) * 0.75);
}

.arabic-highlight {
  background: var(--bg-highlight);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
  font-weight: 700;
}

/* Audio play button */
.audio-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.audio-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light, var(--bg-highlight));
}

.audio-btn--playing {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

/* Word-level audio button — small, appears under the word */
.audio-btn--word {
  width: 22px;
  height: 22px;
  font-size: 11px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  display: block;
  margin: 2px auto 0;
}

.wbw-word:hover .audio-btn--word {
  opacity: 1;
  pointer-events: auto;
}

/* Always visible in study card highlights */
.verse-card__hw .audio-btn--word {
  display: inline-flex;
  width: 18px;
  height: 18px;
  font-size: 10px;
  opacity: 1;
  pointer-events: auto;
  vertical-align: middle;
  margin: 0 3px;
}

/* Inline in word forms table */
.audio-btn--form {
  display: inline-flex;
  width: 20px;
  height: 20px;
  font-size: 11px;
  opacity: 0.6;
  pointer-events: auto;
  vertical-align: middle;
  margin-right: 6px;
}

.audio-btn--form:hover {
  opacity: 1;
}

/* Root letter highlighting — color-code root letters inside word forms */
.root-letter {
  color: var(--root-highlight, var(--accent));
  font-weight: 700;
}

/* ========================================
   Verse Context
   ======================================== */

.verse-context {
  margin-bottom: 24px;
}

.verse-context__ref {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
  font-weight: 500;
}

.verse-context__arabic {
  font-family: var(--arabic-font);
  font-size: var(--arabic-size);
  direction: rtl;
  text-align: right;
  line-height: var(--arabic-line-height, 2.2);
  margin-bottom: 12px;
  color: var(--text-primary);
}

.verse-context__translation {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  font-style: italic;
}

/* ========================================
   Form Controls (shared)
   ======================================== */

.filter-input {
  padding: 9px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 200px;
}

.filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.filter-select {
  padding: 9px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  appearance: auto;
}

.filter-select--sm {
  padding: 7px 10px;
  font-size: 13px;
  min-width: 70px;
}

.threshold-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-weight: 500;
}

/* ========================================
   Ornamental Divider
   ======================================== */

.ornament-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0;
  color: var(--border-ornament);
  opacity: 0.5;
}

.ornament-divider::before,
.ornament-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-ornament), transparent);
}

.ornament-divider__star {
  font-size: 10px;
  line-height: 1;
}

/* ========================================
   Utilities
   ======================================== */

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* ========================================
   RTL Support
   ======================================== */

[dir="rtl"] body {
  font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif;
  font-size: 17px;
  line-height: 2;
}

[dir="rtl"] .verse-context__translation,
[dir="rtl"] .study-card__meaning,
[dir="rtl"] .back-meaning,
[dir="rtl"] .lemma-card__meaning,
[dir="rtl"] .family-pill__meaning,
[dir="rtl"] .family-detail__meaning {
  font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif;
  line-height: 2;
}

[dir="rtl"] .nav-inner { flex-direction: row-reverse; }
[dir="rtl"] .nav-links { flex-direction: row-reverse; }
[dir="rtl"] .nav-links a {
  font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: 0;
}
[dir="rtl"] .page-title { text-align: right; font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif; }
[dir="rtl"] h1, [dir="rtl"] h2, [dir="rtl"] h3 { font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif; }
[dir="rtl"] .stat-label { text-transform: none; font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif; }
[dir="rtl"] .setting-label { text-align: right; font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif; }
[dir="rtl"] .btn, [dir="rtl"] button { font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif; }
[dir="rtl"] .verse-context__translation { text-align: right; direction: rtl; }

[dir="rtl"] .wbw-meaning,
[dir="rtl"] .detail-meaning,
[dir="rtl"] .occ-translation,
[dir="rtl"] .root-item__meaning,
[dir="rtl"] .pair-meaning,
[dir="rtl"] .pair-ayah__translation,
[dir="rtl"] .similar-text__translation,
[dir="rtl"] .similar-variant__translation,
[dir="rtl"] .detail-item__meaning {
  font-family: 'Jameel Noori Nastaleeq', 'Noto Nastaliq Urdu', serif;
  direction: rtl;
  text-align: right;
}

/* ========================================
   Theme: Dark — Midnight Scholar
   ======================================== */

[data-theme="dark"] {
  --bg-primary: #13110e;
  --bg-card: #1c1915;
  --bg-nav: #0a0908;
  --bg-accent: #231f1a;
  --bg-highlight: #2e2510;
  --bg-page-texture: none;

  --text-primary: #e8e0d4;
  --text-secondary: #a89a88;
  --text-muted: #6e6258;
  --text-nav: #e8e0d4;
  --text-arabic: #f0e8dc;

  --border: #302a22;
  --border-ornament: #8a7440;
  --border-focus: #c4a050;

  --accent: #c4a050;
  --accent-hover: #b08e3e;
  --accent-light: #2e2510;
  --accent-glow: rgba(196, 160, 80, 0.15);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.2), 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* ========================================
   Theme: Sepia — Aged Manuscript
   ======================================== */

[data-theme="sepia"] {
  --bg-primary: #f0e6d0;
  --bg-card: #f8f0de;
  --bg-nav: #3a2a1c;
  --bg-accent: #e8dcc4;
  --bg-highlight: #e4d4a8;

  --text-primary: #3a2a1c;
  --text-secondary: #5c4a38;
  --text-muted: #8a7460;
  --text-nav: #f0e6d0;
  --text-arabic: #2a1a0e;

  --border: #d4c4a4;
  --border-ornament: #b08a40;
  --border-focus: #8a6a20;

  --accent: #8a6a20;
  --accent-hover: #74581a;
  --accent-light: #e8d8b0;

  --shadow-sm: 0 1px 2px rgba(58, 42, 28, 0.08);
  --shadow-md: 0 4px 8px rgba(58, 42, 28, 0.1);
  --shadow-lg: 0 10px 20px rgba(58, 42, 28, 0.12);
  --shadow-card: 0 1px 0 rgba(58, 42, 28, 0.06), 0 2px 6px rgba(58, 42, 28, 0.08);
}

/* ========================================
   Theme: High Contrast
   ======================================== */

[data-theme="high-contrast"] {
  --bg-primary: #000000;
  --bg-card: #0a0a0a;
  --bg-nav: #000000;
  --bg-accent: #1a1a1a;
  --bg-highlight: #333300;
  --bg-page-texture: none;

  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --text-muted: #b0b0b0;
  --text-nav: #ffffff;
  --text-arabic: #ffffff;

  --border: #555555;
  --border-ornament: #ffcc00;
  --border-focus: #ffcc00;

  --accent: #ffcc00;
  --accent-hover: #e6b800;
  --accent-light: #333300;

  --shadow-sm: 0 1px 2px rgba(255, 255, 255, 0.05);
  --shadow-md: 0 4px 6px rgba(255, 255, 255, 0.07);
  --shadow-lg: 0 10px 15px rgba(255, 255, 255, 0.1);
  --shadow-card: none;
}

[data-theme="high-contrast"] .nav { border-bottom: 2px solid var(--accent); }
[data-theme="high-contrast"] .nav-border-ornament { display: none; }
[data-theme="high-contrast"] .card { border-width: 2px; }
[data-theme="high-contrast"] .card::before { display: none; }
[data-theme="high-contrast"] .btn-primary { color: #000000; font-weight: 700; }

/* ========================================
   Theme: Manuscript (Solarized warm)
   ======================================== */

[data-theme="manuscript"] {
  --bg-primary: #FDF6E3;
  --bg-card: #fefbf3;
  --bg-nav: #3b3229;
  --bg-accent: #f5edd6;
  --bg-highlight: #f0e4be;

  --text-primary: #586E75;
  --text-secondary: #657B83;
  --text-muted: #93A1A1;
  --text-nav: #FDF6E3;
  --text-arabic: #3b3229;

  --border: #e6dcc3;
  --border-ornament: #B58900;
  --border-focus: #B58900;

  --accent: #B58900;
  --accent-hover: #9a7400;
  --accent-light: #f5edd6;

  --btn-again: #dc322f;
  --btn-again-hover: #c12724;
  --btn-hard: #cb4b16;
  --btn-hard-hover: #b34013;
  --btn-good: #268BD2;
  --btn-good-hover: #1e7aba;
  --btn-easy: #2aa198;
  --btn-easy-hover: #248f87;

  --shadow-sm: 0 1px 2px rgba(88, 110, 117, 0.06);
  --shadow-md: 0 4px 6px rgba(88, 110, 117, 0.08);
  --shadow-lg: 0 10px 15px rgba(88, 110, 117, 0.1);
  --shadow-card: 0 1px 0 rgba(88, 110, 117, 0.04), 0 2px 6px rgba(88, 110, 117, 0.06);
}

/* ========================================
   Theme: Olive Grove
   ======================================== */

[data-theme="olive"] {
  --bg-primary: #F1F3F0;
  --bg-card: #f8f9f7;
  --bg-nav: #2D3436;
  --bg-accent: #e5e9e3;
  --bg-highlight: #dde6d0;

  --text-primary: #2D3436;
  --text-secondary: #4a5356;
  --text-muted: #7c8a8d;
  --text-nav: #F1F3F0;
  --text-arabic: #1a1f20;

  --border: #d1d8cf;
  --border-ornament: #6B8E23;
  --border-focus: #6B8E23;

  --accent: #6B8E23;
  --accent-hover: #5a781d;
  --accent-light: #dde6d0;

  --btn-again: #c0392b;
  --btn-again-hover: #a93226;
  --btn-hard: #d4870e;
  --btn-hard-hover: #b8740c;
  --btn-good: #6B8E23;
  --btn-good-hover: #5a781d;
  --btn-easy: #8B4513;
  --btn-easy-hover: #743a10;

  --shadow-sm: 0 1px 2px rgba(45, 52, 54, 0.06);
  --shadow-md: 0 4px 6px rgba(45, 52, 54, 0.08);
  --shadow-lg: 0 10px 15px rgba(45, 52, 54, 0.1);
  --shadow-card: 0 1px 0 rgba(45, 52, 54, 0.04), 0 2px 6px rgba(45, 52, 54, 0.06);
}

/* ========================================
   Theme: Deep Night (OLED)
   ======================================== */

[data-theme="night"] {
  --bg-primary: #0c0c0c;
  --bg-card: #161616;
  --bg-nav: #050505;
  --bg-accent: #1e1e1e;
  --bg-highlight: #1a2e2a;
  --bg-page-texture: none;

  --text-primary: #E0E0E0;
  --text-secondary: #a0a0a0;
  --text-muted: #666666;
  --text-nav: #E0E0E0;
  --text-arabic: #f0f0f0;

  --border: #2a2a2a;
  --border-ornament: #00BFA5;
  --border-focus: #00BFA5;

  --accent: #00BFA5;
  --accent-hover: #00a68e;
  --accent-light: #1a2e2a;

  --btn-again: #cf6679;
  --btn-again-hover: #b85566;
  --btn-hard: #FFB74D;
  --btn-hard-hover: #e6a043;
  --btn-good: #00BFA5;
  --btn-good-hover: #00a68e;
  --btn-easy: #BB86FC;
  --btn-easy-hover: #a46ef0;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.7);
  --shadow-card: 0 1px 0 rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="night"] .btn-primary { color: #0c0c0c; font-weight: 600; }
[data-theme="night"] .nav-border-ornament {
  background: linear-gradient(90deg, transparent 0%, #00BFA522 15%, #00BFA5 50%, #00BFA522 85%, transparent 100%);
}

/* ========================================
   Theme: Academic
   ======================================== */

[data-theme="academic"] {
  --bg-primary: #FAFAFA;
  --bg-card: #FFFFFF;
  --bg-nav: #1A73E8;
  --bg-accent: #f1f3f4;
  --bg-highlight: #fef7e0;
  --bg-page-texture: none;

  --text-primary: #202124;
  --text-secondary: #5F6368;
  --text-muted: #9AA0A6;
  --text-nav: #FFFFFF;
  --text-arabic: #202124;

  --border: #dadce0;
  --border-ornament: #1A73E8;
  --border-focus: #1A73E8;

  --accent: #1A73E8;
  --accent-hover: #1565c0;
  --accent-light: #e8f0fe;

  --btn-again: #ea4335;
  --btn-again-hover: #d33426;
  --btn-hard: #F9AB00;
  --btn-hard-hover: #e09c00;
  --btn-good: #34a853;
  --btn-good-hover: #2d9249;
  --btn-easy: #5F6368;
  --btn-easy-hover: #4e5256;

  --shadow-sm: 0 1px 2px rgba(60, 64, 67, 0.1);
  --shadow-md: 0 1px 3px rgba(60, 64, 67, 0.15);
  --shadow-lg: 0 4px 8px rgba(60, 64, 67, 0.2);
  --shadow-card: 0 1px 2px rgba(60, 64, 67, 0.1);
}

[data-theme="academic"] .nav-brand__ar { color: rgba(255, 255, 255, 0.85); }
[data-theme="academic"] .nav-border-ornament {
  background: linear-gradient(90deg, #1A73E8, #4285f4, #1A73E8);
  height: 2px;
}
[data-theme="academic"] .card::before { display: none; }

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
  /* Switch nav from horizontal-scroll to hamburger dropdown */
  .nav {
    overflow-x: visible;
    -webkit-overflow-scrolling: auto;
  }

  .nav-inner {
    padding: 0 16px;
    min-width: unset;
    height: auto;
    min-height: 54px;
    flex-wrap: wrap;
    align-items: center;
    position: relative;
  }

  /* Show hamburger button */
  .nav-toggle {
    display: flex;
  }

  /* Hide nav links by default on mobile */
  .nav-links,
  [dir="rtl"] .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0 14px;
    order: 10;
    border-top: 1px solid rgba(196, 168, 106, 0.12);
  }

  /* Show when toggled open */
  .nav-links--open,
  [dir="rtl"] .nav-links--open {
    display: flex;
    flex-direction: column;
  }

  .nav-links li {
    width: 100%;
  }

  /* Full-width tappable links */
  .nav-links a {
    display: block;
    padding: 11px 16px;
    font-size: 15px;
    border-radius: var(--radius);
  }

  .lang-switcher {
    width: 100%;
    padding: 4px 12px 0;
    margin-inline-start: 0;
  }

  .lang-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
  }

  .page {
    padding: 24px 16px 48px;
  }

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

  .page-title {
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  .nav-inner {
    padding: 0 12px;
  }

  .nav-brand {
    gap: 6px;
  }

  .nav-brand__en {
    font-size: 16px;
  }

  .nav-brand__ar {
    display: none; /* Hide Arabic subtitle on very small screens to save space */
  }
}

/* ========================================
   Video Embeds
   ======================================== */

.video-section {
  margin: 40px auto;
  text-align: center;
  max-width: 800px;
}

.video-section__title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
  letter-spacing: -0.2px;
}

.video-wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 ratio */
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  background: #000;
}

.video-wrapper iframe,
.video-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
