/* ============================================================
   TYPINGO – 8 COMPLETE VISUAL THEMES SYSTEM (GLOBAL)
   ============================================================
   Themes apply globally across the entire website via [data-theme].
   Supported Themes:
     1. forest     - Forest Nature (Deep green, organic elements)
     2. ocean      - Ocean Blue (Abyss blue, underwater atmosphere)
     3. sunset     - Sunset Gradient (Warm orange, purple, dusk glow)
     4. retro      - Retro Pixel (8-bit arcade, CRT scanlines, neon phosphor)
     5. vaporwave  - Vaporwave (Neon pink, purple synthwave, glowing grid)
     6. cyberpunk  - Cyberpunk Neon (Matrix green, terminal dark, neon borders)
     7. candy      - Candy Colorful (Playful pink, turquoise, joyful pastels)
     8. pastel     - Pastel Minimalist (Clean white, soft lavender accents)
     + dark        - Classic Dark (Tyspingo default dark)
     + light       - Classic Light (Tyspingo white mode)
   ============================================================ */

/* ──────────────────────────────────────────────────────────
   1. DESIGN TOKENS FOR ALL 8 THEMES + DARK + LIGHT
   ────────────────────────────────────────────────────────── */

/* CLASSIC DARK (Default) */
:root,
html[data-theme='dark'] {
  color-scheme: dark;
  --bg: #060816;
  --bg-soft: #0f172a;
  --surface: rgba(15, 23, 42, 0.76);
  --surface-strong: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --muted: #9ba7c4;
  --accent: #7c4dff;
  --accent-2: #22d3ee;
  --border: rgba(255, 255, 255, 0.16);
  --shadow: 0 24px 70px rgba(2, 6, 23, 0.45);
  --correct: #34d399;
  --incorrect: #fb7185;
  --current-bg: rgba(124, 77, 255, 0.25);
  --progress: linear-gradient(90deg, #7c4dff, #22d3ee);
  --bg-gradient: radial-gradient(circle at top left, rgba(124, 77, 255, 0.24), transparent 28%),
                 radial-gradient(circle at bottom right, rgba(34, 211, 238, 0.18), transparent 28%);
}

/* CLASSIC LIGHT (White Mode) */
html[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f7ff;
  --bg-soft: #eef2ff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --text: #111827;
  --muted: #5b6478;
  --accent: #6d28d9;
  --accent-2: #0891b2;
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 24px 70px rgba(99, 102, 241, 0.15);
  --correct: #059669;
  --incorrect: #dc2626;
  --current-bg: rgba(109, 40, 217, 0.16);
  --progress: linear-gradient(90deg, #6d28d9, #0891b2);
  --bg-gradient: radial-gradient(circle at top left, rgba(109, 40, 217, 0.08), transparent 30%),
                 radial-gradient(circle at bottom right, rgba(8, 145, 178, 0.08), transparent 30%);
}

/* THEME 1: FOREST NATURE */
html[data-theme='forest'],
[data-typing-theme='forest'] {
  color-scheme: dark;
  --bg: #071510;
  --bg-soft: #0f2a1a;
  --surface: rgba(10, 31, 16, 0.86);
  --surface-strong: rgba(74, 222, 128, 0.12);
  --text: #d4f5e4;
  --muted: #7ab893;
  --accent: #4ade80;
  --accent-2: #86efac;
  --border: rgba(74, 222, 128, 0.22);
  --shadow: 0 24px 70px rgba(4, 20, 8, 0.6);
  --correct: #4ade80;
  --incorrect: #fca5a5;
  --current-bg: rgba(74, 222, 128, 0.25);
  --progress: linear-gradient(90deg, #22c55e, #4ade80, #86efac);
  --bg-gradient: radial-gradient(ellipse at 15% 20%, rgba(34, 197, 94, 0.22) 0%, transparent 55%),
                 radial-gradient(ellipse at 85% 80%, rgba(21, 128, 61, 0.25) 0%, transparent 50%),
                 radial-gradient(ellipse at 50% 100%, rgba(74, 222, 128, 0.15) 0%, transparent 60%);
}

/* THEME 2: OCEAN BLUE */
html[data-theme='ocean'],
[data-typing-theme='ocean'] {
  color-scheme: dark;
  --bg: #020e1c;
  --bg-soft: #041830;
  --surface: rgba(2, 18, 40, 0.88);
  --surface-strong: rgba(56, 189, 248, 0.12);
  --text: #bfefff;
  --muted: #5ba3c9;
  --accent: #38bdf8;
  --accent-2: #67e8f9;
  --border: rgba(56, 189, 248, 0.22);
  --shadow: 0 24px 70px rgba(0, 8, 30, 0.7);
  --correct: #38bdf8;
  --incorrect: #f87171;
  --current-bg: rgba(56, 189, 248, 0.22);
  --progress: linear-gradient(90deg, #0284c7, #38bdf8, #67e8f9);
  --bg-gradient: radial-gradient(ellipse at 25% 10%, rgba(6, 182, 212, 0.22) 0%, transparent 50%),
                 radial-gradient(ellipse at 75% 90%, rgba(56, 189, 248, 0.2) 0%, transparent 50%),
                 radial-gradient(ellipse at 50% 50%, rgba(3, 105, 161, 0.18) 0%, transparent 70%);
}

/* THEME 3: SUNSET GRADIENT */
html[data-theme='sunset'],
[data-typing-theme='sunset'] {
  color-scheme: dark;
  --bg: #150818;
  --bg-soft: #240d28;
  --surface: rgba(30, 10, 24, 0.88);
  --surface-strong: rgba(251, 146, 60, 0.14);
  --text: #ffe4cc;
  --muted: #d48872;
  --accent: #fb923c;
  --accent-2: #f472b6;
  --border: rgba(251, 146, 60, 0.25);
  --shadow: 0 24px 70px rgba(20, 4, 10, 0.7);
  --correct: #fbbf24;
  --incorrect: #f87171;
  --current-bg: rgba(251, 146, 60, 0.24);
  --progress: linear-gradient(90deg, #9333ea, #f97316, #fbbf24);
  --bg-gradient: radial-gradient(ellipse at 50% 100%, rgba(251, 146, 60, 0.3) 0%, transparent 55%),
                 radial-gradient(ellipse at 15% 50%, rgba(244, 114, 182, 0.22) 0%, transparent 50%),
                 radial-gradient(ellipse at 85% 25%, rgba(168, 85, 247, 0.22) 0%, transparent 50%);
}

/* THEME 4: RETRO PIXEL */
html[data-theme='retro'],
html[data-theme='pixel'],
[data-typing-theme='retro'],
[data-typing-theme='pixel'] {
  color-scheme: dark;
  --bg: #0a0a02;
  --bg-soft: #141404;
  --surface: rgba(16, 16, 4, 0.94);
  --surface-strong: rgba(34, 197, 94, 0.15);
  --text: #4ade80;
  --muted: #16a34a;
  --accent: #22c55e;
  --accent-2: #86efac;
  --border: rgba(34, 197, 94, 0.35);
  --shadow: 0 0 35px rgba(34, 197, 94, 0.25);
  --correct: #22c55e;
  --incorrect: #ef4444;
  --current-bg: rgba(34, 197, 94, 0.28);
  --progress: linear-gradient(90deg, #15803d, #22c55e);
  --typing-prompt-font: 'Courier New', 'Lucida Console', monospace;
  --bg-gradient: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(34, 197, 94, 0.02) 2px, rgba(34, 197, 94, 0.02) 4px);
}

/* THEME 5: VAPORWAVE */
html[data-theme='vaporwave'],
[data-typing-theme='vaporwave'] {
  color-scheme: dark;
  --bg: #080012;
  --bg-soft: #120028;
  --surface: rgba(18, 0, 36, 0.88);
  --surface-strong: rgba(240, 171, 252, 0.12);
  --text: #fde8ff;
  --muted: #c084fc;
  --accent: #e879f9;
  --accent-2: #f472b6;
  --border: rgba(240, 171, 252, 0.25);
  --shadow: 0 0 40px rgba(168, 85, 247, 0.35);
  --correct: #a78bfa;
  --incorrect: #f43f5e;
  --current-bg: rgba(232, 121, 249, 0.25);
  --progress: linear-gradient(90deg, #7c3aed, #e879f9, #f0abfc);
  --bg-gradient: radial-gradient(ellipse at 20% 80%, rgba(168, 85, 247, 0.28) 0%, transparent 55%),
                 radial-gradient(ellipse at 80% 20%, rgba(232, 121, 249, 0.22) 0%, transparent 50%),
                 radial-gradient(ellipse at 50% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 60%);
}

/* THEME 6: CYBERPUNK NEON */
html[data-theme='cyberpunk'],
[data-typing-theme='cyberpunk'] {
  color-scheme: dark;
  --bg: #000902;
  --bg-soft: #001605;
  --surface: rgba(0, 14, 4, 0.94);
  --surface-strong: rgba(0, 255, 65, 0.12);
  --text: #bbf7d0;
  --muted: #4ade80;
  --accent: #00ff41;
  --accent-2: #39ff14;
  --border: rgba(0, 255, 65, 0.3);
  --shadow: 0 0 35px rgba(0, 255, 65, 0.2);
  --correct: #00ff41;
  --incorrect: #ff2244;
  --current-bg: rgba(0, 255, 65, 0.24);
  --progress: linear-gradient(90deg, #00b300, #00ff41, #39ff14);
  --typing-prompt-font: 'Courier New', monospace;
  --bg-gradient: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0, 255, 65, 0.015) 3px, rgba(0, 255, 65, 0.015) 4px),
                 radial-gradient(ellipse at 50% 0%, rgba(0, 255, 65, 0.15) 0%, transparent 55%);
}

/* THEME 7: CANDY COLORFUL */
html[data-theme='candy'],
[data-typing-theme='candy'] {
  color-scheme: light;
  --bg: #fff0fa;
  --bg-soft: #ffe4f2;
  --surface: rgba(255, 245, 252, 0.94);
  --surface-strong: rgba(244, 114, 182, 0.14);
  --text: #831843;
  --muted: #db2777;
  --accent: #ec4899;
  --accent-2: #a855f7;
  --border: rgba(244, 114, 182, 0.35);
  --shadow: 0 24px 50px rgba(244, 114, 182, 0.2);
  --correct: #059669;
  --incorrect: #dc2626;
  --current-bg: rgba(244, 114, 182, 0.25);
  --progress: linear-gradient(90deg, #f472b6, #c084fc, #60a5fa);
  --bg-gradient: radial-gradient(circle at 15% 20%, rgba(244, 114, 182, 0.28) 0%, transparent 40%),
                 radial-gradient(circle at 85% 75%, rgba(167, 139, 250, 0.25) 0%, transparent 40%),
                 radial-gradient(circle at 50% 50%, rgba(96, 165, 250, 0.18) 0%, transparent 50%),
                 radial-gradient(circle at 70% 10%, rgba(250, 204, 21, 0.2) 0%, transparent 35%);
}

/* THEME 8: PASTEL MINIMALIST */
html[data-theme='pastel'],
[data-typing-theme='pastel'] {
  color-scheme: light;
  --bg: #f8f9ff;
  --bg-soft: #eff1fc;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: rgba(167, 139, 250, 0.12);
  --text: #1e1b4b;
  --muted: #64748b;
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --border: rgba(167, 139, 250, 0.25);
  --shadow: 0 24px 60px rgba(139, 92, 246, 0.12);
  --correct: #10b981;
  --incorrect: #ef4444;
  --current-bg: rgba(167, 139, 250, 0.18);
  --progress: linear-gradient(90deg, #8b5cf6, #a78bfa, #c4b5fd);
  --bg-gradient: radial-gradient(ellipse at 20% 20%, rgba(196, 181, 253, 0.35) 0%, transparent 45%),
                 radial-gradient(ellipse at 80% 80%, rgba(167, 139, 250, 0.25) 0%, transparent 45%),
                 radial-gradient(ellipse at 60% 30%, rgba(216, 180, 254, 0.22) 0%, transparent 40%);
}

/* ──────────────────────────────────────────────────────────
   2. GLOBAL ATMOSPHERIC TAKEOVER & PSEUDO-ELEMENTS
   ────────────────────────────────────────────────────────── */

/* Ensure the page shell sits on top of atmospheric overlays */
.page-shell {
  position: relative;
  z-index: 2;
}

/* The atmospheric decorative layers on body */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 400ms ease;
}

/* Forest leaf particles */
html[data-theme='forest'] body::after {
  background-image:
    radial-gradient(circle 3px at 15% 25%, rgba(74,222,128,0.35) 0%, transparent 100%),
    radial-gradient(circle 2px at 45% 65%, rgba(134,239,172,0.3) 0%, transparent 100%),
    radial-gradient(circle 4px at 70% 20%, rgba(74,222,128,0.25) 0%, transparent 100%),
    radial-gradient(circle 2px at 85% 55%, rgba(134,239,172,0.3) 0%, transparent 100%),
    radial-gradient(circle 3px at 30% 80%, rgba(74,222,128,0.2) 0%, transparent 100%);
  animation: forestDrift 9s ease-in-out infinite alternate;
}

@keyframes forestDrift {
  0%   { transform: translateY(0px) rotate(0deg); opacity: 0.6; }
  100% { transform: translateY(-12px) rotate(4deg); opacity: 0.95; }
}

/* Ocean underwater bubbles & wave light */
html[data-theme='ocean'] body::after {
  background-image:
    radial-gradient(circle 4px at 25% 35%, rgba(103,232,249,0.45) 0%, transparent 100%),
    radial-gradient(circle 3px at 55% 25%, rgba(56,189,248,0.4) 0%, transparent 100%),
    radial-gradient(circle 5px at 80% 40%, rgba(103,232,249,0.35) 0%, transparent 100%),
    radial-gradient(circle 2px at 10% 55%, rgba(56,189,248,0.45) 0%, transparent 100%),
    radial-gradient(ellipse 120px 40px at 20% 70%, rgba(56,189,248,0.06) 0%, transparent 100%);
  animation: oceanFloat 10s ease-in-out infinite alternate;
}

@keyframes oceanFloat {
  0%   { transform: translate(0, 0); opacity: 0.7; }
  50%  { transform: translate(6px, -8px); opacity: 0.9; }
  100% { transform: translate(-4px, 5px); opacity: 0.8; }
}

/* Sunset twilight glow */
html[data-theme='sunset'] body::after {
  background-image:
    radial-gradient(circle 80px at 50% 90%, rgba(251,191,36,0.2) 0%, rgba(251,146,60,0.1) 50%, transparent 100%),
    linear-gradient(to top, rgba(21, 8, 24, 0.6) 0%, transparent 20%);
  animation: sunsetPulse 6s ease-in-out infinite alternate;
}

@keyframes sunsetPulse {
  0%   { opacity: 0.75; }
  100% { opacity: 1; }
}

/* Retro CRT scanlines */
html[data-theme='retro'] body::after,
html[data-theme='pixel'] body::after {
  background: linear-gradient(
    180deg,
    rgba(34, 197, 94, 0.05) 0%,
    transparent 15%,
    transparent 85%,
    rgba(34, 197, 94, 0.05) 100%
  );
}

/* Vaporwave perspective & neon drift */
html[data-theme='vaporwave'] body::after {
  background-image:
    linear-gradient(to bottom, transparent 65%, rgba(168,85,247,0.08) 100%),
    radial-gradient(circle 80px at 30% 70%, rgba(232,121,249,0.12) 0%, transparent 100%),
    radial-gradient(circle 60px at 70% 30%, rgba(99,102,241,0.12) 0%, transparent 100%);
  animation: vaporGlow 8s ease-in-out infinite alternate;
}

@keyframes vaporGlow {
  0%   { opacity: 0.7; }
  100% { opacity: 1; }
}

/* Cyberpunk terminal matrix pulses */
html[data-theme='cyberpunk'] body::after {
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(0, 255, 65, 0.12) 0%, transparent 50%),
    radial-gradient(circle 3px at 10% 20%, rgba(0,255,65,0.6) 0%, transparent 100%),
    radial-gradient(circle 2px at 88% 40%, rgba(0,255,65,0.4) 0%, transparent 100%),
    radial-gradient(circle 4px at 30% 75%, rgba(57,255,20,0.35) 0%, transparent 100%);
  animation: cyberpunkPulse 4s ease-in-out infinite alternate;
}

@keyframes cyberpunkPulse {
  0%   { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Candy buoyant bubbles */
html[data-theme='candy'] body::after {
  background-image:
    radial-gradient(circle 25px at 12% 28%, rgba(244,114,182,0.2) 0%, transparent 100%),
    radial-gradient(circle 18px at 28% 12%, rgba(167,139,250,0.22) 0%, transparent 100%),
    radial-gradient(circle 22px at 82% 18%, rgba(251,207,232,0.28) 0%, transparent 100%),
    radial-gradient(circle 30px at 88% 65%, rgba(196,181,253,0.18) 0%, transparent 100%);
  animation: candyFloat 6s ease-in-out infinite alternate;
}

@keyframes candyFloat {
  0%   { transform: translateY(0) scale(1); opacity: 0.8; }
  100% { transform: translateY(-8px) scale(1.04); opacity: 1; }
}

/* ──────────────────────────────────────────────────────────
   3. RETRO & CYBERPUNK THEME TYPOGRAPHY & CARDS
   ────────────────────────────────────────────────────────── */

html[data-theme='retro'] .practice-card,
html[data-theme='retro'] .hero-card,
html[data-theme='pixel'] .practice-card,
html[data-theme='pixel'] .hero-card {
  border-radius: 4px;
  border-width: 2px;
  box-shadow: 0 0 15px rgba(34, 197, 94, 0.15);
}

html[data-theme='cyberpunk'] .practice-card,
html[data-theme='cyberpunk'] .hero-card {
  border-color: rgba(0, 255, 65, 0.4);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.15);
}

/* ──────────────────────────────────────────────────────────
   4. THUMBNAILS (Used in Popover, Settings, First-Time Screen)
   ────────────────────────────────────────────────────────── */

.theme-preview-thumbnail {
  width: 100%;
  aspect-ratio: 16/10;
  display: flex;
  flex-direction: column;
  padding: 0.55rem;
  gap: 0.28rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  pointer-events: none;
  box-sizing: border-box;
  overflow: hidden;
  transition: transform 200ms ease;
}

.tpt-bar {
  height: 0.24rem;
  border-radius: 999px;
  width: 55%;
}

.tpt-lines {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  justify-content: center;
}

.tpt-line {
  height: 0.22rem;
  border-radius: 999px;
}

.tpt-line:nth-child(1) { width: 92%; }
.tpt-line:nth-child(2) { width: 78%; }
.tpt-line:nth-child(3) { width: 86%; }

.tpt-input {
  height: 0.24rem;
  border-radius: 999px;
  width: 100%;
  margin-top: 0.15rem;
}

.tpt-stats {
  display: flex;
  gap: 0.25rem;
}

.tpt-stat {
  height: 0.32rem;
  border-radius: 999px;
  flex: 1;
}

/* Thumbnail Color Classes */
.theme-tn-forest { background: linear-gradient(160deg, #0f2a1a 0%, #1a4527 60%, #071510 100%); }
.theme-tn-forest .tpt-bar { background: #4ade80; }
.theme-tn-forest .tpt-line { background: rgba(74, 222, 128, 0.4); }
.theme-tn-forest .tpt-input { background: rgba(74, 222, 128, 0.22); }
.theme-tn-forest .tpt-stat { background: rgba(74, 222, 128, 0.45); }

.theme-tn-ocean { background: linear-gradient(160deg, #041830 0%, #062847 60%, #020e1c 100%); }
.theme-tn-ocean .tpt-bar { background: #38bdf8; }
.theme-tn-ocean .tpt-line { background: rgba(56, 189, 248, 0.4); }
.theme-tn-ocean .tpt-input { background: rgba(56, 189, 248, 0.22); }
.theme-tn-ocean .tpt-stat { background: rgba(56, 189, 248, 0.45); }

.theme-tn-sunset { background: linear-gradient(160deg, #150818 0%, #3d1030 40%, #7a2510 80%, #c05020 100%); }
.theme-tn-sunset .tpt-bar { background: #fb923c; }
.theme-tn-sunset .tpt-line { background: rgba(251, 146, 60, 0.45); }
.theme-tn-sunset .tpt-input { background: rgba(251, 146, 60, 0.25); }
.theme-tn-sunset .tpt-stat { background: rgba(251, 146, 60, 0.5); }

.theme-tn-retro { background: #0a0a02; border-color: rgba(34, 197, 94, 0.4); }
.theme-tn-retro .tpt-bar { background: #22c55e; }
.theme-tn-retro .tpt-line { background: rgba(34, 197, 94, 0.45); }
.theme-tn-retro .tpt-input { background: rgba(34, 197, 94, 0.25); }
.theme-tn-retro .tpt-stat { background: rgba(34, 197, 94, 0.55); }

.theme-tn-vaporwave { background: linear-gradient(160deg, #080012 0%, #1a0036 50%, #000d1a 100%); }
.theme-tn-vaporwave .tpt-bar { background: #f0abfc; }
.theme-tn-vaporwave .tpt-line { background: rgba(240, 171, 252, 0.4); }
.theme-tn-vaporwave .tpt-input { background: rgba(240, 171, 252, 0.22); }
.theme-tn-vaporwave .tpt-stat { background: rgba(240, 171, 252, 0.45); }

.theme-tn-cyberpunk { background: #000902; border-color: rgba(0, 255, 65, 0.4); }
.theme-tn-cyberpunk .tpt-bar { background: #00ff41; }
.theme-tn-cyberpunk .tpt-line { background: rgba(0, 255, 65, 0.4); }
.theme-tn-cyberpunk .tpt-input { background: rgba(0, 255, 65, 0.22); }
.theme-tn-cyberpunk .tpt-stat { background: rgba(0, 255, 65, 0.5); }

.theme-tn-candy { background: linear-gradient(160deg, #ffe4f0 0%, #fff0fa 60%, #e4f0ff 100%); border-color: rgba(244, 114, 182, 0.4); }
.theme-tn-candy .tpt-bar { background: #ec4899; }
.theme-tn-candy .tpt-line { background: rgba(236, 72, 153, 0.45); }
.theme-tn-candy .tpt-input { background: rgba(236, 72, 153, 0.25); }
.theme-tn-candy .tpt-stat { background: rgba(236, 72, 153, 0.5); }

.theme-tn-pastel { background: #f8f9ff; border-color: rgba(167, 139, 250, 0.4); }
.theme-tn-pastel .tpt-bar { background: #8b5cf6; }
.theme-tn-pastel .tpt-line { background: rgba(139, 92, 246, 0.4); }
.theme-tn-pastel .tpt-input { background: rgba(139, 92, 246, 0.22); }
.theme-tn-pastel .tpt-stat { background: rgba(139, 92, 246, 0.45); }

/* Representative Color Swatches */
.theme-swatches {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.4rem;
  align-items: center;
}

.theme-swatch-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ──────────────────────────────────────────────────────────
   5. FIRST-TIME THEME SELECTION FULL-SCREEN MODAL
   ────────────────────────────────────────────────────────── */

.first-theme-selection {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  box-sizing: border-box;
}

.first-theme-selection[aria-hidden='true'] {
  display: none !important;
}

.first-theme-selection-overlay {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 15, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.first-theme-selection-content {
  position: relative;
  z-index: 2;
  width: min(1040px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 2.2rem 2.4rem;
  box-shadow: 0 35px 90px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  box-sizing: border-box;
  animation: modalScaleIn 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.first-theme-selection-header {
  text-align: center;
}

.first-theme-badge {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}

.first-theme-selection-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.4rem, 3vw, 2.1rem);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.first-theme-selection-subtitle {
  margin: 0 auto;
  max-width: 620px;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.55;
}

.first-theme-selection-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

/* Individual Theme Selection Card (used in First-Visit & Settings) */
.theme-select-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem;
  border-radius: 1rem;
  background: var(--bg-soft);
  border: 2px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
  outline: none;
  color: var(--text);
  box-sizing: border-box;
}

.theme-select-card:hover {
  transform: translateY(-3px);
  border-color: var(--border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.theme-select-card.active,
.theme-select-card[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--surface-strong);
  box-shadow: 0 0 0 1px var(--accent), 0 10px 30px rgba(0, 0, 0, 0.45);
}

.theme-card-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 900;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.theme-select-card.active .theme-card-badge,
.theme-select-card[aria-pressed='true'] .theme-card-badge {
  display: flex;
}

.theme-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.theme-card-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.theme-card-sub {
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.35;
}

.first-theme-selection-actions {
  display: flex;
  justify-content: center;
  padding-top: 0.5rem;
}

.first-continue-btn {
  padding: 0.85rem 2.8rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(124, 77, 255, 0.35);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.first-continue-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(124, 77, 255, 0.45);
}

/* ──────────────────────────────────────────────────────────
   6. TYPING PRACTICE TOOLBAR THEME POPOVER
   ────────────────────────────────────────────────────────── */

.theme-popover {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.theme-popover[aria-hidden='true'] {
  display: none !important;
}

.theme-popover-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.theme-popover-panel {
  position: relative;
  z-index: 2;
  width: min(580px, 96vw);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.35rem;
  padding: 1.4rem 1.6rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  box-sizing: border-box;
  animation: modalScaleIn 200ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.theme-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
}

.theme-popover-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.theme-popover-close {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid transparent;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: all 150ms ease;
}

.theme-popover-close:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--border);
}

.theme-popover-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* ──────────────────────────────────────────────────────────
   7. SETTINGS PAGE THEME SECTION (COMPACT & MODERN)
   ────────────────────────────────────────────────────────── */

.theme-setting-row {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.theme-setting-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

/* Compact Active Theme Bar */
.theme-compact-view {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.15rem;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-sizing: border-box;
  transition: border-color 180ms ease, background 180ms ease;
}

.theme-compact-view:hover {
  border-color: var(--accent);
}

.theme-current-badge {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.theme-current-preview {
  width: 50px;
  height: 36px;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0.22rem 0.32rem;
  display: flex;
  flex-direction: column;
  gap: 0.16rem;
  flex-shrink: 0;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: transform 200ms ease;
}

.theme-compact-view:hover .theme-current-preview {
  transform: scale(1.04);
}

.theme-current-preview .tpt-bar {
  height: 0.18rem;
  width: 58%;
  border-radius: 999px;
}

.theme-current-preview .tpt-lines {
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
  flex: 1;
  justify-content: center;
}

.theme-current-preview .tpt-line {
  height: 0.16rem;
  border-radius: 999px;
  width: 90%;
}

.theme-current-preview .tpt-line:nth-child(2) {
  width: 72%;
}

.theme-current-preview .tpt-input {
  height: 0.18rem;
  border-radius: 999px;
  width: 100%;
}

.theme-current-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.theme-current-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.theme-current-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.theme-compact-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.theme-change-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(124, 77, 255, 0.25);
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.theme-change-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(124, 77, 255, 0.35);
}

.theme-change-btn:active {
  transform: translateY(0);
}

.theme-btn-icon {
  font-size: 1.1rem;
  line-height: 1;
  display: inline-block;
  transition: transform 250ms ease;
}

.theme-change-btn:hover .theme-btn-icon {
  transform: rotate(90deg);
}

.theme-toggle-expand-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.52rem 0.95rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.theme-toggle-expand-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--surface);
}

.theme-toggle-arrow {
  font-size: 0.85rem;
  line-height: 1;
  display: inline-block;
}

/* Collapsible Theme Grid Container */
.settings-theme-grid-container {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
  margin: 0;
  padding: 0;
  transition: max-height 280ms cubic-bezier(0.16, 1, 0.3, 1),
              opacity 200ms ease,
              visibility 280ms ease,
              margin-top 200ms ease;
}

.settings-theme-grid-container.is-expanded {
  max-height: 1400px;
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  margin-top: 0.65rem;
  padding-bottom: 0.35rem;
}

.settings-theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
}

@media (max-width: 768px) {
  .theme-compact-view {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    padding: 0.85rem;
    box-sizing: border-box;
  }

  .theme-compact-actions {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
    box-sizing: border-box;
  }

  .theme-change-btn,
  .theme-toggle-expand-btn {
    width: 100%;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
  }
}

/* ──────────────────────────────────────────────────────────
   8. RESPONSIVE DESIGN & MOTION REDUCTION
   ────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .first-theme-selection-grid,
  .settings-theme-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .first-theme-selection-content {
    padding: 1.6rem 1.4rem;
  }
}

@media (max-width: 540px) {
  .theme-popover-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
  
  .first-theme-selection-grid,
  .settings-theme-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }
  
  .first-theme-selection {
    padding: 0.75rem;
  }
  
  .first-theme-selection-content {
    padding: 1.25rem 1rem;
    border-radius: 1.15rem;
  }
  
  .first-theme-selection-title {
    font-size: 1.3rem;
  }
  
  .first-continue-btn {
    width: 100%;
    padding: 0.8rem 1.5rem;
  }
  
  .theme-popover-panel {
    padding: 1.15rem 1rem;
    border-radius: 1.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  body::after,
  .first-theme-selection-content,
  .theme-popover-panel,
  .theme-select-card {
    animation: none !important;
    transition: none !important;
  }
}
