@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

/**
 * IFL Multiagent Frontend
 * Modern minimal dark theme - Mobile responsive
 */

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

/* Dark Theme (Default) - Monochrome B&W + Amber Contrast */
:root {
    --primary: #ffffff;
    --primary-hover: #d4d4d8;
    --primary-muted: rgba(255, 255, 255, 0.06);
    --primary-fg: #050505;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --bg: #050505;
    --bg-secondary: #0a0a0a;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-elevated: rgba(255, 255, 255, 0.05);
    --bg-tertiary: rgba(255, 255, 255, 0.07);
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --success: #10b981;
    --error: #EF4444;
    --warning: #F59E0B;
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Rich content colors */
    --code-bg: #0f0f11;
    --code-text: #d4d4d8;
    --table-header: #141416;
    --table-row-alt: rgba(255, 255, 255, 0.02);
    --chip-bg: rgba(255, 255, 255, 0.06);
    --chip-text: #d4d4d8;
    --search-highlight: rgba(245, 158, 11, 0.4);

    /* User/Assistant message colors */
    --msg-user-bg: rgba(255, 255, 255, 0.04);
    --msg-user-text: #e4e4e7;
    --msg-assistant-bg: var(--bg-elevated);
    --msg-assistant-text: #e4e4e7;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.6);

    /* Neon accents — neutral + functional colors */
    --neon-indigo: #d4d4d8;
    --neon-indigo-glow: rgba(255, 255, 255, 0.1);
    --neon-amber: #f59e0b;
    --neon-amber-glow: rgba(245, 158, 11, 0.3);
    --neon-emerald: #34d399;
    --neon-emerald-glow: rgba(52, 211, 153, 0.3);
    --neon-cyan: #22d3ee;
    --neon-cyan-glow: rgba(34, 211, 238, 0.35);
    --neon-rose: #d4d4d8;
    --neon-rose-glow: rgba(255, 255, 255, 0.1);
    --neon-violet: #d4d4d8;
    --neon-violet-glow: rgba(255, 255, 255, 0.1);
    --neon-teal: #2dd4bf;
    --neon-teal-glow: rgba(45, 212, 191, 0.35);
    --neon-orange: #f59e0b;
    --neon-orange-glow: rgba(245, 158, 11, 0.35);
}

/* Light Theme - Monochrome B&W + Amber Contrast */
:root.light-mode {
    --primary: #0a0a0a;
    --primary-hover: #27272a;
    --primary-muted: rgba(0, 0, 0, 0.04);
    --primary-fg: #ffffff;
    --accent: #d97706;
    --accent-hover: #b45309;
    --bg: #f8f8f8;
    --bg-secondary: #f4f4f5;
    --bg-card: #ffffff;
    --bg-elevated: #e4e4e7;
    --bg-tertiary: #d4d4d8;
    --text: #0a0a0a;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --success: #059669;
    --error: #DC2626;
    --warning: #D97706;

    /* Rich content colors */
    --code-bg: #f4f4f5;
    --code-text: #18181b;
    --table-header: #e4e4e7;
    --table-row-alt: rgba(0, 0, 0, 0.02);
    --chip-bg: rgba(0, 0, 0, 0.04);
    --chip-text: #27272a;
    --search-highlight: rgba(245, 158, 11, 0.4);

    /* User/Assistant message colors */
    --msg-user-bg: rgba(0, 0, 0, 0.03);
    --msg-user-text: #27272a;
    --msg-assistant-bg: var(--bg-elevated);
    --msg-assistant-text: #18181b;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.1);

    /* Neon accents (toned for light) */
    --neon-indigo: #52525b;
    --neon-indigo-glow: rgba(0, 0, 0, 0.05);
    --neon-amber: #d97706;
    --neon-amber-glow: rgba(217, 119, 6, 0.2);
    --neon-emerald: #059669;
    --neon-emerald-glow: rgba(5, 150, 105, 0.2);
    --neon-cyan: #0891b2;
    --neon-cyan-glow: rgba(8, 145, 178, 0.2);
    --neon-rose: #52525b;
    --neon-rose-glow: rgba(0, 0, 0, 0.05);
    --neon-violet: #52525b;
    --neon-violet-glow: rgba(0, 0, 0, 0.05);
    --neon-teal: #0d9488;
    --neon-teal-glow: rgba(13, 148, 136, 0.2);
    --neon-orange: #d97706;
    --neon-orange-glow: rgba(217, 119, 6, 0.2);
}

/* ═══════════════════════════════════════════════════════════════
   STYLE THEMES — applied via class on <html>
   Each theme defines its own dark/light variable overrides.
   The "geek" theme is the default (no class needed).
   ═══════════════════════════════════════════════════════════════ */

/* --- MINIMAL THEME (dark) — clean layout, B&W --- */
:root.theme-minimal {
    --primary: #ffffff;
    --primary-hover: #d4d4d8;
    --primary-muted: rgba(255, 255, 255, 0.06);
    --primary-fg: #050505;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.1);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.15);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.2);
    --neon-indigo: #d4d4d8;
    --neon-indigo-glow: rgba(255, 255, 255, 0.1);
    --neon-violet: #d4d4d8;
    --neon-violet-glow: rgba(255, 255, 255, 0.1);
}

/* --- MINIMAL THEME (light) --- */
:root.theme-minimal.light-mode {
    --primary: #0a0a0a;
    --primary-hover: #27272a;
    --primary-muted: rgba(0, 0, 0, 0.04);
    --primary-fg: #ffffff;
    --neon-indigo: #52525b;
    --neon-indigo-glow: rgba(0, 0, 0, 0.05);
    --neon-violet: #52525b;
    --neon-violet-glow: rgba(0, 0, 0, 0.05);
}

/* --- DYSTOPIAN THEME (dark) — sharp edges, glitch, B&W --- */
:root.theme-dystopian {
    --primary: #ffffff;
    --primary-hover: #d4d4d8;
    --primary-muted: rgba(255, 255, 255, 0.06);
    --primary-fg: #050505;
    --accent: #f59e0b;
    --bg: #050505;
    --bg-secondary: #0a0a0a;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-elevated: rgba(255, 255, 255, 0.05);
    --bg-tertiary: rgba(255, 255, 255, 0.07);
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #52525b;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --success: #10b981;
    --error: #f43f5e;
    --warning: #f59e0b;
    --font-body: 'Inter', system-ui, sans-serif;
    --font-mono: 'Share Tech Mono', 'Courier New', monospace;
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 6px;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.5);
    --neon-indigo: #d4d4d8;
    --neon-indigo-glow: rgba(255, 255, 255, 0.1);
    --neon-emerald: #22d3ee;
    --neon-emerald-glow: rgba(34, 211, 238, 0.4);
    --neon-cyan: #22d3ee;
    --neon-cyan-glow: rgba(34, 211, 238, 0.5);
    --neon-rose: #d4d4d8;
    --neon-rose-glow: rgba(255, 255, 255, 0.1);
    --neon-violet: #d4d4d8;
    --neon-violet-glow: rgba(255, 255, 255, 0.1);
}

/* --- DYSTOPIAN THEME (light) --- */
:root.theme-dystopian.light-mode {
    --primary: #0a0a0a;
    --primary-hover: #27272a;
    --primary-muted: rgba(0, 0, 0, 0.04);
    --primary-fg: #ffffff;
    --bg: #f8f8f8;
    --bg-secondary: #f4f4f5;
    --bg-card: #ffffff;
    --bg-elevated: #e4e4e7;
    --bg-tertiary: #d4d4d8;
    --text: #0a0a0a;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
}

/* --- PURIST THEME (dark) — serif typography, maximum readability, B&W --- */
:root.theme-purist {
    --primary: #ffffff;
    --primary-hover: #d4d4d8;
    --primary-muted: rgba(255, 255, 255, 0.06);
    --primary-fg: #050505;
    --font-body: 'Georgia', 'Times New Roman', serif;
    --font-mono: 'Georgia', serif;
    --neon-indigo: #d4d4d8;
    --neon-indigo-glow: rgba(255, 255, 255, 0.06);
    --neon-amber: #d4d4d8;
    --neon-amber-glow: rgba(255, 255, 255, 0.06);
    --neon-violet: #d4d4d8;
    --neon-violet-glow: rgba(255, 255, 255, 0.06);
}

/* --- PURIST THEME (light) --- */
:root.theme-purist.light-mode {
    --primary: #0a0a0a;
    --primary-hover: #27272a;
    --primary-muted: rgba(0, 0, 0, 0.04);
    --primary-fg: #ffffff;
    --neon-indigo: #52525b;
    --neon-indigo-glow: rgba(0, 0, 0, 0.05);
    --neon-violet: #52525b;
    --neon-violet-glow: rgba(0, 0, 0, 0.05);
}

/* --- DYSTOPIAN-SPECIFIC EFFECTS (B&W) --- */
:root.theme-dystopian body {
    text-shadow: none;
}

/* Glitch effect on headings in dystopian (B&W) */
:root.theme-dystopian .action-hero-title,
:root.theme-dystopian .dash-section-title,
:root.theme-dystopian .hw-card-title {
    animation: dystGlitch 8s ease-in-out infinite;
}

@keyframes dystGlitch {
    0%, 94%, 100% { text-shadow: 0 0 2px rgba(255,255,255,0.2); }
    95% { text-shadow: -2px 0 rgba(255,255,255,0.4), 2px 0 rgba(255,255,255,0.2); }
    96% { text-shadow: 2px 0 rgba(255,255,255,0.4), -2px 0 rgba(255,255,255,0.2); }
    97% { text-shadow: 0 0 2px rgba(255,255,255,0.2); }
}

/* ═══════════════════════════════════════════════════════════
   COLOR THEMES — background color palettes (desktop only)
   Work alongside style themes (geek/minimal/dystopian/purist)
   ═══════════════════════════════════════════════════════════ */

/* --- Violet Light (tint — lighter, airy) --- */
:root.color-violet-light {
    --bg: #0e0b18; --bg-secondary: #161222; --bg-card: #161222;
    --bg-elevated: #1e182e; --bg-tertiary: #261f3a;
    --primary: #a78bfa; --primary-hover: #c4b5fd; --primary-muted: rgba(167,139,250,0.12);
    --border: #302850; --border-hover: #403562;
    --msg-user-bg: rgba(167,139,250,0.1); --msg-user-text: #c4b5fd;
}
:root.color-violet-light.light-mode {
    --bg: #f5f3ff; --bg-secondary: #ede9fe; --bg-card: #ffffff;
    --bg-elevated: #ddd6fe; --bg-tertiary: #c4b5fd;
    --border: #c4b5fd; --border-hover: #a78bfa;
}

/* --- Violet Mid (brand center) --- */
:root.color-violet-mid {
    --bg: #0c0818; --bg-secondary: #130e22; --bg-card: #130e22;
    --bg-elevated: #1c1530; --bg-tertiary: #241c3e;
    --primary: #8b5cf6; --primary-hover: #a78bfa; --primary-muted: rgba(139,92,246,0.12);
    --border: #2e2252; --border-hover: #3e3065;
    --msg-user-bg: rgba(139,92,246,0.1); --msg-user-text: #c4b5fd;
}
:root.color-violet-mid.light-mode {
    --bg: #f3f0ff; --bg-secondary: #e8e2fc; --bg-card: #ffffff;
    --bg-elevated: #d8d0f5; --bg-tertiary: #c0b4e8;
    --border: #c0b4e8; --border-hover: #a78bfa;
}

/* --- Violet Deep (shade — rich, dramatic) --- */
:root.color-violet-deep {
    --bg: #08051a; --bg-secondary: #0e0a22; --bg-card: #0e0a22;
    --bg-elevated: #15102e; --bg-tertiary: #1c153a;
    --primary: #6d28d9; --primary-hover: #7c3aed; --primary-muted: rgba(109,40,217,0.12);
    --border: #221848; --border-hover: #302258;
    --msg-user-bg: rgba(109,40,217,0.1); --msg-user-text: #a78bfa;
}
:root.color-violet-deep.light-mode {
    --bg: #ece8fc; --bg-secondary: #ddd6f8; --bg-card: #ffffff;
    --bg-elevated: #ccc0f0; --bg-tertiary: #b8a8e5;
    --border: #b8a8e5; --border-hover: #8b5cf6;
}

/* --- Color wheel button (desktop only, uses .icon-btn base) --- */
.color-wheel-btn {
    display: none;
}

@media (min-width: 769px) {
    .color-wheel-btn {
        display: flex;
    }

    .color-wheel-btn:active {
        transform: scale(0.9) rotate(90deg);
    }
}

/* ═══════════════════════════════════════════════════════════
   FOCUS MODES — dashboard layout restructuring (desktop only)
   Scientist = default (no class), Philosopher, Creator
   ═══════════════════════════════════════════════════════════ */

/* Collapsible section chevron */
.dash-section-chevron {
    display: inline-flex;
    align-items: center;
    margin-right: 8px;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}
.dash-section-chevron.collapsed {
    transform: rotate(-90deg);
}
.dash-section-header:hover .dash-section-chevron {
    color: var(--text);
}


/* ═══════════════════════════════════════════════════════════
   GEEK THEME ENHANCEMENTS — retro terminal / green CRT
   ═══════════════════════════════════════════════════════════ */

/* GEEK: Hide all hardware chrome — binary glitch + violet CRT is the identity */
:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero-strip,
:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero-bg,
:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero-telemetry,
:root:not(.theme-minimal):not(.theme-dystopian) .review-mon-strip,
:root:not(.theme-minimal):not(.theme-dystopian) .review-mon-bottom,
:root:not(.theme-minimal):not(.theme-dystopian) .vlab-inst-panel,
:root:not(.theme-minimal):not(.theme-dystopian) .vlab-inst-bottom,
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-hw-bar,
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-hw-screws,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-hw-bar,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-waveform-bar {
    display: none !important;
}

/* Geek: no CRT scanlines */
:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero::before,
:root:not(.theme-minimal):not(.theme-dystopian) .review-monitor-inner::before,
:root:not(.theme-minimal):not(.theme-dystopian) .vlab-instrument::before,
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-console::before,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-console::before {
    display: none;
}

/* Geek cards: clean borders */
:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero,
:root:not(.theme-minimal):not(.theme-dystopian) .review-monitor-inner,
:root:not(.theme-minimal):not(.theme-dystopian) .vlab-instrument,
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-console,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-console {
    border-color: var(--border);
}

:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero:hover,
:root:not(.theme-minimal):not(.theme-dystopian) .review-monitor-inner:hover,
:root:not(.theme-minimal):not(.theme-dystopian) .vlab-instrument:hover,
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-console:hover,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-console:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Geek: all hardware bar backgrounds get green tint */
:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero-strip,
:root:not(.theme-minimal):not(.theme-dystopian) .review-mon-strip,
:root:not(.theme-minimal):not(.theme-dystopian) .vlab-inst-panel,
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-hw-bar,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-hw-bar {
    background: linear-gradient(180deg, #12101a 0%, #0e0c16 100%) !important;
    border-bottom-color: #1a2a1a !important;
}

/* Geek: bottom bars green tint */
:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero-telemetry,
:root:not(.theme-minimal):not(.theme-dystopian) .review-mon-bottom,
:root:not(.theme-minimal):not(.theme-dystopian) .vlab-inst-bottom,
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-hw-screws,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-waveform-bar {
    background: linear-gradient(0deg, #0a0810 0%, #0e0c16 100%) !important;
    border-top-color: #1a2a1a !important;
}

/* Geek: card backgrounds */
:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero,
:root:not(.theme-minimal):not(.theme-dystopian) .review-monitor-inner,
:root:not(.theme-minimal):not(.theme-dystopian) .vlab-instrument,
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-console,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-console {
    background: var(--bg-card);
}

/* Geek: clean title styling */
:root:not(.theme-minimal):not(.theme-dystopian) .hw-title-learn,
:root:not(.theme-minimal):not(.theme-dystopian) .hw-title-review,
:root:not(.theme-minimal):not(.theme-dystopian) .hw-title-vlab,
:root:not(.theme-minimal):not(.theme-dystopian) .hw-title-georadar,
:root:not(.theme-minimal):not(.theme-dystopian) .hw-title-chrono {
    color: var(--text);
}

/* Geek: subtitles */
:root:not(.theme-minimal):not(.theme-dystopian) .hw-card-sub {
    color: var(--text-muted);
    font-size: 12px;
}

/* Geek: icon backgrounds */
:root:not(.theme-minimal):not(.theme-dystopian) .hw-icon-learn,
:root:not(.theme-minimal):not(.theme-dystopian) .hw-icon-review,
:root:not(.theme-minimal):not(.theme-dystopian) .hw-icon-vlab,
:root:not(.theme-minimal):not(.theme-dystopian) .hw-icon-georadar,
:root:not(.theme-minimal):not(.theme-dystopian) .hw-icon-chrono {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

/* Geek: hide pulse ring */
:root:not(.theme-minimal):not(.theme-dystopian) .hw-card-icon-pulse {
    display: none !important;
}

/* Geek: section dividers */
:root:not(.theme-minimal):not(.theme-dystopian) .dash-section-line {
    background: linear-gradient(90deg, var(--border), transparent);
}

:root:not(.theme-minimal):not(.theme-dystopian) .dash-section-title {
    color: var(--text-muted);
}

:root:not(.theme-minimal):not(.theme-dystopian) .dash-section-desc {
    color: var(--text-muted);
}

/* Geek: hardware buttons — green accent on hover */
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-hw-btn,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-hw-btn {
    border-color: #1a1530;
    background: #0a0810;
}

:root:not(.theme-minimal):not(.theme-dystopian) .georadar-console:hover .georadar-hw-btn,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-console:hover .chrono-hw-btn {
    color: #c0c0c0 !important;
    border-color: rgba(192, 192, 192, 0.3) !important;
}

/* Geek: knobs — green indicator */
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-hw-knob,
:root:not(.theme-minimal):not(.theme-dystopian) .chrono-hw-knob {
    border-color: #1a1530;
}

/* Geek: LED colors — green primary */
:root:not(.theme-minimal):not(.theme-dystopian) .georadar-led-on,
:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero-led {
    background: #c0c0c0 !important;
    box-shadow: 0 0 8px rgba(192, 192, 192, 0.8) !important;
}

/* Geek: action cards — green border on hover */
:root:not(.theme-minimal):not(.theme-dystopian) .action-card:hover {
    border-color: rgba(192, 192, 192, 0.2);
    box-shadow: 0 0 12px rgba(192, 192, 192, 0.05);
}

/* Geek: telemetry values — green */
:root:not(.theme-minimal):not(.theme-dystopian) .learn-telem-val {
    color: #c0c0c0 !important;
}

:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero-status {
    color: #c0c0c0;
}

:root:not(.theme-minimal):not(.theme-dystopian) .learn-hero-mode {
    color: #c0c0c0;
    border-color: rgba(192, 192, 192, 0.3);
}

/* --- Geek light mode overrides --- */
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .hw-title-learn,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .hw-title-review,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .hw-title-vlab,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .hw-title-georadar,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .hw-title-chrono {
    color: #555555;
    text-shadow: none;
}

:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .hw-card-sub {
    color: var(--text);
    text-shadow: none;
}

:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .learn-hero,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .review-monitor-inner,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .vlab-instrument,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .georadar-console,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .chrono-console {
    background: var(--bg-card);
    border-color: var(--border);
}

:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .learn-hero-strip,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .review-mon-strip,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .vlab-inst-panel,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .georadar-hw-bar,
:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .chrono-hw-bar {
    background: linear-gradient(180deg, #e4e4e7 0%, #f4f4f5 100%) !important;
    border-bottom-color: var(--border) !important;
}

:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .hw-card-icon {
    color: var(--text) !important;
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: var(--border) !important;
}

:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .dash-section-title {
    color: var(--text);
    text-shadow: none;
}

:root.light-mode:not(.theme-minimal):not(.theme-dystopian) .dash-section-desc {
    color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════
   MINIMAL THEME — Dashboard Card Overrides
   Clean, flat, no hardware chrome. Inter font throughout.
   ═══════════════════════════════════════════════════════════════ */

/* MINIMAL: Typography */
:root.theme-minimal {
    --font-display: 'Inter', system-ui, sans-serif;
}

/* MINIMAL: Hide ALL hardware chrome */
:root.theme-minimal .learn-hero-strip,
:root.theme-minimal .learn-hero-bg,
:root.theme-minimal .learn-hero-telemetry,
:root.theme-minimal .review-mon-strip,
:root.theme-minimal .review-mon-bottom,
:root.theme-minimal .vlab-inst-panel,
:root.theme-minimal .vlab-inst-bottom,
:root.theme-minimal .georadar-hw-bar,
:root.theme-minimal .georadar-hw-screws,
:root.theme-minimal .chrono-hw-bar,
:root.theme-minimal .chrono-waveform-bar {
    display: none !important;
}

/* MINIMAL: Hide all animated decorations */
:root.theme-minimal .vlab-bubble,
:root.theme-minimal .georadar-hw-led,
:root.theme-minimal .chrono-hw-led,
:root.theme-minimal .learn-hero-orb,
:root.theme-minimal .hw-card-icon-pulse,
:root.theme-minimal .review-mon-led,
:root.theme-minimal .learn-hero-led,
:root.theme-minimal .vlab-led-green,
:root.theme-minimal .vlab-led-amber,
:root.theme-minimal .vlab-knob,
:root.theme-minimal .vlab-gauge {
    display: none !important;
}

/* MINIMAL: Hardware buttons hidden */
:root.theme-minimal .georadar-hw-btn,
:root.theme-minimal .chrono-hw-btn {
    display: none !important;
}

/* MINIMAL: Clean flat cards */
:root.theme-minimal .learn-hero,
:root.theme-minimal .review-monitor-inner,
:root.theme-minimal .vlab-instrument,
:root.theme-minimal .georadar-console,
:root.theme-minimal .chrono-console {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-sm) !important;
    transition: box-shadow 0.2s, border-color 0.2s !important;
    overflow: visible !important;
}

:root.theme-minimal .learn-hero:hover,
:root.theme-minimal .review-monitor-inner:hover,
:root.theme-minimal .vlab-instrument:hover,
:root.theme-minimal .georadar-console:hover,
:root.theme-minimal .chrono-console:hover {
    box-shadow: var(--shadow-md) !important;
    border-color: var(--border-hover) !important;
    transform: none !important;
}

/* MINIMAL: Clean body padding */
:root.theme-minimal .hw-card-body {
    padding: 20px 24px !important;
    gap: 18px !important;
}

/* MINIMAL: Clean icon — no pulse, no animation, circle with subtle bg */
:root.theme-minimal .hw-card-icon {
    border-radius: 50% !important;
    width: 52px !important;
    height: 52px !important;
    border: none !important;
    animation: none !important;
}

:root.theme-minimal .hw-card-icon-pulse {
    display: none !important;
}

/* MINIMAL: Clean title — no glow, no text-shadow */
:root.theme-minimal .hw-card-title {
    font-family: 'Inter', system-ui, sans-serif !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em !important;
    text-shadow: none !important;
    text-transform: none !important;
    animation: none !important;
}

:root.theme-minimal .hw-card-sub {
    font-family: 'Inter', system-ui, sans-serif !important;
    font-size: 12px !important;
    color: var(--text-muted) !important;
    text-shadow: none !important;
    letter-spacing: normal !important;
}

/* MINIMAL: Title colors — B&W */
:root.theme-minimal .hw-title-learn,
:root.theme-minimal .hw-title-review,
:root.theme-minimal .hw-title-vlab,
:root.theme-minimal .hw-title-georadar,
:root.theme-minimal .hw-title-chrono { color: var(--text) !important; text-shadow: none !important; }

:root.theme-minimal.light-mode .hw-title-learn,
:root.theme-minimal.light-mode .hw-title-review,
:root.theme-minimal.light-mode .hw-title-vlab,
:root.theme-minimal.light-mode .hw-title-georadar,
:root.theme-minimal.light-mode .hw-title-chrono { color: var(--text) !important; }

/* MINIMAL: Icon backgrounds — B&W */
:root.theme-minimal .hw-icon-learn,
:root.theme-minimal .hw-icon-review,
:root.theme-minimal .hw-icon-vlab,
:root.theme-minimal .hw-icon-georadar,
:root.theme-minimal .hw-icon-chrono { background: rgba(255, 255, 255, 0.04) !important; color: var(--text-secondary) !important; }

:root.theme-minimal.light-mode .hw-icon-learn,
:root.theme-minimal.light-mode .hw-icon-review,
:root.theme-minimal.light-mode .hw-icon-vlab,
:root.theme-minimal.light-mode .hw-icon-georadar,
:root.theme-minimal.light-mode .hw-icon-chrono { background: rgba(0, 0, 0, 0.04) !important; color: var(--text-secondary) !important; }

/* MINIMAL: Section dividers — simpler */
:root.theme-minimal .dash-section-title {
    font-family: 'Inter', system-ui, sans-serif !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    font-size: 11px !important;
    text-shadow: none !important;
    animation: none !important;
}

:root.theme-minimal .dash-section-desc {
    font-family: 'Inter', system-ui, sans-serif !important;
    text-shadow: none !important;
}

:root.theme-minimal .dash-section-line {
    background: var(--border) !important;
}

/* MINIMAL: Action cards — cleaner */
:root.theme-minimal .action-card {
    border-radius: 12px !important;
    border-width: 1px !important;
    box-shadow: var(--shadow-sm) !important;
}

:root.theme-minimal .action-card:hover {
    box-shadow: var(--shadow-md) !important;
    transform: none !important;
}

/* MINIMAL: Tools bar cards — clean, no left border, subtle bg */
:root.theme-minimal .tools-bar .action-card {
    border-left: none !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 14px !important;
}
:root.theme-minimal .tools-bar .action-card::after {
    display: none;
}
:root.theme-minimal .tools-bar .action-card:hover {
    background: var(--bg-elevated) !important;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.08) !important;
    border-color: rgba(59, 130, 246, 0.25) !important;
}
:root.theme-minimal .tools-bar .action-card-icon {
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.06) !important;
}

/* MINIMAL: Remove all glow/neon from action hero */
:root.theme-minimal .action-hero-title {
    font-family: 'Inter', system-ui, sans-serif !important;
    text-shadow: none !important;
    animation: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   DYSTOPIAN THEME — Dashboard Card Overrides
   Aggressive cyberpunk: red/pink/cyan neon, scan lines, glitch.
   ═══════════════════════════════════════════════════════════════ */

/* DYSTOPIAN: Typography */
:root.theme-dystopian {
    --font-display: 'Share Tech Mono', 'Courier New', monospace;
}

/* DYSTOPIAN: Sharp cards, B&W */
:root.theme-dystopian .learn-hero,
:root.theme-dystopian .review-monitor-inner,
:root.theme-dystopian .vlab-instrument,
:root.theme-dystopian .georadar-console,
:root.theme-dystopian .chrono-console {
    border-radius: 2px !important;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3), inset 0 0 30px rgba(0,0,0,0.2) !important;
}

:root.theme-dystopian .learn-hero:hover,
:root.theme-dystopian .review-monitor-inner:hover,
:root.theme-dystopian .vlab-instrument:hover,
:root.theme-dystopian .georadar-console:hover,
:root.theme-dystopian .chrono-console:hover {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05), 0 0 40px rgba(0, 0, 0, 0.3) !important;
    animation: dystFlicker 0.15s ease;
}

@keyframes dystFlicker {
    0% { opacity: 1; }
    25% { opacity: 0.95; }
    50% { opacity: 1; }
    75% { opacity: 0.97; }
    100% { opacity: 1; }
}

/* DYSTOPIAN: Titles — monospace, B&W */
:root.theme-dystopian .hw-card-title {
    font-family: 'Share Tech Mono', 'Courier New', monospace !important;
    letter-spacing: 1.5px !important;
    text-transform: uppercase !important;
    color: var(--text) !important;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.2) !important;
}

/* DYSTOPIAN: Section dividers — sharp */
:root.theme-dystopian .dash-section-line {
    background: linear-gradient(90deg, var(--border), transparent) !important;
}

:root.theme-dystopian .dash-section-title {
    font-family: 'Share Tech Mono', monospace !important;
    color: var(--text-secondary) !important;
    text-shadow: none !important;
}

/* DYSTOPIAN: Icon backgrounds — B&W with sharp corners */
:root.theme-dystopian .hw-card-icon {
    border: 1px solid var(--border) !important;
    border-radius: 2px !important;
}

:root.theme-dystopian .hw-icon-learn { background: rgba(255, 255, 255, 0.04) !important; color: var(--text) !important; }
:root.theme-dystopian .hw-icon-review { background: rgba(255, 255, 255, 0.04) !important; color: var(--text) !important; }
:root.theme-dystopian .hw-icon-vlab { background: rgba(255, 255, 255, 0.04) !important; color: var(--text-secondary) !important; }
:root.theme-dystopian .hw-icon-georadar { background: rgba(255, 255, 255, 0.04) !important; color: var(--text-secondary) !important; }
:root.theme-dystopian .hw-icon-chrono { background: rgba(255, 255, 255, 0.04) !important; color: var(--text-secondary) !important; }

/* DYSTOPIAN: Scan line overlay — B&W */
:root.theme-dystopian .learn-hero::before,
:root.theme-dystopian .review-monitor-inner::before,
:root.theme-dystopian .vlab-instrument::before,
:root.theme-dystopian .georadar-console::before,
:root.theme-dystopian .chrono-console::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.015) 2px, rgba(255,255,255,0.015) 4px);
    pointer-events: none; z-index: 1; border-radius: inherit;
}

/* DYSTOPIAN: Action cards — sharp corners */
:root.theme-dystopian .action-card {
    border-radius: 2px !important;
}

:root.theme-dystopian .action-card:hover {
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.05) !important;
}

:root.theme-dystopian .tools-bar .action-card-icon {
    border-radius: 2px;
}

/* DYSTOPIAN: Subtitles — monospace */
:root.theme-dystopian .hw-card-sub {
    font-family: 'Share Tech Mono', monospace !important;
    font-size: 10px !important;
    letter-spacing: 0.5px !important;
    color: var(--text-muted) !important;
}

/* DYSTOPIAN: Learn hero orbs — red/pink */
:root.theme-dystopian .learn-hero-orb {
    background: radial-gradient(circle, rgba(244, 63, 94, 0.15), transparent) !important;
}

/* DYSTOPIAN: Light mode adjustments */
:root.theme-dystopian.light-mode .learn-hero,
:root.theme-dystopian.light-mode .review-monitor-inner,
:root.theme-dystopian.light-mode .vlab-instrument,
:root.theme-dystopian.light-mode .georadar-console,
:root.theme-dystopian.light-mode .chrono-console {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
}

:root.theme-dystopian.light-mode .learn-hero::before,
:root.theme-dystopian.light-mode .review-monitor-inner::before,
:root.theme-dystopian.light-mode .vlab-instrument::before,
:root.theme-dystopian.light-mode .georadar-console::before,
:root.theme-dystopian.light-mode .chrono-console::before {
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.015) 2px,
        rgba(244, 63, 94, 0.02) 4px
    );
}

:root.theme-dystopian.light-mode .learn-hero-strip,
:root.theme-dystopian.light-mode .review-mon-strip,
:root.theme-dystopian.light-mode .vlab-inst-panel,
:root.theme-dystopian.light-mode .georadar-hw-bar,
:root.theme-dystopian.light-mode .chrono-hw-bar {
    background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-secondary) 100%) !important;
    border-color: var(--border) !important;
}

:root.theme-dystopian.light-mode .learn-hero-telemetry,
:root.theme-dystopian.light-mode .review-mon-bottom,
:root.theme-dystopian.light-mode .vlab-inst-bottom,
:root.theme-dystopian.light-mode .georadar-hw-screws,
:root.theme-dystopian.light-mode .chrono-waveform-bar {
    background: linear-gradient(0deg, var(--bg-tertiary) 0%, var(--bg-secondary) 100%) !important;
    border-color: var(--border) !important;
}

:root.theme-dystopian.light-mode .learn-hero-led,
:root.theme-dystopian.light-mode .review-mon-led,
:root.theme-dystopian.light-mode .vlab-led-green {
    background: var(--text-muted) !important;
    box-shadow: none !important;
}

:root.theme-dystopian.light-mode .hw-card-sub {
    color: var(--text-muted) !important;
}

/* ═══════════════════════════════════════════════════════════
   PURIST THEME — cream, serif, no icons, just titles + text
   ═══════════════════════════════════════════════════════════ */

/* PURIST: Hide ALL chrome, icons, animations, hardware bars */
:root.theme-purist .learn-hero-strip,
:root.theme-purist .learn-hero-bg,
:root.theme-purist .learn-hero-telemetry,
:root.theme-purist .review-mon-strip,
:root.theme-purist .review-mon-bottom,
:root.theme-purist .vlab-inst-panel,
:root.theme-purist .vlab-inst-bottom,
:root.theme-purist .georadar-hw-bar,
:root.theme-purist .georadar-hw-screws,
:root.theme-purist .chrono-hw-bar,
:root.theme-purist .chrono-waveform-bar,
:root.theme-purist .hw-card-icon,
:root.theme-purist .hw-card-icon-pulse,
:root.theme-purist .vlab-bubble,
:root.theme-purist .learn-hero-orb {
    display: none !important;
}

/* PURIST: Cards become invisible — no background, no border, no box */
:root.theme-purist .learn-hero,
:root.theme-purist .review-monitor-inner,
:root.theme-purist .vlab-instrument,
:root.theme-purist .georadar-console,
:root.theme-purist .chrono-console {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

:root.theme-purist .learn-hero:hover,
:root.theme-purist .review-monitor-inner:hover,
:root.theme-purist .vlab-instrument:hover,
:root.theme-purist .georadar-console:hover,
:root.theme-purist .chrono-console:hover {
    box-shadow: none !important;
    transform: none !important;
}

/* PURIST: No ::before overlays */
:root.theme-purist .learn-hero::before,
:root.theme-purist .review-monitor-inner::before,
:root.theme-purist .vlab-instrument::before,
:root.theme-purist .georadar-console::before,
:root.theme-purist .chrono-console::before {
    display: none !important;
}

/* PURIST: Remove card row margins — just a tight list */
:root.theme-purist .vlab-card-row,
:root.theme-purist .georadar-card-row,
:root.theme-purist .chrono-card-row,
:root.theme-purist .review-monitor {
    margin-bottom: 0;
}

/* PURIST: Body — just text, tight padding */
:root.theme-purist .hw-card-body {
    padding: 8px 16px;
    gap: 0;
}

/* PURIST: Title — serif, simple, with hover underline */
:root.theme-purist .hw-card-title {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none !important;
    text-shadow: none !important;
    color: var(--text);
    cursor: pointer;
    display: inline;
}

:root.theme-purist .hw-title-learn,
:root.theme-purist .hw-title-review,
:root.theme-purist .hw-title-vlab,
:root.theme-purist .hw-title-georadar,
:root.theme-purist .hw-title-chrono {
    color: var(--text) !important;
    text-shadow: none !important;
}

/* Hover underline on titles */
:root.theme-purist .learn-hero:hover .hw-card-title,
:root.theme-purist .review-monitor-inner:hover .hw-card-title,
:root.theme-purist .vlab-instrument:hover .hw-card-title,
:root.theme-purist .georadar-console:hover .hw-card-title,
:root.theme-purist .chrono-console:hover .hw-card-title {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* PURIST: Subtitles — inline after title, em dash separator */
:root.theme-purist .hw-card-sub {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
    display: inline;
    margin-left: 0;
}

:root.theme-purist .hw-card-sub::before {
    content: ' \2014  ';
    color: var(--text-muted);
}

/* PURIST: hw-card-text becomes inline flow */
:root.theme-purist .hw-card-text {
    display: inline;
    gap: 0;
}

/* PURIST: Section dividers — simple line, serif */
:root.theme-purist .dash-section-line {
    background: var(--border);
    height: 1px;
}

:root.theme-purist .dash-section-title {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-weight: 400;
    font-style: italic;
    letter-spacing: 0.5px;
    text-transform: none;
    color: var(--text-secondary);
    text-shadow: none;
    font-size: 13px;
}

:root.theme-purist .dash-section-desc {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 12px;
    color: var(--text-muted);
    font-style: normal;
}

/* PURIST: Action cards — no cards, just text list */
:root.theme-purist .action-bar,
:root.theme-purist .tools-bar {
    display: flex;
    flex-direction: column;
    gap: 0;
}

:root.theme-purist .action-card {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 6px 0 !important;
    gap: 0 !important;
}

:root.theme-purist .action-card::after {
    display: none;
}

:root.theme-purist .action-card:hover {
    box-shadow: none !important;
    transform: none !important;
}

:root.theme-purist .action-card:hover .action-card-title {
    text-decoration: underline;
    text-underline-offset: 3px;
}

:root.theme-purist .action-card-icon {
    display: none !important;
}

:root.theme-purist .action-card-title {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-weight: 400;
    font-size: 15px;
    color: var(--text);
    display: inline;
}

:root.theme-purist .action-card-subtitle {
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 13px;
    font-style: italic;
    color: var(--text-muted);
    display: inline;
}

:root.theme-purist .action-card-subtitle::before {
    content: ' \2014  ';
}

:root.theme-purist .action-card-text {
    display: inline;
    gap: 0;
}

/* PURIST: Force serif everywhere */
:root.theme-purist {
    font-family: 'Georgia', 'Times New Roman', serif !important;
}
:root.theme-purist *,
:root.theme-purist *::before,
:root.theme-purist *::after {
    font-family: inherit !important;
}
/* PURIST: Preserve monospace only in code blocks */
:root.theme-purist code,
:root.theme-purist pre,
:root.theme-purist pre *,
:root.theme-purist .code-block,
:root.theme-purist .code-block * {
    font-family: 'Fira Code', 'Monaco', monospace !important;
}
/* PURIST: Preserve KaTeX math fonts */
:root.theme-purist .katex,
:root.theme-purist .katex * {
    font-family: KaTeX_Main, 'Times New Roman', serif !important;
}

/* PURIST: No animations */
:root.theme-purist * {
    animation-duration: 0s !important;
}

/* Style theme cycle — uses same .icon-btn as light/dark toggle */

/* Accessibility: visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

html {
    font-size: 15px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Typography */
h1 { font-size: 1.25rem; font-weight: 600; }
h2 { font-size: 1rem; font-weight: 600; }
h3 { font-size: 0.9rem; font-weight: 500; }
p { color: var(--text-secondary); }

a {
    color: var(--primary-hover);
    text-decoration: none;
    transition: color 0.15s;
}

a:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Layout */
.dashboard {
    max-width: 1000px;
    margin: 0 auto;
    padding: 24px;
    position: relative;
    z-index: 1;
}

/* Dashboard Tabs */
.dash-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 36px;
    padding: 3px;
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border);
    width: fit-content;
}

.dash-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 11px;
    transition: all 0.25s ease;
    font-family: inherit;
}

.dash-tab:hover {
    color: var(--text-secondary);
    background: var(--bg-elevated);
}

.dash-tab.active {
    background: var(--bg-elevated);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.dash-tab svg {
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity var(--transition);
}

.dash-tab.active svg {
    opacity: 1;
    stroke: var(--primary);
}

.dash-tab-content {
    display: none;
}

.dash-tab-content.active {
    display: block;
}

.light-mode .dash-tab.active {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

@media (max-width: 480px) {
    .dash-tab {
        padding: 8px 12px;
        font-size: 0.8rem;
        gap: 6px;
    }
    .dash-tab svg {
        width: 14px;
        height: 14px;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.card-header {
    margin-bottom: 16px;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 24px;
    border-radius: 12px;
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    font-family: inherit;
}

.btn:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--text);
    color: var(--bg);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-primary:hover {
    opacity: 0.85;
}

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

.btn-secondary:hover {
    border-color: var(--border-hover);
}

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

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-input::placeholder {
    color: var(--text-muted);
}

/* Consent Section */
.consent-section {
    margin-top: 20px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.consent-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.consent-checkbox:last-child {
    margin-bottom: 0;
}

.consent-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
    flex-shrink: 0;
    cursor: pointer;
}

.consent-checkbox label {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    cursor: pointer;
}

.consent-checkbox label a {
    color: var(--primary);
    text-decoration: none;
}

.consent-checkbox label a:hover {
    text-decoration: underline;
}

/* Header */
.header {
    background: transparent;
    padding: 20px 0;
    border-radius: 0;
    margin-bottom: 32px;
    border: none;
    min-height: 72px;
    position: relative;
    z-index: 100;
}

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

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    height: 44px;
}


/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 4px;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: all 0.15s;
}

.modal-close:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Settings Modal */
.modal-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-container .modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-container .modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.modal-container .modal-body {
    padding: 24px;
}

.form-section {
    margin-bottom: 32px;
}

.form-section:last-child {
    margin-bottom: 0;
}

.form-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.danger-zone {
    border-top: 1px solid var(--border);
    padding-top: 24px;
    margin-top: 24px;
}

.danger-zone h3 {
    color: #a1a1aa;
}

.btn-danger {
    background: var(--primary);
    color: var(--primary-fg);
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

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

.btn-danger:disabled {
    background: #6b7280;
    cursor: not-allowed;
}

.warning-text {
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.5;
}

.delete-list {
    list-style: disc;
    margin-left: 20px;
    margin-bottom: 16px;
    color: var(--text-muted);
}

/* ============================================================================
   Professional Settings Modal
   ============================================================================ */

.settings-modal-container {
    max-width: 900px;
    width: 95%;
    max-height: 85vh;
    padding: 0;
    overflow: hidden;
}

.settings-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    height: 85vh;
    max-height: 85vh;
}

.settings-sidebar {
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.settings-sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.settings-sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.settings-nav {
    list-style: none;
    padding: 12px;
    margin: 0;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.settings-nav-item:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.settings-nav-item.active {
    background: var(--accent);
    color: white;
}

.settings-nav-item.active svg {
    stroke: white;
}

.settings-nav-item svg {
    flex-shrink: 0;
    stroke: currentColor;
}

.settings-content {
    background: var(--bg-card);
    overflow-y: auto;
    position: relative;
    padding: 32px;
    min-height: 0; /* Required for grid child to respect parent max-height */
}

.settings-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-close-btn:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.settings-tab {
    display: none;
}

.settings-tab.active {
    display: block;
}

.settings-tab-header {
    margin-bottom: 32px;
    padding-right: 50px;
}

.settings-tab-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--text);
}

.settings-tab-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.settings-form {
    max-width: 500px;
}

.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.settings-field {
    margin-bottom: 24px;
}

.settings-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text);
}

.settings-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.settings-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.settings-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.settings-actions {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* Toggle switches */
.settings-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.settings-toggle-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}

.settings-toggle-item:last-child {
    border-bottom: none;
}

.settings-toggle-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-toggle-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.settings-toggle-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.settings-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.settings-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.settings-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 26px;
    transition: all 0.2s;
}

.settings-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: white;
    border-radius: 50%;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.settings-toggle input:checked + .settings-toggle-slider {
    background: var(--accent);
    border-color: var(--accent);
}

.settings-toggle input:checked + .settings-toggle-slider:before {
    transform: translateX(22px);
}

/* Settings cards */
.settings-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 24px;
}

.settings-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.settings-card-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.settings-card-body {
    padding: 20px;
}

.settings-subscription-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.settings-plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--accent), #a1a1aa);
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.settings-plan-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.settings-card.settings-danger {
    border-color: rgba(255, 255, 255, 0.3);
}

.settings-card.settings-danger .settings-card-header {
    background: rgba(255, 255, 255, 0.1);
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.settings-card.settings-danger .settings-card-header h4 {
    color: #a1a1aa;
}

.settings-danger-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0 0 16px 0;
    line-height: 1.5;
}

/* Mobile responsiveness for settings */
@media (max-width: 768px) {
    .settings-modal-container {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .settings-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: 100vh;
        height: 100dvh;
        max-height: 100vh;
        max-height: 100dvh;
    }

    .settings-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .settings-sidebar-header {
        display: none;
    }

    .settings-nav {
        display: flex;
        overflow-x: auto;
        padding: 8px;
        gap: 4px;
    }

    .settings-nav-item {
        flex-shrink: 0;
        padding: 10px 16px;
    }

    .settings-nav-item span {
        display: none;
    }

    .settings-content {
        padding: 24px 20px;
    }

    .settings-row {
        grid-template-columns: 1fr;
    }

    .settings-close-btn {
        top: 12px;
        right: 12px;
    }
}

.delete-list li {
    margin-bottom: 6px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.delete-confirm-modal .modal-body {
    max-width: 400px;
}


/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 55vh;
    min-height: 350px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    line-height: 1.5;
}

.chat-message-user {
    align-self: flex-end;
    background: var(--primary);
    color: var(--primary-fg);
}

.chat-message-assistant {
    align-self: flex-start;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

.chat-message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.chat-agent-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.15);
    color: var(--primary-hover);
    font-size: 0.7rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.chat-input-container {
    display: flex;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.chat-input {
    flex: 1;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

.chat-send-btn {
    padding: 12px 24px;
    background: var(--primary);
    color: var(--primary-fg);
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

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

/* ================================
   Full-Screen Chat Interface
   Split-panel layout like old MCP
   ================================ */

.chat-fullscreen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 10000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    height: 100vh;
    height: 100dvh; /* iOS dynamic viewport */
}

.chat-fullscreen.active {
    display: flex;
}

/* Chrome Header - 64px, layout-stable to prevent twitching */
.chat-fullscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    height: 64px;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 10;
    contain: layout style;
}

.chat-fullscreen-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chat-fullscreen-logo {
    height: 36px;
    border-radius: 8px;
}

.chat-fullscreen-logo-large {
    height: 48px;
    border-radius: 8px;
}

.chat-fullscreen-branding {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-fullscreen-product {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.chat-fullscreen-session {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.chat-fullscreen-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

/* Chat Theme Toggle - matches dashboard style */
.chat-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
}

.chat-theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.chat-theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* Sun icon hidden in dark mode, shown in light mode */
.chat-theme-toggle .icon-sun { display: none; }
.chat-theme-toggle .icon-moon { display: block; }

:root.light-mode .chat-theme-toggle .icon-sun { display: block; }
:root.light-mode .chat-theme-toggle .icon-moon { display: none; }

/* Light mode for chat fullscreen - using :root.light-mode */
:root.light-mode .chat-fullscreen {
    background: #f8f9fa;
}

:root.light-mode .chat-fullscreen-header {
    background: #ffffff;
    border-color: #e5e7eb;
}

:root.light-mode .chat-fullscreen-product,
:root.light-mode .chat-fullscreen-title {
    color: #1a1b26;
}

:root.light-mode .chat-fullscreen-session {
    color: #6b7280;
}

:root.light-mode .chat-panel-left,
:root.light-mode .chat-panel-right {
    background: #ffffff;
    border-color: #e5e7eb;
}

:root.light-mode .chat-log {
    background: #f8f9fa;
}

:root.light-mode .chat-msg.user {
    background: rgba(0, 0, 0, 0.04);
    color: #1a1b26;
}

:root.light-mode .chat-msg.assistant {
    background: #ffffff;
    color: #1a1b26;
}

:root.light-mode .chat-form {
    background: #ffffff;
    border-color: #e5e7eb;
}

:root.light-mode .chat-input-field {
    background: #f8f9fa;
    color: #1a1b26;
    border-color: #e5e7eb;
}

:root.light-mode .chat-input-field::placeholder {
    color: #9ca3af;
}

/* Light mode for mind map */
:root.light-mode .mindmap-canvas {
    background: linear-gradient(135deg, #f8f9fa 0%, #f1f3f9 100%);
}

:root.light-mode .mindmap-svg {
    background-color: #f8f9fa;
    background-image: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.03) 100%);
}

:root.light-mode .mindmap-info {
    background: rgba(255,255,255,0.95);
    border-color: #e5e7eb;
    color: #1a1b26;
}

:root.light-mode .mindmap-info .layout-btn,
:root.light-mode .mindmap-info .zoom-btn,
:root.light-mode .mindmap-info .view-btn {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #374151;
}

:root.light-mode .mindmap-info .layout-btn:hover,
:root.light-mode .mindmap-info .zoom-btn:hover,
:root.light-mode .mindmap-info .view-btn:hover {
    background: var(--primary);
    color: var(--primary-fg);
}

:root.light-mode .mindmap-info .view-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

:root.light-mode .mindmap-node text {
    fill: #1f2937 !important;
    stroke: #ffffff !important;
    stroke-width: 3.5px !important;
    paint-order: stroke fill;
    font-weight: 600 !important;
}

:root.light-mode .link-label-group text {
    fill: #6b7280;
}

/* Light mode for search bar */
:root.light-mode .chat-toolbar {
    background: #ffffff;
    border-color: #e5e7eb;
}

:root.light-mode .search-container input {
    background: #f3f4f6;
    color: #1a1b26;
    border-color: #e5e7eb;
}

:root.light-mode .search-container input::placeholder {
    color: #9ca3af;
}

:root.light-mode .chat-fullscreen-close {
    background: #f3f4f6;
    color: #374151;
}

:root.light-mode .chat-fullscreen-close:hover {
    background: #e5e7eb;
}

:root.light-mode .chat-theme-toggle {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #374151;
}

.chat-fullscreen-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-fullscreen-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-lg);
    border: none;
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.chat-fullscreen-close:hover {
    background: var(--bg-tertiary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.chat-fullscreen-close:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Split Body Container */
.chat-fullscreen-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Left Panel - Chat (40%) */
.chat-panel-left {
    width: var(--chat-width, 40%);
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

/* Right Panel - Mind Map (60%) */
.chat-panel-right {
    width: calc(100% - var(--chat-width, 40%) - 6px);
    position: relative;
    background: var(--bg);
    overflow: hidden;
}

/* Smooth transition on click-to-expand, disabled during drag */
.chat-panel-left, .chat-panel-right {
    transition: width 0.2s ease;
}
.chat-fullscreen-body.dragging .chat-panel-left,
.chat-fullscreen-body.dragging .chat-panel-right,
.chat-fullscreen-body.dragging .panel-divider {
    transition: none;
}

/* Chat Log */
.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
}

/* Message Styles */
.chat-msg {
    margin-bottom: 16px;
    display: block;
    clear: both;
    max-width: 85%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 14px;
    line-height: 1.6;
    animation: slideIn 0.3s ease;
}

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

.chat-msg.user {
    margin-left: auto;
    text-align: right;
    color: var(--msg-user-text);
    padding: 12px 16px;
    background: var(--msg-user-bg);
    border-radius: 16px 16px 4px 16px;
    font-weight: 500;
}

.chat-msg.assistant {
    margin-right: auto;
    text-align: left;
    color: var(--msg-assistant-text);
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-radius: 16px 16px 16px 4px;
}

/* Thinking indicator */
.thinking-indicator {
    animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Chat Form */
.chat-form {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.ai-disclaimer {
    padding: 4px 20px 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.ai-disclaimer a {
    color: var(--primary);
    text-decoration: none;
}

.ai-disclaimer a:hover {
    text-decoration: underline;
}

.chat-input-field {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
    resize: none;
    min-height: 44px;
    max-height: 120px;
}

.chat-input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted);
}

.chat-input-field::placeholder {
    color: var(--text-muted);
}

.chat-submit-btn {
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    border: none;
    background: var(--primary);
    color: var(--primary-fg);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.chat-submit-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.chat-submit-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.chat-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========================================================================
   DRAWING CANVAS - Handwriting Input (Scholar/Sage)
   ======================================================================== */

/* Toggle button in chat form — hidden by default, shown by JS after subscription check */
.chat-draw-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-draw-toggle.visible {
    display: flex;
}

.chat-draw-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.chat-draw-toggle.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

/* Canvas container - replaces textarea when in draw mode */
.drawing-canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    background-color: #000000;
}

:root.light-mode .drawing-canvas-container {
    background-color: #ffffff;
}

/* Toolbar above the canvas */
.drawing-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.drawing-toolbar .drawing-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.drawing-tool-btn,
.drawing-size-btn,
.drawing-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.drawing-tool-btn:hover,
.drawing-size-btn:hover,
.drawing-action-btn:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.drawing-tool-btn.active,
.drawing-size-btn.active {
    background: var(--primary);
    color: var(--primary-fg);
}

/* Canvas wrapper (provides the lined background visible through transparent canvas) */
.drawing-canvas-wrapper {
    flex: 1;
    position: relative;
    min-height: 200px;
    max-height: 300px;
}

/* The actual canvas - transparent so lines show through */
.drawing-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
    background: transparent;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .drawing-canvas-wrapper {
        min-height: 150px;
        max-height: 200px;
    }
}

/* ========================================================================
   FULLSCREEN DRAWING - Mobile overlay mode
   ======================================================================== */

.drawing-canvas-container.drawing-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 10002;
    border-radius: 0;
    border: none;
}

.drawing-canvas-container.drawing-fullscreen .drawing-canvas-wrapper {
    min-height: unset;
    max-height: none;
    flex: 1;
}

.drawing-canvas-container.drawing-fullscreen .drawing-toolbar {
    padding: 8px 12px;
    gap: 4px;
}

.drawing-canvas-container.drawing-fullscreen .drawing-tool-btn,
.drawing-canvas-container.drawing-fullscreen .drawing-size-btn,
.drawing-canvas-container.drawing-fullscreen .drawing-action-btn {
    width: 40px;
    height: 40px;
}

/* Done/Send buttons - hidden in normal mode, shown in fullscreen */
.drawing-done-btn,
.drawing-send-fullscreen-btn {
    display: none;
}

.drawing-fullscreen-right {
    display: none;
    margin-left: auto;
    gap: 8px;
    align-items: center;
}

.drawing-canvas-container.drawing-fullscreen .drawing-fullscreen-right {
    display: flex;
}

.drawing-canvas-container.drawing-fullscreen .drawing-send-fullscreen-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    border-radius: var(--radius-lg);
    border: none;
    background: var(--primary);
    color: var(--primary-fg);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.drawing-canvas-container.drawing-fullscreen .drawing-done-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

/* ========================================================================
   PANEL VIEW STATES (fullscreen toggle for chat / mindmap)
   ======================================================================== */

/* Chat-only: hide mindmap */
.chat-fullscreen-body[data-panel-view="chat-only"] .chat-panel-left {
    width: 100% !important;
    height: 100% !important;
    border-right: none;
    border-bottom: none;
}
.chat-fullscreen-body[data-panel-view="chat-only"] .chat-panel-right {
    display: none !important;
}

/* Mindmap-only: hide chat */
.chat-fullscreen-body[data-panel-view="mindmap-only"] .chat-panel-left {
    display: none !important;
}
.chat-fullscreen-body[data-panel-view="mindmap-only"] .chat-panel-right {
    width: 100% !important;
    height: 100% !important;
}

/* Mobile FAB toggle button */
.panel-toggle-btn {
    display: none;
    position: absolute;
    bottom: 80px;
    right: 20px;
    z-index: 100;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--primary-fg);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
}
.panel-toggle-btn:active {
    transform: scale(0.92);
}
.panel-toggle-btn svg {
    width: 24px;
    height: 24px;
}

/* Show correct icon based on state */
.chat-fullscreen-body[data-panel-view="chat-only"] .panel-toggle-chat-icon,
.chat-fullscreen-body:not([data-panel-view]) .panel-toggle-chat-icon {
    display: none;
}
.chat-fullscreen-body[data-panel-view="chat-only"] .panel-toggle-map-icon,
.chat-fullscreen-body:not([data-panel-view]) .panel-toggle-map-icon {
    display: block;
}
.chat-fullscreen-body[data-panel-view="mindmap-only"] .panel-toggle-map-icon {
    display: none;
}
.chat-fullscreen-body[data-panel-view="mindmap-only"] .panel-toggle-chat-icon {
    display: block;
}

/* Old expand buttons — hidden (replaced by divider) */
.panel-expand-btn { display: none !important; }

/* ============================================
   PANEL DIVIDER — Draggable resize bar
   ============================================ */
.panel-divider {
    width: 6px;
    background: var(--border);
    cursor: col-resize;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    transition: background 0.15s;
    outline: none;
}

.panel-divider:hover,
.panel-divider:focus-visible {
    background: var(--primary, #a1a1aa);
}

.panel-divider:focus-visible {
    box-shadow: 0 0 0 2px var(--primary, #a1a1aa);
}

.panel-divider-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s, background 0.15s, color 0.15s;
    z-index: 6;
}

.panel-divider:hover .panel-divider-btn,
.panel-divider:focus-within .panel-divider-btn {
    opacity: 1;
}

.panel-divider-btn:hover {
    background: var(--primary, #a1a1aa);
    color: var(--primary-fg, #fff);
}

.panel-divider-grip {
    display: flex;
    flex-direction: column;
    gap: 3px;
    opacity: 0;
    transition: opacity 0.2s;
}

.panel-divider:hover .panel-divider-grip {
    opacity: 0.5;
}

.panel-divider-grip span {
    display: block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-muted);
}

/* Hide divider in expanded states */
.chat-fullscreen-body[data-panel-view="chat-only"] .panel-divider,
.chat-fullscreen-body[data-panel-view="mindmap-only"] .panel-divider {
    display: none;
}

/* Restore split button — appears when a panel is fully expanded */
.panel-restore-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 32px;
    height: 48px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.15s, color 0.15s;
}

.panel-restore-btn:hover {
    opacity: 1;
    background: var(--primary, #a1a1aa);
    color: var(--primary-fg);
    border-color: var(--primary);
}

/* Mobile: hide divider + restore, show FAB */
@media (max-width: 768px) {
    .panel-toggle-btn {
        display: flex !important;
    }
    .panel-divider,
    .panel-restore-btn {
        display: none !important;
    }
}

/* Desktop/tablet: show expand buttons, hide FAB */
@media (min-width: 769px) {
    .panel-toggle-btn {
        display: none !important;
    }
    .panel-expand-btn {
        display: inline-flex;
    }
}

/* ========================================================================
   iOS VIEWPORT FIX
   ======================================================================== */

@supports (height: 100dvh) {
    @media (max-width: 768px) {
        .chat-fullscreen {
            height: 100dvh;
        }
    }
}

/* ========================================================================
   ENHANCED PHONE BREAKPOINTS (480px portrait)
   ======================================================================== */

@media (max-width: 480px) {
    .chat-fullscreen-header {
        padding: 8px 12px;
        height: 48px;
    }

    .chat-fullscreen-logo,
    .chat-fullscreen-logo-large {
        height: 24px;
    }

    .chat-fullscreen-product {
        font-size: 0.9rem;
    }

    .chat-fullscreen-session {
        font-size: 0.7rem;
    }

    .chat-fullscreen-close {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .chat-log {
        padding: 12px;
    }

    .chat-msg {
        font-size: 13px;
        padding: 10px 12px;
        max-width: 95%;
    }

    .chat-form {
        padding: 8px 12px;
        gap: 8px;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: flex-end;
    }

    .chat-draw-toggle {
        width: 40px;
        height: 40px;
    }

    .chat-input-field {
        flex: 1;
        min-height: 40px;
        padding: 10px 12px;
        font-size: 16px;
    }

    .chat-submit-btn {
        padding: 10px 16px;
        font-size: 13px;
        width: auto;
        flex-shrink: 0;
    }

    .channel-tab {
        font-size: 12px;
        padding: 6px 10px;
        white-space: nowrap;
    }
}

/* Mind Map Canvas */
.mindmap-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.mindmap-svg {
    width: 100%;
    height: 100%;
    display: block;
    /* Simple background - grid dots are drawn in SVG so they move with pan/zoom */
    background-color: var(--bg);
    background-image: radial-gradient(ellipse at center, transparent 0%, rgba(0, 0, 0, 0.12) 100%);
}

/* Mind Map Toolbar */
.mindmap-toolbar {
    position: absolute;
    left: 16px;
    bottom: 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    z-index: 100;
}

.mindmap-toolbar .chip {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

/* Concept Chips in Messages */
.chip {
    display: inline;
    background: var(--chip-bg);
    color: var(--chip-text);
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}

/* Agent Badge */
.agent-badge {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 8px;
    background: var(--chip-bg);
    color: var(--chip-text);
    font-size: 0.7rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Mobile: Stack panels */
@media (max-width: 1024px) {
    .chat-fullscreen-body {
        flex-direction: column;
    }

    .chat-panel-left {
        width: 100%;
        height: 60%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .chat-panel-right {
        width: 100%;
        height: 40%;
    }
}

@media (max-width: 768px) {
    .chat-fullscreen-header {
        padding: 10px 16px;
        height: 56px;
    }

    .chat-fullscreen-logo {
        height: 28px;
    }

    .chat-fullscreen-title {
        font-size: 0.9rem;
    }

    .chat-log {
        padding: 16px;
    }

    .chat-form {
        padding: 12px 16px;
        flex-direction: column;
    }

    .chat-submit-btn {
        width: 100%;
    }

    .chat-msg {
        max-width: 90%;
    }
}

/* ================================
   Node Popover (Mind Map)
   ================================ */

.node-popover {
    position: absolute;
    right: 16px;
    top: 16px;
    width: min(360px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
    animation: popoverIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes popoverIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.node-popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.node-popover-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.node-popover-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1;
    transition: color 0.15s;
}

.node-popover-close:hover {
    color: var(--text);
}

.node-popover-body {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.node-popover-section {
    margin-bottom: 16px;
}

.node-popover-section:last-child {
    margin-bottom: 0;
}

.node-popover-section label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 8px;
}

.node-popover-buttons {
    display: flex;
    gap: 8px;
}

.node-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.node-btn:hover {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border-hover);
}

.node-btn.active.learning {
    background: rgba(255, 255, 255, 0.15);
    color: #a1a1aa;
    border-color: #a1a1aa;
}

.node-btn.active.mastered {
    background: rgba(255, 255, 255, 0.15);
    color: #a1a1aa;
    border-color: #a1a1aa;
}

.node-btn.danger {
    color: var(--error);
}

.node-btn.danger:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--error);
}

.node-btn.primary {
    background: var(--primary);
    color: var(--primary-fg);
    border-color: var(--primary);
}

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

/* Color Picker */
.node-color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.selected {
    border-color: white;
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor;
}

/* Ask Form */
.node-ask-form {
    display: flex;
    gap: 8px;
}

.node-ask-input {
    flex: 1;
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
}

.node-ask-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-muted);
}

.node-ask-input::placeholder {
    color: var(--text-muted);
}

/* Mind Map Node Styling */
.mindmap-node {
    transition: opacity 0.3s ease;
}

.mindmap-node:hover circle {
    filter: brightness(1.2);
    cursor: pointer;
}

.mindmap-node.dimmed {
    opacity: 0.25;
}

.mindmap-node.dragging {
    cursor: grabbing;
}

.mindmap-node.node-pulse circle {
    animation: nodePulse 2s ease-in-out infinite;
}

@keyframes nodePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ============================================
   NODE STATE SYSTEM
   4 states: new, learning, reviewing, mastered
   ============================================ */

/* NEW state - Subtle outer glow, waiting to be explored */
.mindmap-node.state-new circle {
    stroke: #a1a1aa !important;
    stroke-width: 2.5px !important;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.4));
    animation: nodeGlow 4s ease-in-out infinite;
}

@keyframes nodeGlow {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
    }
    50% {
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
    }
}

/* LEARNING state - Pulsing indicator, in progress */
.mindmap-node.state-learning circle {
    stroke: #a1a1aa !important;
    stroke-width: 3px !important;
    animation: nodePulse 3s ease-in-out infinite;
}

@keyframes nodePulse {
    0%, 100% {
        stroke-width: 3px;
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
    }
    50% {
        stroke-width: 4px;
        filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
    }
}

/* REVIEWING state - Red highlight, needs attention */
.mindmap-node.state-reviewing circle {
    stroke: #a1a1aa !important;
    stroke-width: 3px !important;
    animation: nodeReview 2s ease-in-out infinite;
}

@keyframes nodeReview {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.4));
        stroke-width: 3px;
    }
    50% {
        filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.6));
        stroke-width: 4px;
    }
}

/* MASTERED state - Strong green, stable appearance */
.mindmap-node.state-mastered circle {
    stroke: #a1a1aa !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.4));
}

/* State indicator badges (small text under node) */
.node-state-badge {
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
}

/* ============================================
   STATE FILTER CONTROLS
   ============================================ */

.mindmap-state-filters {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-right: 8px;
}

.state-filter-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.state-filter-btn:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.state-filter-btn.active {
    border-color: currentColor;
    color: var(--text);
}

.state-filter-btn.active[data-state="all"] {
    background: var(--primary);
    color: var(--primary-fg);
    border-color: var(--primary);
}

.state-filter-btn .state-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* State dots — match mindmap node stroke colors (getNodeStroke in
   mindmap-renderer.js) so the legend is consistent with the map. */
.state-filter-btn[data-state="new"] .state-dot {
    background: #93c5fd;  /* light blue — unseen */
}

.state-filter-btn[data-state="learning"] .state-dot {
    background: #fbbf24;  /* amber — in progress */
}

.state-filter-btn[data-state="reviewing"] .state-dot {
    background: #ef4444;  /* red — due for review */
    animation: dotPulse 1.5s ease-in-out infinite;
}

.state-filter-btn[data-state="mastered"] .state-dot {
    background: #22c55e;  /* green — mastered */
}

@keyframes dotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.2); }
}

.state-filter-btn .state-count {
    font-weight: 600;
    min-width: 14px;
    text-align: center;
}

/* Hidden nodes when filtered */
.mindmap-node.state-hidden {
    opacity: 0.1 !important;
    pointer-events: none;
}

/* ========================================
   CLUSTER STYLES
   ======================================== */

/* Collapsed cluster */
.cluster-collapsed {
    /* No transform transition - conflicts with JS translate */
}

.cluster-collapsed:hover circle {
    fill-opacity: 0.45;
    filter: brightness(1.15);
}

/* Expanded cluster boundary */
.cluster-boundary {
    transition: all 0.3s ease;
    pointer-events: none;
}

.cluster-boundary:hover {
    stroke-opacity: 0.6;
    fill-opacity: 0.12;
}

/* Venn diagram intersection zones */
.cluster-intersection {
    transition: fill-opacity 0.2s ease, stroke-opacity 0.2s ease;
    pointer-events: none;
}

.cluster-intersection:hover {
    fill-opacity: 0.35;
    stroke-opacity: 0.8;
}

.intersection-label {
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Cluster collapse button */
.cluster-collapse-btn {
    transition: transform 0.2s ease;
}

.cluster-collapse-btn:hover {
    transform: scale(1.2);
}

.cluster-collapse-btn:hover circle {
    fill-opacity: 0.5;
}

/* ========================================
   END CLUSTER STYLES
   ======================================== */

/* Organize by state - cluster nodes */
.mindmap-canvas.organized-by-state .mindmap-node {
    transition: transform 0.5s ease-out, opacity 0.3s ease;
}

/* State legend in corner - top right to avoid menu overlap */
.mindmap-state-legend {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 10px;
    opacity: 0.85;
    z-index: 10;
}

.mindmap-state-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.mindmap-state-legend .legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: transparent;
    border: 2px solid;
}

/* Legend dots — match mindmap node stroke colors (getNodeStroke in
   mindmap-renderer.js) so the legend is consistent with the map. */
.mindmap-state-legend .legend-dot.new {
    border-color: #93c5fd;
    background: #93c5fd;
}

.mindmap-state-legend .legend-dot.learning {
    border-color: #fbbf24;
    background: #fbbf24;
}

.mindmap-state-legend .legend-dot.reviewing {
    border-color: #ef4444;
    background: #ef4444;
    animation: dotPulse 1.5s ease-in-out infinite;
}

.mindmap-state-legend .legend-dot.mastered {
    border-color: #22c55e;
    background: #22c55e;
}

.mindmap-state-legend .legend-count {
    font-weight: 600;
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: auto;
}

.mindmap-link {
    transition: stroke 0.2s, opacity 0.2s, stroke-width 0.15s;
}

.mindmap-link.highlighted {
    stroke: var(--primary) !important;
    stroke-width: 3 !important;
    opacity: 1 !important;
}

/* Link labels: hidden by default, shown on hover */
.link-label {
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.link-label.link-label-visible {
    opacity: 1;
}

.link-hit-area {
    cursor: pointer;
}

/* Mind Map Popover */
.mindmap-popover {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 320px;
    max-height: 80vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

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

.popover-title {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.popover-state {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.popover-state.state-new {
    background: rgba(255, 255, 255, 0.2);
    color: #a1a1aa;
}

.popover-state.state-learning {
    background: rgba(255, 255, 255, 0.2);
    color: #a1a1aa;
}

.popover-state.state-reviewing {
    background: rgba(255, 255, 255, 0.2);
    color: #a1a1aa;
}

.popover-state.state-mastered {
    background: rgba(255, 255, 255, 0.2);
    color: #a1a1aa;
}

.popover-close {
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.popover-close:hover {
    background: var(--bg-elevated);
}

.popover-body {
    padding: 16px;
}

.popover-section {
    margin-bottom: 16px;
}

.popover-section:last-child {
    margin-bottom: 0;
}

.popover-section-title {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

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

.popover-btn {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.popover-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
}

.popover-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.popover-btn.mastered {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.popover-btn.learning {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.popover-colors {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.popover-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.popover-color-swatch:hover {
    transform: scale(1.15);
}

.popover-color-swatch.active {
    border-color: var(--primary-fg);
    box-shadow: 0 0 0 2px var(--primary);
}

.popover-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    margin-bottom: 10px;
}

.popover-input:focus {
    outline: none;
    border-color: var(--primary);
}

.popover-summary {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    max-height: 150px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.popover-info-text {
    font-size: 13px;
    color: var(--text-primary);
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.popover-connections {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.popover-connection-tag {
    font-size: 11px;
    padding: 4px 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.popover-status {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Radial Tree: Relationship display in popover */
.popover-relationship-box {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 4px;
}

.popover-rel-type {
    display: block;
    color: var(--primary);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.popover-rel-parent {
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
}

/* Rich relationship display in popover */
.popover-relationships {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.popover-rel-group {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 8px 10px;
}

.popover-rel-section-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.popover-rel-item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 2px 0;
}

.popover-rel-item .popover-rel-type {
    display: inline;
    margin-bottom: 0;
    font-size: 10px;
}

.popover-rel-item .popover-rel-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
}

.popover-rel-more {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
    padding-top: 2px;
}

/* Radial tree popover: compact action layout */
.radial-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 8px;
}

.radial-actions .popover-btn {
    flex: 1;
    min-width: 70px;
    text-align: center;
}

.popover-btn.primary {
    background: var(--primary);
    color: var(--primary-fg);
    border-color: var(--primary);
}

.popover-btn.danger {
    color: var(--error, #a1a1aa);
    border-color: var(--error, #a1a1aa);
    opacity: 0.7;
}

.popover-btn.danger:hover {
    background: var(--error, #a1a1aa);
    color: #fff;
    opacity: 1;
}

.popover-btn.quiz {
    color: var(--neon-emerald, #a1a1aa);
    border-color: rgba(255, 255, 255, 0.3);
}

.popover-btn.quiz:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--neon-emerald, #a1a1aa);
}

/* Node Quiz Panel */
.node-quiz-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 380px;
    max-width: 90%;
    max-height: 80%;
    background: var(--bg-elevated, #1e1f2e);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.node-quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.node-quiz-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.node-quiz-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    flex-shrink: 0;
}

.node-quiz-close:hover {
    color: var(--text);
}

.node-quiz-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.light-mode .node-quiz-panel {
    background: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* Popover Tributaries */
.popover-tributaries-section {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 4px;
}

.popover-tributaries {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.popover-trib-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.popover-trib-btn .trib-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.popover-trib-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.popover-trib-btn.explore:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #a1a1aa;
}

.popover-trib-btn.explore:hover .trib-label {
    color: #a1a1aa;
}

.popover-trib-btn.connect:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #a1a1aa;
}

.popover-trib-btn.connect:hover .trib-label {
    color: #a1a1aa;
}

.popover-trib-btn.apply:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #a1a1aa;
}

.popover-trib-btn.apply:hover .trib-label {
    color: #a1a1aa;
}

.popover-trib-btn:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

/* Toolbar buttons */
.mindmap-toolbar .toolbar-btn {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.mindmap-toolbar .toolbar-btn:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.mindmap-toolbar .toolbar-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.mindmap-info {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    padding: 8px 14px;
    /* SVG node filters (glow, radiant, cosmic) create new stacking contexts
       inside the mindmap canvas, which can paint over absolutely-positioned
       siblings without an explicit z-index. Pin the toolbar above the SVG. */
    z-index: 50;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mindmap-info .layout-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 12px;
    padding-right: 12px;
    border-right: 1px solid var(--border);
}

.mindmap-info .layout-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.mindmap-info .layout-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.mindmap-info .zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mindmap-info .zoom-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.mindmap-info .zoom-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

.mindmap-info #zoom-level {
    min-width: 48px;
    text-align: center;
    font-weight: 500;
}

.mindmap-info #zoom-reset {
    width: auto;
    padding: 0 12px;
    font-size: 11px;
}

/* Density control (focused/all toggle) */


/* View controls (2D/3D toggle) */
.mindmap-info .view-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.mindmap-info .view-btn {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.mindmap-info .view-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
    color: var(--text);
}

.mindmap-info .view-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-fg);
}

/* Mindmap toggle controls */
.mindmap-toggle-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 12px;
    padding-right: 12px;
    border-right: 1px solid var(--border);
}

.mindmap-toggle-controls .toggle-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* Toggle switch styling */
.mindmap-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.mindmap-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mindmap-toggle .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: 0.2s;
}

.mindmap-toggle .toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    border-radius: 50%;
    transition: 0.2s;
}

.mindmap-toggle input:checked + .toggle-slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

.mindmap-toggle input:checked + .toggle-slider:before {
    transform: translateX(16px);
    background-color: var(--primary-fg);
}

/* Light mode toggle */
:root.light-mode .mindmap-toggle .toggle-slider {
    background-color: #e5e7eb;
    border-color: #d1d5db;
}

:root.light-mode .mindmap-toggle .toggle-slider:before {
    background-color: #9ca3af;
}

:root.light-mode .mindmap-toggle input:checked + .toggle-slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* 3D container */
.mindmap-3d-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 56px; /* Leave room for controls */
    background: #1a1b26;
    border-radius: var(--radius-lg);
}

.mindmap-3d-container canvas {
    border-radius: var(--radius-lg);
}

/* 3D tooltip */
.graph3d-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--bg-secondary, #1e1f2e);
    border: 1px solid var(--border, #333);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    max-width: 220px;
    transition: opacity 0.15s;
}
.graph3d-tooltip-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary, #e2e8f0);
    line-height: 1.3;
}
.graph3d-tooltip-state {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.5px;
}
.graph3d-tooltip-state.state-mastered { color: #a1a1aa; }
.graph3d-tooltip-state.state-reviewing { color: #a1a1aa; }
.graph3d-tooltip-state.state-learning { color: #a1a1aa; }
.graph3d-tooltip-state.state-new { color: #a1a1aa; }

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Spinner */
.spinner {
    display: inline-flex;
}

.spinner-circle {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-small .spinner-circle {
    width: 16px;
    height: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.875rem;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.2s ease;
    max-width: 320px;
}

.toast-visible {
    transform: translateX(0);
    opacity: 1;
}

.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--error); }
.toast-warning { border-color: var(--warning); }

/* Auth Pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 380px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo {
    margin-bottom: 20px;
}

.auth-logo img {
    height: 40px;
}

.auth-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-divider span {
    padding: 0 12px;
}

.google-signin-container {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.google-signin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 24px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(8px);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

.google-signin-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.google-signin-btn:active {
    transform: translateY(0);
}

:root.light-mode .google-signin-btn {
    background: rgba(0, 0, 0, 0.02);
    border-color: var(--border);
    color: var(--text);
}

:root.light-mode .google-signin-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.2);
}

/* ── Neural Background & Glassmorphism ── */

.neural-bg {
    position: relative;
    overflow: hidden;
}

#neural-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.neural-bg .auth-container,
.neural-bg .onboarding-container {
    position: relative;
    z-index: 1;
}

.glass-card {
    background: rgba(19, 20, 26, 0.8) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 16px !important;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 80px rgba(255, 255, 255, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Enhanced Google button — primary CTA */
.google-signin-btn--primary {
    padding: 14px 24px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.google-signin-btn--primary:hover {
    background: rgba(255, 255, 255, 0.09) !important;
    border-color: rgba(255, 255, 255, 0.35) !important;
    box-shadow: 0 0 24px rgba(255, 255, 255, 0.12) !important;
    transform: translateY(-1px);
}

/* Neural-themed form inputs */
.neural-bg .form-input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.neural-bg .form-input:focus {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 16px rgba(255, 255, 255, 0.08);
    outline: none;
}

/* Form entrance animations */
@keyframes neuralSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes neuralSlideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.neural-bg .auth-header {
    animation: neuralSlideUp 0.5s ease backwards;
}

.neural-bg .google-signin-container {
    animation: neuralSlideUp 0.5s ease 0.1s backwards;
}

.neural-bg .auth-divider {
    animation: neuralSlideUp 0.4s ease 0.15s backwards;
}

.neural-bg #login-form .form-group:nth-child(1) {
    animation: neuralSlideUp 0.4s ease 0.2s backwards;
}

.neural-bg #login-form .form-group:nth-child(2) {
    animation: neuralSlideUp 0.4s ease 0.25s backwards;
}

.neural-bg #login-form button[type="submit"] {
    animation: neuralSlideUp 0.4s ease 0.3s backwards;
}

.neural-bg .auth-footer {
    animation: neuralSlideUp 0.4s ease 0.35s backwards;
}

.neural-bg #mfa-section {
    animation: neuralSlideDown 0.3s ease forwards;
}

/* Neural auth title glow */
.neural-bg .auth-title,
.neural-bg .step-title {
    background: linear-gradient(135deg, #ffffff 0%, #c7d2fe 50%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Neural Light Mode Overrides ── */

:root.light-mode .glass-card {
    background: rgba(255, 255, 255, 0.85) !important;
    border: 1px solid rgba(99, 102, 241, 0.15) !important;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.08),
        0 0 80px rgba(99, 102, 241, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

:root.light-mode .google-signin-btn--primary {
    background: rgba(0, 0, 0, 0.02) !important;
    border: 1px solid var(--border) !important;
}

:root.light-mode .google-signin-btn--primary:hover {
    background: rgba(99, 102, 241, 0.06) !important;
    border-color: rgba(99, 102, 241, 0.3) !important;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.08) !important;
}

:root.light-mode .neural-bg .form-input {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border);
    color: var(--text);
}

:root.light-mode .neural-bg .form-input:focus {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.1);
}

:root.light-mode .neural-bg .auth-title,
:root.light-mode .neural-bg .step-title {
    background: linear-gradient(135deg, #312e81 0%, #6366f1 50%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

:root.light-mode .neural-bg .auth-subtitle,
:root.light-mode .neural-bg .step-subtitle {
    color: var(--text-secondary);
}

:root.light-mode .neural-bg .auth-divider span {
    color: var(--text-muted);
}

/* ── End Neural Styles ── */

.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--success);
    margin-bottom: 16px;
}

/* ==================== */
/* MFA SETUP            */
/* ==================== */

.mfa-setup {
    text-align: left;
}

.mfa-header {
    text-align: center;
    margin-bottom: 32px;
}

.mfa-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: var(--primary-muted);
    border-radius: 50%;
    color: var(--primary);
    margin-bottom: 16px;
}

.mfa-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.mfa-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.mfa-steps {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 24px;
}

.mfa-step {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.step-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--primary-fg);
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 50%;
}

.step-content {
    flex: 1;
    min-width: 0;
}

.step-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.step-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.step-content .warning-text {
    color: var(--warning);
    font-weight: 500;
}

.qr-container {
    display: flex;
    justify-content: center;
    padding: 16px;
    background: white;
    border-radius: var(--radius);
    width: fit-content;
    margin: 0 auto;
}

.qr-container img,
.qr-container canvas {
    display: block;
    width: 200px;
    height: 200px;
}

.secret-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    font-family: 'Fira Code', 'Monaco', monospace;
}

.secret-display code {
    flex: 1;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    color: var(--text);
    word-break: break-all;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius);
    transition: background 0.2s, color 0.2s;
}

.btn-icon:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.backup-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.backup-code {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    font-family: 'Fira Code', 'Monaco', monospace;
    font-size: 0.85rem;
    text-align: center;
    color: var(--text);
}

.backup-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.backup-actions .btn {
    flex: 1;
    min-width: 120px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.verify-input-container {
    max-width: 200px;
}

.mfa-code-input {
    font-family: 'Fira Code', 'Monaco', monospace;
    font-size: 1.5rem !important;
    letter-spacing: 0.3em;
    text-align: center;
    padding: 16px !important;
}

.mfa-confirm {
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text);
}

.checkbox-label input[type="checkbox"] {
    margin-top: 2px;
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-full {
    width: 100%;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* MFA responsive */
@media (max-width: 480px) {
    .mfa-step {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .step-content {
        width: 100%;
    }

    .backup-codes {
        grid-template-columns: 1fr;
    }

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

    .backup-actions .btn {
        width: 100%;
    }

    .secret-display {
        flex-direction: column;
        text-align: center;
    }
}

/* ==================== */
/* MOBILE RESPONSIVE    */
/* ==================== */

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .dashboard {
        padding: 16px;
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .header {
        padding: 14px 16px;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .header-left {
        justify-content: space-between;
    }

    .header-logo {
        height: 28px;
    }

    .flex.gap-4 {
        width: 100%;
        display: flex;
    }

    .flex.gap-4 .btn {
        flex: 1;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .card {
        padding: 16px;
    }

    /* Modal full screen on mobile */
    .modal-overlay {
        padding: 0;
    }

    .modal {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chat-container {
        height: calc(100vh - 140px);
    }

    .chat-input-container {
        flex-direction: column;
    }

    .chat-send-btn {
        width: 100%;
    }

    /* Auth pages */
    .auth-container {
        max-width: 100%;
    }

    .auth-card {
        padding: 24px 20px;
        border-radius: var(--radius);
    }

    .auth-logo img {
        height: 36px;
    }

    .auth-title {
        font-size: 1.15rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .dashboard {
        padding: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .btn {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .form-input {
        padding: 12px;
    }

    #toast-container {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .toast {
        max-width: 100%;
    }

    /* Auth pages - very small screens */
    .auth-page {
        padding: 16px 12px;
    }

    .auth-card {
        padding: 20px 16px;
    }

    .auth-logo img {
        height: 32px;
    }

    .auth-title {
        font-size: 1.1rem;
    }

    .auth-subtitle {
        font-size: 0.85rem;
    }

    .form-input {
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* ==================== */
/* ONBOARDING WIZARD    */
/* ==================== */

.onboarding-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.onboarding-container {
    width: 100%;
    max-width: 600px;
}

/* Progress Bar */
.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Wizard Steps */
.wizard-step {
    display: none;
    animation: fadeIn 0.3s ease;
}

.wizard-step.active {
    display: block;
}

/* Override glass-card on onboarding wizard — open, borderless floating form */
.onboarding-page .wizard-step.glass-card {
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0;
}

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

.step-header {
    text-align: center;
    margin-bottom: 32px;
}

.step-logo {
    margin-bottom: 20px;
}

.step-logo img {
    height: 48px;
}

.step-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.step-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.step-content {
    margin-bottom: 32px;
}

.step-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.step-buttons .btn {
    min-width: 120px;
}

.btn-full {
    width: 100%;
}

/* Welcome Features */
.welcome-features {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 400px;
    margin: 0 auto;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.feature-icon {
    color: var(--primary);
    flex-shrink: 0;
}

.feature-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.feature-text strong {
    color: var(--text);
    font-weight: 500;
}

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

/* Choice Cards Grid */
.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.choice-grid.three-col {
    grid-template-columns: repeat(3, 1fr);
}

.choice-card {
    padding: 20px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.choice-card:hover {
    border-color: var(--text-muted);
}

.choice-card.selected {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

.choice-icon {
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
}

.choice-card.selected .choice-icon {
    color: var(--primary);
}

.choice-label {
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.choice-desc {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.4;
}

/* Choice Cards List (Horizontal) */
.choice-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.choice-card-horizontal {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.15s ease;
}

.choice-card-horizontal:hover {
    border-color: var(--text-muted);
}

.choice-card-horizontal.selected {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
}

.choice-card-horizontal .choice-icon {
    color: var(--text-muted);
    margin-bottom: 0;
    flex-shrink: 0;
}

.choice-card-horizontal.selected .choice-icon {
    color: var(--primary);
}

.choice-card-horizontal .choice-text {
    flex: 1;
}

.choice-card-horizontal .choice-label {
    margin-bottom: 2px;
}

/* Curriculum Tree Browser */
.curr-item:hover {
    background: var(--bg-hover);
    border-radius: 4px;
}
.curr-subtopic {
    transition: background 0.15s;
}
.curr-subtopic:hover {
    background: var(--bg-hover) !important;
}
.curr-selected {
    font-weight: 600;
}
#curriculum-tree-container::-webkit-scrollbar {
    width: 6px;
}
#curriculum-tree-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Form Row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Verification Input */
.verification-input {
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 0.5em;
    padding: 16px;
}

/* Onboarding Mobile Responsive */
@media (max-width: 768px) {
    .onboarding-container {
        max-width: 100%;
    }

    .step-title {
        font-size: 1.25rem;
    }

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

    .choice-grid.three-col {
        grid-template-columns: 1fr;
    }

    .choice-card {
        padding: 16px 12px;
    }

    .step-buttons {
        flex-direction: column;
    }

    .step-buttons .btn {
        width: 100%;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .choice-grid {
        grid-template-columns: 1fr;
    }

    .verification-input {
        font-size: 1.5rem;
        letter-spacing: 0.3em;
    }
}

/* ================================
   Knowledge Graph Visualization
   ================================ */

/* Graph Panel Container */
.graph-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.graph-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

.graph-title h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
}

.graph-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: 8px;
}

.graph-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.graph-controls .btn-sm {
    padding: 6px 10px;
    font-size: 0.75rem;
}

.graph-layout-select {
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.75rem;
    cursor: pointer;
}

.graph-layout-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Graph Container */
.graph-container {
    position: relative;
    flex: 1;
    min-height: 400px;
    background: var(--bg);
    overflow: hidden;
}

/* SVG Styles */
.knowledge-graph {
    display: block;
    width: 100%;
    height: 100%;
}

.knowledge-graph .node {
    cursor: pointer;
}

.knowledge-graph .node circle {
    transition: filter 0.2s ease, stroke 0.2s ease;
}

.knowledge-graph .node:hover circle {
    stroke-width: 3;
}

.knowledge-graph .edge {
    transition: opacity 0.2s ease;
}

.knowledge-graph .edge-label {
    pointer-events: none;
}

/* Node Details Panel */
.graph-details {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.graph-details-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.graph-details-close:hover {
    color: var(--text);
}

.graph-details h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    padding-right: 24px;
    color: var(--text);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
}

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

.detail-value {
    font-size: 0.8rem;
    color: var(--text);
    font-weight: 500;
}

/* Graph Modal Integration */
.graph-modal {
    max-width: 900px;
}

.graph-modal .modal-body {
    padding: 0;
}

.graph-modal .graph-container {
    height: 500px;
}

/* Chat Toolbar */
.chat-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}

/* Graph Button in Chat */
.chat-graph-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-graph-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.chat-graph-btn svg {
    width: 16px;
    height: 16px;
}

/* Loading State */
.graph-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
}

.graph-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Empty State */
.graph-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
}

.graph-empty-icon {
    margin-bottom: 12px;
    color: var(--border);
}

.graph-empty-icon svg {
    width: 48px;
    height: 48px;
}

.graph-empty p {
    font-size: 0.9rem;
}

/* Topic Input */
.graph-topic-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

.graph-topic-input input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
}

.graph-topic-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.graph-topic-input input::placeholder {
    color: var(--text-muted);
}

/* Graph Responsive */
@media (max-width: 768px) {
    .graph-panel-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .graph-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .graph-container {
        min-height: 300px;
    }

    .graph-details {
        width: calc(100% - 32px);
        left: 16px;
        right: 16px;
    }

    .graph-modal .graph-container {
        height: 400px;
    }
}

@media (max-width: 480px) {
    .graph-controls .btn-sm {
        padding: 4px 8px;
    }

    .graph-layout-select {
        padding: 4px 8px;
    }
}

/* ================================
   Theme Toggle
   ================================ */

.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-muted);
}

.theme-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* Sun icon hidden in dark mode, shown in light mode */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

:root.light-mode .theme-toggle .icon-sun { display: block; }
:root.light-mode .theme-toggle .icon-moon { display: none; }

/* ================================
   Rich Content Rendering
   ================================ */

/* Code Blocks */
.code-block {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 12px 0;
    overflow: hidden;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border);
}

.code-block-lang {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 500;
}

.code-block-copy {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.code-block-copy:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.code-block pre {
    margin: 0;
    padding: 12px;
    overflow-x: auto;
}

.code-block code {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.85rem;
    color: var(--code-text);
    line-height: 1.5;
}

/* Inline Code */
code:not(.code-block code) {
    background: var(--code-bg);
    color: var(--primary-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.85em;
}

/* Math Equations (KaTeX) */
.math-display {
    display: block;
    margin: 16px 0;
    padding: 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    overflow-x: auto;
    text-align: center;
}

.math-display .katex-display {
    margin: 0;
}

.math-inline {
    display: inline;
    padding: 0 2px;
}

.math-inline .katex {
    white-space: normal;
    word-wrap: break-word;
}

.math-error {
    color: var(--error);
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* KaTeX color overrides for dark theme */
.katex {
    color: var(--text);
}

.light-mode .katex {
    color: var(--text);
}

/* Tables */
.content-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.9rem;
    overflow-x: auto;
    display: block;
}

.content-table thead {
    background: var(--table-header);
}

.content-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.content-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.content-table tbody tr:nth-child(even) {
    background: var(--table-row-alt);
}

.content-table tbody tr:hover {
    background: var(--primary-muted);
}

/* Concept Chips - Subtle styling for inline concepts */
.concept-chip {
    display: inline;
    color: var(--primary);
    font-weight: 500;
    border-bottom: 1px dotted var(--primary);
    /* No background or pill styling - keep inline with prose */
}

/* Prevent nested concept chips */
.concept-chip .concept-chip {
    border-bottom: none;
    font-weight: inherit;
}

/* Content Lists - Ordered and Unordered using CSS Counters */
.content-list {
    margin: 12px 0;
    padding-left: 0 !important;
    display: block;
}

ol.content-list {
    counter-reset: list-counter;
    list-style: none !important;
}

ol.content-list > li {
    counter-increment: list-counter;
    position: relative;
    padding-left: 32px;
    margin-bottom: 8px;
    line-height: 1.6;
}

ol.content-list > li::before {
    content: counter(list-counter) ".";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 600;
    min-width: 24px;
}

ul.content-list {
    list-style: none !important;
    padding-left: 0 !important;
}

ul.content-list > li {
    position: relative;
    padding-left: 32px;
    margin-bottom: 8px;
    line-height: 1.6;
}

ul.content-list > li::before {
    content: "•";
    position: absolute;
    left: 12px;
    color: var(--primary);
    font-weight: bold;
}

.content-list li:last-child {
    margin-bottom: 0;
}

/* Ensure numbered lists inside messages work - CSS Counters */
/* Reset counter at message level so multiple ol's continue numbering */
.chat-msg .msg-content {
    counter-reset: msg-list-counter;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

/* Hide empty KaTeX SVG remnants that break layout (only those directly in msg-content, not inside diagram containers) */
.chat-msg .msg-content > svg:empty {
    display: none !important;
}

.chat-msg ol,
.msg-content ol {
    list-style: none !important;
    padding-left: 0 !important;
    margin: 12px 0;
}

.chat-msg ol > li,
.msg-content ol > li {
    counter-increment: msg-list-counter;
    position: relative;
    padding-left: 32px;
    margin-bottom: 8px;
    line-height: 1.6;
}

.chat-msg ol > li::before,
.msg-content ol > li::before {
    content: counter(msg-list-counter) ".";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 600;
    min-width: 24px;
}

.chat-msg ul,
.msg-content ul {
    list-style: none !important;
    padding-left: 0 !important;
    margin: 12px 0;
}

.chat-msg ul li,
.msg-content ul li {
    display: list-item !important;
    margin-bottom: 8px;
}

/* Content Timeline */
.content-timeline {
    position: relative;
    padding: 20px 0;
    margin: 16px 0;
}

.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-muted) 100%);
    transform: translateX(-50%);
}

.timeline-entry {
    position: relative;
    width: 45%;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.timeline-entry.left {
    margin-right: auto;
    text-align: right;
    padding-right: 30px;
}

.timeline-entry.right {
    margin-left: auto;
    text-align: left;
    padding-left: 30px;
}

.timeline-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border: 2px solid var(--bg);
    border-radius: 50%;
    top: 16px;
    box-shadow: 0 0 0 3px var(--primary-muted);
}

.timeline-entry.left .timeline-dot {
    right: -6px;
}

.timeline-entry.right .timeline-dot {
    left: -6px;
}

.timeline-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.timeline-content:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.timeline-date {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.timeline-event {
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
}

/* Timeline responsive */
@media (max-width: 768px) {
    .timeline-line {
        left: 20px;
    }

    .timeline-entry {
        width: calc(100% - 40px);
        margin-left: 40px !important;
        text-align: left !important;
        padding-left: 20px !important;
        padding-right: 0 !important;
    }

    .timeline-entry.left .timeline-dot,
    .timeline-entry.right .timeline-dot {
        left: -26px;
        right: auto;
    }
}

/* Message content paragraphs */
.chat-msg p {
    margin: 0 0 12px 0;
    color: inherit;
}

.chat-msg p:last-child {
    margin-bottom: 0;
}

/* Ensure consistent text color in assistant messages */
.chat-msg.assistant,
.chat-msg.assistant p,
.chat-msg.assistant li,
.chat-msg.assistant td {
    color: var(--text);
}

/* Content Headers */
.chat-msg h1,
.chat-msg h2,
.chat-msg h3 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    color: var(--text);
}

.chat-msg h1 {
    font-size: 1.4em;
}

.chat-msg h2 {
    font-size: 1.2em;
}

.chat-msg h3 {
    font-size: 1.1em;
}

.chat-msg h1:first-child,
.chat-msg h2:first-child,
.chat-msg h3:first-child {
    margin-top: 0;
}

/* ================================
   Conversation Search
   ================================ */

.chat-search {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-search input {
    width: 140px;
    padding: 5px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.8rem;
}

.chat-search input:focus {
    outline: none;
    border-color: var(--primary);
    width: 200px;
}

.chat-search input::placeholder {
    color: var(--text-muted);
}

.chat-search-btn {
    padding: 5px 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.75rem;
}

.chat-search-btn:hover {
    color: var(--primary);
}

.search-highlight {
    background: var(--search-highlight);
    padding: 1px 2px;
    border-radius: 2px;
}

.chat-message.search-dimmed {
    opacity: 0.3;
    filter: blur(1px);
}

.search-match-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ================================
   Session History
   ================================ */

.session-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.session-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.session-panel-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.session-list {
    max-height: 600px;
    overflow-y: auto;
}

.session-item {
    display: flex;
    align-items: flex-start;
    padding: 16px 20px;
    margin: 8px 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.session-item:hover {
    background: var(--bg-elevated);
    border-color: rgba(255, 255, 255, 0.1);
}

.session-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.session-item-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.session-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.session-item-date {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.session-item-summary {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.session-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.session-item-stats {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.session-stat-pill {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
}

.session-stat-pill.review-due {
    color: #a1a1aa;
    background: rgba(255, 255, 255, 0.1);
    font-weight: 500;
}

.light-mode .session-stat-pill.review-due {
    color: #a1a1aa;
    background: rgba(255, 255, 255, 0.08);
}

.session-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.session-item:hover .session-item-actions {
    opacity: 1;
}

.session-action-btn {
    padding: 4px 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.session-action-btn:hover {
    border-color: var(--border);
    color: var(--text);
    background: var(--bg-secondary);
}

.session-action-btn.danger:hover {
    border-color: var(--error);
    color: var(--error);
}

.session-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.session-item.archived {
    opacity: 0.6;
}

.session-item.archived .session-item-title::after {
    content: 'Archived';
    font-size: 0.65rem;
    padding: 2px 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    margin-left: 8px;
    color: var(--text-muted);
}

/* Light mode session cards */
.light-mode .session-item:hover {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.1);
}

.light-mode .session-stat-pill {
    background: rgba(0, 0, 0, 0.04);
}

.session-panel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.session-search {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
}

.session-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 14px;
}

.session-search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.session-search-input::placeholder {
    color: var(--text-muted);
}

.session-pagination {
    padding: 12px 20px;
    text-align: center;
    border-top: 1px solid var(--border);
}

/* Select mode */
.session-select-bar {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}

.session-select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.session-select-all-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.session-item-checkbox {
    display: flex;
    align-items: center;
    padding: 0 4px 0 0;
    flex-shrink: 0;
    cursor: pointer;
}

.session-item-checkbox input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.session-item.selected {
    background: rgba(255, 255, 255, 0.08);
}

.select-mode .session-item {
    cursor: pointer;
}

#select-toggle-btn.active {
    color: var(--accent);
    border-color: var(--accent);
}

.batch-delete-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--error) !important;
    border-color: var(--error) !important;
}

.batch-delete-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* Plan header in dropdown */
.dropdown-plan-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.dropdown-plan-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.dropdown-plan-tag {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: var(--radius);
    background: var(--accent);
    color: white;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.usage-compact-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.usage-compact-text .usage-compact-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Session action buttons with icons */
.session-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    min-width: 28px;
    min-height: 28px;
}

.session-action-btn svg {
    width: 14px;
    height: 14px;
}

/* ================================
   Export Menu
   ================================ */

.export-menu {
    position: relative;
}

.export-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 160px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10001;
    display: none;
}

.export-dropdown.active {
    display: block;
}

.export-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.export-dropdown-item:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.export-dropdown-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.export-badge {
    margin-left: auto;
    padding: 2px 6px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--primary);
    color: var(--primary-fg);
    border-radius: 4px;
}

.export-separator {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.export-upgrade-prompt {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    min-width: 220px;
}

.export-upgrade-prompt svg {
    width: 24px;
    height: 24px;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.export-upgrade-prompt strong {
    display: block;
    color: var(--text);
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.export-upgrade-prompt p {
    font-size: 0.8rem;
    margin-bottom: 12px;
    line-height: 1.4;
}

.export-upgrade-link {
    display: inline-block;
    padding: 6px 16px;
    background: var(--primary);
    color: var(--primary-fg);
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.export-upgrade-link:hover {
    opacity: 0.9;
}

/* ================================
   Enhanced Chat Messages
   ================================ */

.chat-message-user {
    background: var(--msg-user-bg);
    border-left: 3px solid var(--primary);
}

.chat-message-assistant {
    background: var(--msg-assistant-bg);
}

.chat-message-content {
    line-height: 1.6;
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
}

.chat-message-content .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    padding: 8px 0;
}

.chat-message-content .katex {
    max-width: 100%;
}

.chat-message-content p {
    margin-bottom: 8px;
    color: var(--text);
}

.chat-message-content p:last-child {
    margin-bottom: 0;
}

.chat-message-content ul,
.chat-message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.chat-message-content li {
    margin-bottom: 4px;
    color: var(--text-secondary);
}

/* ================================
   Dashboard Stats Enhancement
   ================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

/* Bottom accent line -- always visible, different color per card */
.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, var(--neon-indigo), transparent);
    opacity: 0.6;
    animation: accentPulse 3s ease-in-out infinite;
}

/* Color each stat card accent differently */
.stats-grid:not(.stats-grid-secondary) .stat-card:nth-child(1)::after {
    background: linear-gradient(90deg, transparent, var(--neon-indigo), transparent);
    box-shadow: 0 0 6px var(--neon-indigo-glow);
    animation-delay: 0s;
}

.stats-grid:not(.stats-grid-secondary) .stat-card:nth-child(2)::after {
    background: linear-gradient(90deg, transparent, #a1a1aa, transparent);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
    animation-delay: 0.75s;
}

.stats-grid:not(.stats-grid-secondary) .stat-card:nth-child(3)::after {
    background: linear-gradient(90deg, transparent, var(--neon-amber), transparent);
    box-shadow: 0 0 6px var(--neon-amber-glow);
    animation-delay: 1.5s;
}

.stats-grid:not(.stats-grid-secondary) .stat-card:nth-child(4)::after {
    background: linear-gradient(90deg, transparent, var(--neon-emerald), transparent);
    box-shadow: 0 0 6px var(--neon-emerald-glow);
    animation-delay: 2.25s;
}

@keyframes accentPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-value {
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--neon-indigo);
    margin-bottom: 4px;
}

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

/* Stats responsive */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ================================
   Theme Transition
   ================================ */

*, *::before, *::after {
    transition: background-color 0.2s ease,
                border-color 0.2s ease,
                color 0.2s ease;
}

/* ================================
   Utility Classes
   ================================ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 12px; }

/* ================================
   Streaming Messages
   ================================ */

.chat-message-streaming {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--primary);
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* WebSocket connection status */
.ws-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: var(--radius);
    background: var(--bg-elevated);
}

.ws-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.ws-status.connected .ws-status-dot {
    background: var(--success);
}

.ws-status.disconnected .ws-status-dot {
    background: var(--error);
}

.ws-status.connecting .ws-status-dot {
    background: var(--warning);
    animation: pulse 1s ease-in-out infinite;
}

/* ===== TRIBUTARIES - Follow-up Learning Paths ===== */
.ifl-tributaries {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    opacity: 0;
    transform: translateY(10px);
    animation: tributaryAppear 0.5s ease forwards;
    animation-delay: 0.3s;
}

@keyframes tributaryAppear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ifl-tributary-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 10px;
    width: 100%;
}

.ifl-tributary {
    flex: 1 1 0 !important;
    min-width: 0;
    max-width: 33.33%;
    padding: 14px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 70px;
    display: block;
}

/* Single-item rows (quiz, feynman) take full width */
.ifl-tributary-row .ifl-tributary:only-child {
    max-width: 100%;
    flex: 1 1 100%;
}

.ifl-tributary:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-2px);
}

/* Tributary accent colors — semantic coding per follow-up type.
   Kept colored even in B&W themes because these cards communicate
   different action types (explore depth vs breadth vs application). */
.ifl-tributary.deeper    { border-left: 3px solid #3b82f6; }  /* blue — depth */
.ifl-tributary.wider     { border-left: 3px solid #8b5cf6; }  /* purple — breadth */
.ifl-tributary.practical { border-left: 3px solid #10b981; }  /* green — apply */
.ifl-tributary.quiz      { border-left: 3px solid #f59e0b; }  /* amber — test */
.ifl-tributary.feynman   { border-left: 3px solid #ec4899; }  /* pink — teach back */

.ifl-tributary.deeper:hover    { box-shadow: 0 4px 20px rgba(59, 130, 246, 0.25); }
.ifl-tributary.wider:hover     { box-shadow: 0 4px 20px rgba(139, 92, 246, 0.25); }
.ifl-tributary.practical:hover { box-shadow: 0 4px 20px rgba(16, 185, 129, 0.25); }
.ifl-tributary.quiz:hover      { box-shadow: 0 4px 20px rgba(245, 158, 11, 0.25); }
.ifl-tributary.feynman:hover   { box-shadow: 0 4px 20px rgba(236, 72, 153, 0.25); }

.ifl-trib-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.ifl-tributary.deeper    .ifl-trib-label { color: #3b82f6; }
.ifl-tributary.wider     .ifl-trib-label { color: #8b5cf6; }
.ifl-tributary.practical .ifl-trib-label { color: #10b981; }
.ifl-tributary.quiz      .ifl-trib-label { color: #f59e0b; }
.ifl-tributary.feynman   .ifl-trib-label { color: #ec4899; }

.ifl-trib-text {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Depth indicator bar */
.ifl-depth-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-secondary, rgba(255,255,255,0.03));
    border: 1px solid var(--border);
}

.ifl-depth-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    line-height: 1;
}

.ifl-depth-arrow:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: var(--primary);
    background: var(--bg-hover);
}

.ifl-depth-arrow:disabled {
    opacity: 0.3;
    cursor: default;
}

.ifl-depth-track {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

/* Connecting line behind dots */
.ifl-depth-track::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 12px;
    right: 12px;
    height: 2px;
    background: var(--border);
    transform: translateY(-4px);
    z-index: 0;
}

.ifl-depth-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    z-index: 1;
    transition: all 0.15s ease;
}

.ifl-depth-dot-marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-primary, #1a1a2e);
    transition: all 0.2s ease;
}

.ifl-depth-dot.past .ifl-depth-dot-marker {
    background: var(--primary);
    border-color: var(--primary);
    width: 8px;
    height: 8px;
}

.ifl-depth-dot.active .ifl-depth-dot-marker {
    background: var(--primary);
    border-color: var(--primary);
    width: 14px;
    height: 14px;
    box-shadow: 0 0 8px rgba(var(--primary-rgb, 99,102,241), 0.4);
}

.ifl-depth-dot-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    white-space: nowrap;
    transition: color 0.15s ease;
    max-width: 60px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ifl-depth-dot.active .ifl-depth-dot-label {
    color: var(--primary);
}

.ifl-depth-dot:hover .ifl-depth-dot-label {
    color: var(--text-primary);
}

/* Mobile: hide labels except active */
@media (max-width: 480px) {
    .ifl-depth-dot-label {
        display: none;
    }
    .ifl-depth-dot.active .ifl-depth-dot-label {
        display: block;
    }
}

/* New Session Modal — input field */
.new-session-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}

.new-session-input:focus {
    border-color: var(--primary);
}

/* Flowing thinking indicator */
.ifl-thinking {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
}

.ifl-thinking-flow {
    width: 100px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.ifl-thinking-flow::before {
    content: '';
    position: absolute;
    top: 0;
    left: -50px;
    width: 50px;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: flowThink 1.2s ease-in-out infinite;
}

@keyframes flowThink {
    0% { left: -50px; }
    100% { left: 100px; }
}

.ifl-thinking-text {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}

/* Quiz Container */
.ifl-quiz-container {
    margin-top: 16px;
    padding: 20px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    animation: tributaryAppear 0.3s ease forwards;
}

.ifl-quiz-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    justify-content: center;
}

.ifl-quiz-loading span {
    color: var(--text-muted);
    font-style: italic;
}

.ifl-quiz-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.ifl-quiz-score {
    font-weight: 600;
    color: var(--success);
}

.ifl-quiz-question {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--text);
    line-height: 1.5;
}

.ifl-quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ifl-quiz-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    color: var(--text-secondary);
}

.ifl-quiz-option:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
    border-color: var(--border-hover);
}

.ifl-quiz-option:disabled {
    cursor: default;
}

.ifl-quiz-option.correct {
    background: rgba(255, 255, 255, 0.2);
    border-color: #a1a1aa;
}

.ifl-quiz-option.incorrect {
    background: rgba(255, 255, 255, 0.2);
    border-color: #a1a1aa;
}

.ifl-quiz-option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.ifl-quiz-option.correct .ifl-quiz-option-letter {
    background: var(--primary);
    color: var(--primary-fg);
}

.ifl-quiz-option.incorrect .ifl-quiz-option-letter {
    background: var(--primary);
    color: var(--primary-fg);
}

/* Short answer quiz styles */
.ifl-quiz-short-answer {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ifl-quiz-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}

.ifl-quiz-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.ifl-quiz-textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ifl-quiz-submit-answer {
    align-self: flex-start;
    padding: 10px 20px;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: var(--primary-fg);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ifl-quiz-submit-answer:hover:not(:disabled) {
    background: var(--primary-hover);
}

.ifl-quiz-submit-answer:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ifl-feedback-info {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
}

.ifl-quiz-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.ifl-quiz-nav button {
    padding: 10px 20px;
    background: var(--primary-muted);
    border: 1px solid var(--primary);
    border-radius: 8px;
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.ifl-quiz-nav button:hover:not(:disabled) {
    background: var(--primary);
    color: var(--primary-fg);
}

.ifl-quiz-nav button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ifl-quiz-results {
    text-align: center;
    padding: 30px 20px;
}

.ifl-quiz-results-score {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
}

.ifl-quiz-results-percent {
    font-size: 24px;
    color: var(--success);
    margin-bottom: 12px;
}

.ifl-quiz-results-message {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.ifl-quiz-results button {
    padding: 12px 24px;
    margin: 0 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.ifl-quiz-retry {
    background: var(--primary);
    border: none;
    color: var(--primary-fg);
}

.ifl-quiz-close {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

/* Feynman Modal */
.ifl-feynman-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ifl-feynman-content {
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

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

.ifl-feynman-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.ifl-feynman-header h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text);
}

.ifl-feynman-close {
    width: 32px;
    height: 32px;
    background: var(--bg-elevated);
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ifl-feynman-close:hover {
    background: var(--bg-tertiary);
    color: var(--text);
}

.ifl-feynman-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.ifl-feynman-prompt {
    font-size: 16px;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 12px;
}

.ifl-feynman-prompt strong {
    color: #a1a1aa;
}

.ifl-feynman-tip {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg-elevated);
    border-radius: 8px;
}

.ifl-feynman-input {
    width: 100%;
    min-height: 150px;
    padding: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
}

.ifl-feynman-input:focus {
    outline: none;
    border-color: #a1a1aa;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2);
}

.ifl-feynman-input::placeholder {
    color: var(--text-muted);
}

.ifl-feynman-counter {
    text-align: right;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
    margin-bottom: 16px;
}

.ifl-feynman-submit {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #a1a1aa, #a1a1aa);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ifl-feynman-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.4);
}

.ifl-feynman-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ifl-feynman-result {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.ifl-feynman-score {
    text-align: center;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.ifl-feynman-score-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text);
}

.ifl-feynman-score-message {
    color: var(--text-muted);
    margin-top: 8px;
}

.ifl-feynman-section {
    margin-bottom: 20px;
}

.ifl-feynman-section h4 {
    font-size: 14px;
    margin-bottom: 12px;
    color: var(--text);
}

.ifl-feynman-section.strengths h4 { color: #a1a1aa; }
.ifl-feynman-section.gaps h4 { color: #a1a1aa; }
.ifl-feynman-section.suggestions h4 { color: #a1a1aa; }

.ifl-feynman-section ul {
    margin: 0;
    padding-left: 20px;
}

.ifl-feynman-section li {
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.5;
}

.ifl-feynman-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.ifl-feynman-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
}

.ifl-feynman-retry {
    background: linear-gradient(135deg, #a1a1aa, #a1a1aa);
    border: none;
    color: white;
}

.ifl-feynman-close-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

/* Feynman Results */
.ifl-feynman-results {
    padding: 0;
}

.ifl-feynman-grade {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
}

.ifl-feynman-percent {
    font-size: 24px;
    color: var(--text-muted);
    margin-top: 4px;
}

.ifl-feynman-breakdown {
    margin: 24px 0;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.ifl-feynman-category {
    margin-bottom: 16px;
}

.ifl-feynman-category:last-child {
    margin-bottom: 0;
}

.ifl-feynman-cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.ifl-feynman-cat-name {
    font-weight: 500;
    color: var(--text);
    font-size: 13px;
}

.ifl-feynman-cat-score {
    font-weight: 600;
    font-size: 13px;
}

.ifl-feynman-cat-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.ifl-feynman-cat-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.ifl-feynman-cat-feedback {
    font-size: 12px;
    color: var(--text-muted);
    margin: 8px 0 0 0;
    line-height: 1.4;
}

.ifl-feynman-overall {
    margin-top: 20px;
}

.ifl-feynman-overall h4 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text);
}

.ifl-feynman-overall p {
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
}

.ifl-feynman-error {
    text-align: center;
    padding: 24px;
    color: #a1a1aa;
}

.ifl-feynman-error p {
    margin-bottom: 16px;
}

/* Light mode overrides for tributaries */
[data-theme="light"] .ifl-tributary {
    background: rgba(0,0,0,0.03);
    border-color: var(--border);
}

[data-theme="light"] .ifl-tributary:hover {
    background: rgba(0,0,0,0.06);
}

[data-theme="light"] .ifl-trib-text {
    color: var(--text-secondary);
}

[data-theme="light"] .ifl-tributary.deeper .ifl-trib-label { color: #a1a1aa; }
[data-theme="light"] .ifl-tributary.wider .ifl-trib-label { color: #a1a1aa; }
[data-theme="light"] .ifl-tributary.practical .ifl-trib-label { color: #a1a1aa; }
[data-theme="light"] .ifl-tributary.quiz .ifl-trib-label { color: #a1a1aa; }
[data-theme="light"] .ifl-tributary.feynman .ifl-trib-label { color: #a1a1aa; }

/* ============================================================================
   PAYWALL MODAL
   ============================================================================ */

.paywall-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.paywall-overlay.visible {
    opacity: 1;
}

.paywall-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    max-width: 720px;
    width: 95%;
    padding: 32px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.paywall-modal.upgrade-modal {
    max-width: 480px;
}

.paywall-overlay.visible .paywall-modal {
    transform: scale(1);
}

.paywall-header {
    text-align: center;
    margin-bottom: 24px;
}

.paywall-header h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.paywall-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

.paywall-body {
    text-align: center;
}

.paywall-price {
    margin-bottom: 24px;
}

.price-amount {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
}

.price-period {
    font-size: 18px;
    color: var(--text-secondary);
}

.paywall-features {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
    text-align: left;
}

.paywall-features li {
    padding: 10px 0;
    padding-left: 32px;
    position: relative;
    color: var(--text);
    font-size: 15px;
    border-bottom: 1px solid var(--border);
}

.paywall-features li:last-child {
    border-bottom: none;
}

.paywall-features li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
    font-size: 16px;
}

.paywall-modal .btn-large {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
}

.paywall-footer {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 16px;
}

.paywall-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.paywall-close:hover {
    color: var(--text);
    background: var(--bg-tertiary);
}

/* Paywall Tier Selection */
.paywall-tiers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.paywall-tier {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.paywall-tier:hover {
    border-color: var(--border-hover);
}

.paywall-tier.featured {
    border-color: var(--primary);
    background: var(--primary-muted);
}

.tier-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.paywall-tier.featured .tier-badge {
    background: var(--primary);
    color: var(--primary-fg);
}

.tier-name {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.tier-price {
    margin-bottom: 16px;
}

.tier-price .price-amount {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.tier-price .price-period {
    font-size: 14px;
    color: var(--text-secondary);
}

.tier-features {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
    text-align: left;
}

.tier-features li {
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
    position: relative;
    padding-left: 24px;
}

.tier-features li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

.tier-features li strong {
    color: var(--primary);
}

.paywall-tier .btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
}

/* Paywall Upgrade View */
.paywall-upgrade {
    text-align: center;
}

.upgrade-comparison {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.current-plan, .upgrade-plan {
    text-align: center;
}

.plan-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.plan-name {
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.plan-limit {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
}

.upgrade-plan .plan-name {
    color: var(--primary);
}

.upgrade-arrow {
    font-size: 24px;
    color: var(--primary);
}

.upgrade-price {
    margin-bottom: 24px;
}

.upgrade-price .price-diff {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.upgrade-price .price-total {
    font-size: 14px;
    color: var(--text-secondary);
}

.upgrade-benefits {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
    text-align: left;
}

.upgrade-benefits li {
    padding: 10px 0;
    padding-left: 28px;
    position: relative;
    color: var(--text);
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.upgrade-benefits li:last-child {
    border-bottom: none;
}

.upgrade-benefits li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

.wait-option {
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.wait-option a {
    color: var(--text-secondary);
    text-decoration: underline;
}

.wait-option a:hover {
    color: var(--text);
}

/* Mobile paywall responsiveness */
@media (max-width: 600px) {
    .paywall-tiers {
        grid-template-columns: 1fr;
    }

    .paywall-modal {
        padding: 24px 20px;
    }

    .upgrade-comparison {
        flex-direction: column;
        gap: 12px;
    }

    .upgrade-arrow {
        transform: rotate(90deg);
    }
}

/* Free messages counter */
.free-messages-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.free-messages-counter.warning {
    background: rgba(255, 255, 255, 0.1);
    color: var(--warning);
}

.free-messages-counter.exhausted {
    background: rgba(255, 255, 255, 0.1);
    color: var(--error);
}

/* Light mode overrides for paywall */
[data-theme="light"] .paywall-overlay {
    background: rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .paywall-modal {
    background: #ffffff;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* ================================
   Learning Insights Section
   ================================ */

.insights-grid {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    -webkit-overflow-scrolling: touch;
}

.insights-grid::-webkit-scrollbar {
    height: 4px;
}

.insights-grid::-webkit-scrollbar-track {
    background: transparent;
}

.insights-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.insight-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
    flex-shrink: 0;
    transition: border-color 0.2s ease;
}

.insight-card:hover {
    border-color: var(--primary);
}

.insight-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.insight-icon svg {
    width: 16px;
    height: 16px;
}

.insight-card.achievement .insight-icon,
.insight-card.progress .insight-icon,
.insight-card.recommendation .insight-icon,
.insight-card.streak .insight-icon {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
}

.insight-content {
    flex: 1;
    min-width: 0;
}

.insight-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.insight-value {
    font-size: 11px;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    color: var(--text-secondary);
}

.insight-description {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.insight-loading {
    width: 100%;
    text-align: center;
    padding: 16px;
}

/* Insights responsive */
@media (max-width: 768px) {
    .insight-card {
        min-width: 180px;
    }
}

/* ============================================
   VISUALIZATION (Math/Physics Graphs)
   ============================================ */

.visualization-container {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.visualization-graph {
    width: 100%;
    min-height: 280px;
    background: rgba(255, 255, 255, 0.8);
}

/* Ensure Plotly fills container */
.visualization-graph .js-plotly-plot,
.visualization-graph .plot-container,
.visualization-graph .plotly {
    width: 100% !important;
}

/* Plotly overrides for dark theme */
.visualization-graph .main-svg {
    background: transparent !important;
}

.visualization-graph .plot-container {
    background: transparent !important;
}

/* Error state */
.viz-error {
    padding: 24px;
    text-align: center;
    color: var(--error);
    background: rgba(255, 255, 255, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .visualization-container {
        margin-top: 12px;
    }
    .visualization-graph {
        min-height: 220px;
    }
}

@media (max-width: 480px) {
    .visualization-graph {
        min-height: 200px;
    }
}

/* ============================================
   INTERACTIVE DIAGRAMS
   ============================================ */

.diagram-container {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    position: relative;
}

.diagram-error-placeholder {
    margin-top: 16px;
    padding: 14px 16px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, color 0.15s;
}

.diagram-error-placeholder:hover,
.diagram-error-placeholder:focus {
    border-color: var(--primary, #a1a1aa);
    color: var(--text-primary);
    outline: none;
}

.diagram-pending-placeholder {
    margin-top: 16px;
    height: 220px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(90deg, var(--bg-tertiary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    background-size: 200% 100%;
    animation: diagram-pending-shimmer 1.4s ease-in-out infinite;
}

@keyframes diagram-pending-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Floating pan/zoom controls dock — bottom-right of every SVG diagram.
   Appended by createDock() from pan-zoom-dock.js. Theme-aware via
   CSS custom properties. */
.diagram-dock {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-elevated, var(--bg-secondary, #1a1a1a));
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-lg, 10px);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.3));
    z-index: 5;
    opacity: 0.78;
    transition: opacity 160ms ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.diagram-container:hover .diagram-dock,
.diagram-dock:focus-within,
.diagram-dock:hover {
    opacity: 1;
}

.diagram-dock-btn {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-secondary, #a1a1aa);
    border: 1px solid transparent;
    border-radius: var(--radius-md, 6px);
    cursor: pointer;
    padding: 0;
    transition: background 120ms ease, color 120ms ease,
                border-color 120ms ease, transform 100ms ease;
}
.diagram-dock-btn:hover {
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.07));
    color: var(--text, #fafafa);
    border-color: var(--border-hover, rgba(255, 255, 255, 0.15));
}
.diagram-dock-btn:active {
    transform: scale(0.92);
}
.diagram-dock-btn:focus-visible {
    outline: 2px solid var(--primary, currentColor);
    outline-offset: 1px;
}
.diagram-dock-btn svg {
    display: block;
}

@media (prefers-reduced-motion: reduce) {
    .diagram-dock,
    .diagram-dock-btn {
        transition: none;
    }
    .diagram-dock-btn:active {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .diagram-pending-placeholder {
        animation: none;
        background: var(--bg-tertiary);
    }
}

.diagram-title {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.diagram-export-btns {
    margin-left: auto;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.diagram-container:hover .diagram-export-btns {
    opacity: 1;
}

.diagram-export-btn {
    padding: 3px 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: border-color 0.15s, color 0.15s;
}

.diagram-export-btn:hover {
    border-color: var(--primary);
    color: var(--text-primary);
}

/* Keyboard focus states */
.diagram-container:focus {
    outline: 2px solid var(--primary, #a1a1aa);
    outline-offset: 2px;
}

.diagram-container:focus:not(:focus-visible) {
    outline: none;
}

.diagram-kb-active {
    outline: 2px solid var(--primary, #a1a1aa);
    outline-offset: 2px;
}

[data-kb-focused="true"] {
    filter: drop-shadow(0 0 4px var(--primary, #a1a1aa));
}

/* Reduced motion */
/* Render animation — diagrams fade in on creation */
.diagram-container {
    animation: diagram-fade-in 0.4s ease both;
}

@keyframes diagram-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* SVG element hover feedback */
.diagram-canvas-wrap svg circle[cursor="pointer"]:hover,
.diagram-canvas-wrap svg rect[cursor="pointer"]:hover,
.diagram-canvas-wrap svg g[cursor="pointer"]:hover {
    filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.25));
    transition: filter 0.15s ease;
}

/* Interactive elements get pointer cursor */
.diagram-canvas-wrap [data-focusable] {
    cursor: pointer;
}

/* Diagram typography — consistent across all types */
.diagram-canvas-wrap text {
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Smooth transitions for theme changes */
.diagram-container,
.diagram-title,
.diagram-controls,
.diagram-canvas-wrap {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Control buttons polish */
.diagram-controls button {
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.diagram-controls button:active {
    transform: scale(0.95);
}

/* Title bar subtle bottom shadow */
.diagram-title {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Print mode — clean, no decorations */
@media print {
    .diagram-container {
        border: 1px solid #000 !important;
        background: #fff !important;
        animation: none !important;
        break-inside: avoid;
    }
    .diagram-title {
        color: #000 !important;
        border-bottom: 1px solid #000 !important;
        box-shadow: none !important;
    }
    .diagram-export-btns,
    .diagram-controls {
        display: none !important;
    }
    .diagram-canvas-wrap {
        background: #fff !important;
    }
    .diagram-canvas-wrap text {
        fill: #000 !important;
    }
    .diagram-canvas-wrap line,
    .diagram-canvas-wrap path,
    .diagram-canvas-wrap circle,
    .diagram-canvas-wrap rect {
        stroke: #000 !important;
    }
}

/* ============================================
   IFL DIAGRAM EDITOR
   ============================================ */

/* Fullscreen overlay */
.ifl-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100001;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.ifl-editor-overlay.active { opacity: 1; }

/* Fullscreen editor */
.ifl-editor-fullscreen {
    position: fixed;
    inset: 24px;
    z-index: 100002;
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ifl-editor-fullscreen.active {
    opacity: 1;
    transform: scale(1);
}

.ifl-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ifl-editor-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.ifl-editor-header-actions {
    display: flex;
    gap: 8px;
}

.ifl-editor-save-btn {
    padding: 6px 16px;
    border-radius: 6px;
    border: none;
    background: var(--primary, #a1a1aa);
    color: var(--primary-fg, #fff);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.ifl-editor-save-btn:hover { opacity: 0.9; }

.ifl-editor-close-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

.ifl-editor-close-btn:hover { color: var(--text-primary); }

/* Body layout */
.ifl-editor-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.ifl-editor-sidebar {
    width: 220px;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    background: var(--bg-secondary);
}

.ifl-editor-right {
    border-right: none;
    border-left: 1px solid var(--border);
}

.ifl-editor-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ifl-editor-canvas {
    flex: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
}

.ifl-editor-status {
    padding: 4px 12px;
    display: flex;
    gap: 12px;
    font-size: 11px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* Toolbar */
.ifl-editor-toolbar, .ifl-editor-inline-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-wrap: wrap;
}

.ifl-toolbar-btn {
    padding: 5px 7px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
    font-size: 12px;
}

.ifl-toolbar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.ifl-toolbar-btn.active {
    background: var(--primary, #a1a1aa);
    color: var(--primary-fg);
    border-color: var(--primary);
}

.ifl-toolbar-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.ifl-toolbar-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.ifl-toolbar-right {
    margin-left: auto;
    display: flex;
    gap: 2px;
}

/* Properties panel */
.ifl-properties-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ifl-properties-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.ifl-properties-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.ifl-properties-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
}

.ifl-properties-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.ifl-properties-empty {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    padding: 20px 0;
}

.ifl-prop-type {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.ifl-prop-field {
    margin-bottom: 10px;
}

.ifl-prop-field label {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.ifl-prop-field input,
.ifl-prop-field select,
.ifl-prop-field textarea {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 12px;
    font-family: Inter, sans-serif;
    box-sizing: border-box;
}

.ifl-prop-field input:focus,
.ifl-prop-field select:focus {
    outline: none;
    border-color: var(--primary);
}

.ifl-prop-checkbox label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ifl-prop-checkbox input[type="checkbox"] {
    width: auto;
}

/* Templates */
.ifl-templates-header {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.ifl-templates-list {
    padding: 8px;
}

.ifl-template-group {
    margin-bottom: 12px;
}

.ifl-template-group-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 4px 4px 6px;
}

.ifl-template-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    margin-bottom: 2px;
}

.ifl-template-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
    color: var(--text-primary);
}

/* Export menu */
.ifl-export-menu {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    padding: 4px;
    z-index: 100;
}

.ifl-export-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
}

.ifl-export-menu button:hover {
    background: var(--bg-tertiary);
}

/* Inline editor */
.ifl-editor-inline {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 12px;
}

.ifl-editor-inline-canvas {
    min-height: 300px;
}

/* Responsive */
@media (max-width: 768px) {
    .ifl-editor-fullscreen {
        inset: 8px;
    }
    .ifl-editor-sidebar {
        width: 160px;
    }
    .ifl-editor-left {
        display: none;
    }
}

@media (max-width: 480px) {
    .ifl-editor-fullscreen {
        inset: 0;
        border-radius: 0;
    }
    .ifl-editor-sidebar {
        display: none;
    }
}

/* ============================================
   EDITOR — Sidebar Tabs
   ============================================ */

.ifl-sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ifl-sidebar-tab {
    flex: 1;
    padding: 8px 4px;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.ifl-sidebar-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.ifl-sidebar-tab.active {
    color: var(--primary, #a1a1aa);
    border-bottom-color: var(--primary, #a1a1aa);
}

.ifl-sidebar-panel {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* ============================================
   EDITOR — Selection Overlay
   ============================================ */

.ifl-selection-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

.ifl-selection-rect {
    pointer-events: none;
    transition: none;
}

.ifl-selection-handle {
    pointer-events: none;
}

/* ============================================
   EDITOR — Context Menu
   ============================================ */

.ifl-context-menu {
    position: fixed;
    z-index: 200000;
    min-width: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    padding: 4px;
    font-family: Inter, -apple-system, sans-serif;
}

.ifl-context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 12px;
    border: none;
    border-radius: 5px;
    background: transparent;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s ease;
}

.ifl-context-menu-item:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

.ifl-context-menu-item:disabled {
    opacity: 0.35;
    cursor: default;
}

.ifl-context-menu-icon {
    display: flex;
    align-items: center;
    width: 16px;
    flex-shrink: 0;
}

.ifl-context-menu-label {
    flex: 1;
}

.ifl-context-menu-divider {
    height: 1px;
    margin: 4px 8px;
    background: var(--border);
}

/* ============================================
   EDITOR — Data Panel
   ============================================ */

.ifl-data-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ifl-data-panel-header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.ifl-data-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.ifl-data-panel-body {
    padding: 8px;
    overflow-y: auto;
    flex: 1;
}

.ifl-data-empty {
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
    padding: 20px 0;
}

/* Data sections */
.ifl-data-section {
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.ifl-data-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    cursor: pointer;
    user-select: none;
    font-size: 12px;
}

.ifl-data-section-header:hover {
    background: var(--bg-secondary);
}

.ifl-data-section-toggle {
    font-size: 9px;
    color: var(--text-muted);
    width: 12px;
}

.ifl-data-section-title {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.ifl-data-section-count {
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 1px 5px;
    border-radius: 8px;
}

.ifl-data-add-btn {
    padding: 0 6px;
    height: 20px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    color: var(--primary, #a1a1aa);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
}

.ifl-data-add-btn:hover {
    background: var(--primary, #a1a1aa);
    color: var(--primary-fg);
    border-color: var(--primary);
}

/* Data items */
.ifl-data-items {
    border-top: 1px solid var(--border);
}

.ifl-data-array-item {
    border-bottom: 1px solid var(--border);
    padding: 4px 0;
}

.ifl-data-array-item:last-child {
    border-bottom: none;
}

.ifl-data-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    gap: 4px;
}

.ifl-data-item-label {
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ifl-data-item-label:hover {
    color: var(--primary, #a1a1aa);
}

.ifl-data-item-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.ifl-data-move-btn,
.ifl-data-delete-btn {
    padding: 0 4px;
    height: 18px;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    line-height: 1;
}

.ifl-data-move-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.ifl-data-delete-btn:hover {
    background: var(--primary);
    color: var(--primary-fg);
}

.ifl-data-item-fields {
    padding: 4px 8px 4px 20px;
}

/* Data fields */
.ifl-data-field {
    margin-bottom: 6px;
}

.ifl-data-field label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.ifl-data-field input,
.ifl-data-field select,
.ifl-data-field textarea {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 11px;
    font-family: Inter, sans-serif;
    box-sizing: border-box;
}

.ifl-data-field input:focus,
.ifl-data-field select:focus,
.ifl-data-field textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.ifl-data-field input[type="color"] {
    padding: 2px;
    height: 26px;
    cursor: pointer;
}

.ifl-data-field input[type="checkbox"] {
    width: auto;
}

.ifl-data-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-primary);
}

/* Highlighted field */
.ifl-data-highlighted {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    outline: 1px solid var(--primary, #a1a1aa);
}

/* Add form */
.ifl-data-add-form {
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--primary, #a1a1aa);
    border-radius: 6px;
    background: var(--bg-tertiary);
}

.ifl-data-add-form-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.ifl-data-add-form-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.ifl-data-add-confirm,
.ifl-data-add-cancel {
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-size: 11px;
    cursor: pointer;
}

.ifl-data-add-confirm {
    background: var(--primary, #a1a1aa);
    color: var(--primary-fg);
    border-color: var(--primary);
}

.ifl-data-add-cancel {
    background: transparent;
    color: var(--text-secondary);
}

/* ============================================
   EDITOR — Grid Overlay
   ============================================ */

.ifl-grid-overlay {
    pointer-events: none;
}

/* ============================================
   EDITOR — Restore Prompt
   ============================================ */

.ifl-restore-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 20;
    font-size: 13px;
    color: var(--text-primary);
}

.ifl-restore-prompt button {
    padding: 5px 14px;
    border-radius: 5px;
    border: 1px solid var(--border);
    font-size: 12px;
    cursor: pointer;
}

.ifl-restore-prompt button:first-of-type {
    background: var(--primary, #a1a1aa);
    color: var(--primary-fg);
    border-color: var(--primary);
}

.ifl-restore-prompt button:last-of-type {
    background: transparent;
    color: var(--text-secondary);
}

/* ============================================
   EDITOR — Color Picker
   ============================================ */

.ifl-color-picker {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    padding: 8px;
}

.ifl-color-picker-presets {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-bottom: 6px;
}

.ifl-color-preset {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.1s, transform 0.1s;
}

.ifl-color-preset:hover {
    border-color: #fff;
    transform: scale(1.15);
}

.ifl-color-custom {
    width: 100%;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
}

/* ============================================
   EDITOR — Inline Text Input
   ============================================ */

.ifl-inline-text-input {
    box-sizing: border-box;
}

.ifl-inline-text-input:focus {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* ============================================
   EDITOR — Canvas Sizing Fix
   ============================================ */

.ifl-editor-canvas .diagram-canvas-wrap {
    max-height: none !important;
    min-height: 100%;
}

.ifl-editor-canvas .diagram-canvas-wrap svg {
    max-height: none !important;
    width: 100%;
    height: 100%;
}

.ifl-sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    gap: 0;
}

.ifl-sidebar-tab {
    flex: 1;
    padding: 8px 4px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    text-align: center;
    white-space: nowrap;
}

.ifl-sidebar-tab:hover {
    color: var(--text-secondary);
}

.ifl-sidebar-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ============================================
   EDITOR — Light Mode
   ============================================ */

.light-mode .ifl-context-menu {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.light-mode .ifl-restore-prompt {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.light-mode .ifl-data-highlighted {
    background: rgba(255, 255, 255, 0.08);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .diagram-container,
    .diagram-container * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

.diagram-title svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.diagram-canvas-wrap {
    width: 100%;
    min-height: 200px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.diagram-canvas-wrap canvas {
    display: block;
    max-width: 100%;
    max-height: 500px;
}

.diagram-canvas-wrap svg {
    display: block;
    max-width: 100%;
    max-height: 500px;
    margin: 0 auto;
}

.diagram-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    align-items: center;
}

.diagram-controls button {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 12px;
    font-family: Inter, -apple-system, sans-serif;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.diagram-controls button:hover {
    border-color: var(--primary);
    background: var(--bg-primary);
}

.diagram-controls button:active {
    transform: scale(0.97);
}

.diagram-info-tooltip {
    position: absolute;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-primary);
    max-width: 250px;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    line-height: 1.4;
}

.diagram-slider {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.diagram-slider input[type="range"] {
    width: 80px;
    accent-color: var(--primary, #a1a1aa);
}

/* Light mode overrides */
.light-mode .diagram-canvas-wrap {
    background: var(--bg-primary, #ffffff);
}

.light-mode .diagram-info-tooltip {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .diagram-container {
        margin-top: 12px;
    }
    .diagram-canvas-wrap {
        min-height: 180px;
    }
    .diagram-canvas-wrap svg {
        max-height: 350px;
    }
    .diagram-controls {
        padding: 6px 8px;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .diagram-canvas-wrap {
        min-height: 150px;
    }
    .diagram-canvas-wrap svg {
        max-height: 280px;
    }
    .diagram-controls button {
        padding: 3px 8px;
        font-size: 11px;
    }
}

/* ============================================
   HEADER USER MENU & THEME TOGGLE
   ============================================ */

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Icon Button (Theme Toggle) */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text);
    border-color: var(--text-muted);
}

/* Theme toggle icons - visibility controlled by JS */
.icon-btn .icon-sun,
.icon-btn .icon-moon {
    transition: opacity 0.2s ease, transform 0.3s ease;
}

/* Header Hero (greeting on left) */
.header-hero {
    display: flex;
    align-items: center;
}

.header-hero-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-greeting {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.header-subtitle {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.4;
    max-width: 600px;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.trigger-logo {
    height: 28px;
    flex-shrink: 0;
}

.user-menu-trigger:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
}

.user-menu-plan {
    font-size: 14px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text);
    line-height: 1;
}

.user-menu-plan.pro {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.25));
    color: var(--primary);
}

.user-menu-plan.cancelling {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.15));
    color: var(--warning);
    font-size: 12px;
}

.dropdown-cancel-notice {
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    font-size: 0.75rem;
    color: var(--warning);
    line-height: 1.3;
}

#settings-plan-status.cancelling {
    color: var(--warning);
}

.user-menu-trigger svg:last-child {
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.user-menu.open .user-menu-trigger svg:last-child {
    transform: rotate(180deg);
}

/* Dropdown */
.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 10000;
}

.user-menu.open .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-section {
    padding: 12px 16px;
}

.dropdown-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
}

.dropdown-item svg {
    color: var(--text-muted);
}

.dropdown-item:hover svg {
    color: var(--text);
}

/* Compact Usage in Dropdown */
.usage-compact {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.usage-compact-item {
    display: grid;
    grid-template-columns: 70px 1fr 50px;
    align-items: center;
    gap: 10px;
}

.usage-compact-label {
    font-size: 12px;
    color: var(--text-muted);
}

.usage-compact-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.usage-compact-progress {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    min-width: 2px;
}

.usage-compact-progress.warning {
    background: var(--warning);
}

.usage-compact-progress.exhausted {
    background: var(--error);
}

.usage-compact-count {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Paywall message styling */
.chat-msg.paywall-message .msg-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.chat-msg.paywall-message .paywall-subscribe-btn {
    margin-top: 12px;
}

/* Inline paywall in chat */
.paywall-inline {
    text-align: center;
}

.paywall-inline-heading {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--text-primary);
}

.paywall-inline-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0 0 16px;
}

.paywall-inline-tiers {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.paywall-inline-tier {
    flex: 1;
    max-width: 220px;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    text-align: center;
}

.paywall-inline-tier.featured {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.08);
}

.paywall-inline-features {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 6px 0 10px;
    line-height: 1.4;
}

.paywall-inline-btn {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.85rem;
}

@media (max-width: 480px) {
    .paywall-inline-tiers {
        flex-direction: column;
        align-items: center;
    }
    .paywall-inline-tier {
        max-width: 100%;
    }
}

/* Header responsive */
@media (max-width: 768px) {
    .header-actions {
        gap: 8px;
    }

    .header-actions .btn {
        display: none;
    }

    .header-actions .btn#start-session-btn {
        display: flex;
        padding: 8px 12px;
        font-size: 13px;
    }

    .header-hero-text {
        display: flex;
    }

    .header-greeting {
        font-size: 0.95rem;
    }

    .header-subtitle {
        display: none;
    }

    .user-menu-dropdown {
        width: 260px;
        right: -10px;
    }
}

/* ============================================
   Channel Tabs - Sub-topic Navigation
   ============================================ */

.channel-tabs-container {
    height: 44px;
    min-height: 44px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.channel-tabs-wrapper {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.channel-tabs-wrapper::-webkit-scrollbar {
    display: none;
}

.channel-tabs-list {
    display: flex;
    gap: 2px;
    padding: 6px 12px;
    min-width: min-content;
}

.channel-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    max-width: 180px;
    min-width: 80px;
    transition: all 0.15s ease;
    position: relative;
}

.channel-tab:hover {
    background: var(--bg-elevated);
}

.channel-tab.active {
    background: var(--bg-card);
    border-color: var(--border);
    border-bottom-color: var(--bg-card);
    margin-bottom: -1px;
}

.channel-tab-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.channel-tab-status.status-new {
    background: var(--primary);
}

.channel-tab-status.status-active {
    background: var(--primary);
    animation: pulse-status 2s ease-in-out infinite;
}

.channel-tab-status.status-learning {
    background: var(--warning);
}

.channel-tab-status.status-reviewing {
    background: var(--error);
}

.channel-tab-status.status-mastered {
    background: var(--success);
}

.channel-tab-status.status-streaming {
    background: var(--primary);
    animation: flowPulse 1s ease-in-out infinite;
    box-shadow: 0 0 6px var(--primary);
}

@keyframes pulse-status {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes flowPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

.channel-tab-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.channel-tab.active .channel-tab-name {
    color: var(--text);
}

.channel-tab-close {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.channel-tab:hover .channel-tab-close {
    opacity: 1;
}

.channel-tab-close:hover {
    background: var(--bg-tertiary);
    color: var(--text);
}

/* Tabs overflow scroll indicator */
.channel-tabs-container {
    position: relative;
}

.channel-tabs-container::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, var(--bg-secondary));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.channel-tabs-container.has-overflow::after {
    opacity: 1;
}

/* Mobile responsive tabs */
@media (max-width: 768px) {
    .channel-tabs-container {
        height: 40px;
        min-height: 40px;
    }

    .channel-tabs-list {
        padding: 4px 8px;
    }

    .channel-tab {
        padding: 4px 10px;
        max-width: 140px;
        min-width: 60px;
    }

    .channel-tab-name {
        font-size: 12px;
    }

    .channel-tab-close {
        opacity: 1;
        width: 16px;
        height: 16px;
        font-size: 14px;
    }
}

/* ================================
   MOBILE RESPONSIVE STYLES
   ================================ */

/* 480px - Small phones */
@media (max-width: 480px) {
    /* Channel tabs - very compact */
    .channel-tabs-container {
        height: 36px;
        min-height: 36px;
    }

    .channel-tabs-list {
        padding: 3px 6px;
        gap: 4px;
    }

    .channel-tab {
        padding: 3px 8px;
        max-width: 100px;
        min-width: 50px;
        gap: 4px;
    }

    .channel-tab-status {
        width: 6px;
        height: 6px;
    }

    .channel-tab-name {
        font-size: 11px;
    }

    /* Chat input - stack vertically */
    .chat-form {
        gap: 8px;
    }

    .chat-input-field {
        padding: 10px 12px;
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 40px;
    }

    .chat-submit-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Mindmap toolbar - smaller chips */
    .mindmap-toolbar {
        left: 8px;
        bottom: 8px;
        gap: 4px;
    }

    .mindmap-toolbar .chip,
    .mindmap-toolbar .toolbar-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    /* Mindmap popover - full width on small screens */
    .mindmap-popover {
        width: calc(100% - 16px);
        right: 8px;
        left: 8px;
        max-height: 60vh;
    }

    /* Node popover - adjust for small screens */
    .node-popover {
        right: 8px;
        top: 8px;
        width: calc(100% - 16px);
        max-height: calc(100% - 16px);
    }

    .node-popover-header {
        padding: 10px 12px;
    }

    .node-popover-body {
        padding: 12px;
        max-height: 300px;
    }

    .node-popover-buttons {
        flex-direction: column;
    }

    .node-btn {
        width: 100%;
        padding: 10px;
    }

    /* Popover close button - larger touch target */
    .node-popover-close,
    .popover-close-btn {
        padding: 8px;
        font-size: 1.75rem;
        min-width: 44px;
        min-height: 44px;
    }

    /* Message bubbles - more width */
    .chat-msg {
        max-width: 95%;
    }

    /* Mindmap nodes - larger touch targets */
    .mindmap-node {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Touch-friendly improvements for all mobile */
@media (max-width: 768px) {
    /* Mindmap popover responsive */
    .mindmap-popover {
        width: min(320px, calc(100% - 32px));
        right: 16px;
    }

    /* Larger touch targets for buttons */
    .popover-btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    /* Mindmap toolbar adjustments */
    .mindmap-toolbar {
        left: 12px;
        bottom: 12px;
    }

    /* Node popover buttons */
    .node-btn {
        min-height: 40px;
    }

    /* Session cards */
    .session-card {
        padding: 12px !important;
    }

    .session-card .session-meta {
        font-size: 0.75rem !important;
    }

    .session-card .session-actions {
        gap: 4px !important;
    }

    .session-card .session-actions button {
        padding: 6px 8px !important;
        font-size: 0.7rem !important;
    }

    /* Modal close buttons - larger touch area */
    .modal-close,
    .chat-fullscreen-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ============================================================================
   Help Button and Modal
   ============================================================================ */

/* Chat Tools Dropdown (in session header) */
.chat-tools-dropdown {
    position: relative;
    display: inline-flex;
}

.chat-tools-trigger {
    background: var(--primary) !important;
}

.chat-tools-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    min-width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    z-index: 1000;
    padding: 4px;
    animation: chatToolsIn 0.15s ease;
}

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

.chat-tools-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    min-height: 40px;
    transition: background 0.1s;
}

.chat-tools-item:hover {
    background: var(--bg-tertiary);
}

.chat-tools-item:active {
    opacity: 0.7;
}

.chat-tools-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.chat-tools-item span {
    flex: 1;
}

.chat-tools-divider {
    height: 1px;
    margin: 4px 12px;
    background: var(--border);
}

.chat-tools-customize {
    opacity: 0.6;
    font-size: 12px !important;
}

.chat-tools-customize:hover {
    opacity: 1;
}

/* Help Button - Matches exit session button size */
.chat-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-lg);
    border: none;
    background: var(--primary);
    color: var(--primary-fg);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-help-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.chat-help-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.chat-help-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

/* Light mode help button */
:root.light-mode .chat-help-btn {
    background: var(--primary);
}

:root.light-mode .chat-help-btn:hover {
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.15);
}

/* Help Modal Overlay */
.help-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.help-modal-overlay.active {
    opacity: 1;
}

/* Help Modal */
.help-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    max-width: 800px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.2s ease;
}

.help-modal-overlay.active .help-modal {
    transform: translateY(0);
}

/* Help Modal Header */
.help-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.help-modal-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.help-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.help-modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text);
}

.help-modal-close svg {
    width: 20px;
    height: 20px;
}

/* Help Modal Content */
.help-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Help Sections */
.help-section {
    margin-bottom: 32px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-muted);
}

.help-section p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}

.help-section ul,
.help-section ol {
    color: var(--text-secondary);
    line-height: 1.7;
    padding-left: 24px;
    margin-bottom: 12px;
}

.help-section li {
    margin-bottom: 8px;
}

.help-section li strong {
    color: var(--text);
}

/* Help Feature Grid */
.help-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.help-feature {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.help-feature h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.help-feature p {
    font-size: 0.875rem;
    margin-bottom: 0;
}

/* Tier Badges */
.tier-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    margin-bottom: 6px;
}

.tier-badge.sage-only {
    background: var(--primary);
    color: var(--primary-fg);
}

.tier-badge.scholar-up {
    background: var(--primary);
    color: var(--primary-fg);
}

/* Help Shortcuts */
.help-shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.help-shortcut {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.help-shortcut kbd {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: inherit;
    font-size: 0.8rem;
    color: var(--text);
    white-space: nowrap;
}

/* Help Smart Colors Section */
.help-color-hierarchy {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 16px 0;
    padding: 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.help-color-level {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.help-color-swatches {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.help-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.help-color-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.help-color-info strong {
    color: var(--text);
    font-size: 0.95rem;
}

.help-color-info span {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

.help-tip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 16px 0;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 100%);
    border-radius: var(--radius);
    border-left: 3px solid var(--primary);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.help-tip svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--primary);
}

.help-border-indicator {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 3px solid;
    background: var(--bg-elevated);
    margin-right: 8px;
    vertical-align: middle;
}

/* Help Tiers Comparison */
.help-tiers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.help-tier {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.help-tier.highlight {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

.help-tier h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
}

.help-tier.highlight h4 {
    color: var(--primary);
}

.help-tier ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-tier li {
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.help-tier li:last-child {
    border-bottom: none;
}

/* Light Mode Adjustments */
:root.light-mode .help-modal {
    background: #ffffff;
}

:root.light-mode .help-modal-header {
    background: #f9fafb;
}

:root.light-mode .help-feature,
:root.light-mode .help-tier {
    background: #f9fafb;
}

:root.light-mode .help-shortcut kbd {
    background: #f3f4f6;
}

:root.light-mode .help-color-hierarchy {
    background: #f9fafb;
}

:root.light-mode .help-swatch {
    border-color: rgba(0, 0, 0, 0.1);
}

:root.light-mode .help-tip {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(139, 92, 246, 0.08) 100%);
}

:root.light-mode .help-border-indicator {
    background: #ffffff;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .help-modal {
        max-height: 90vh;
    }

    .help-modal-header {
        padding: 16px;
    }

    .help-modal-header h2 {
        font-size: 1.1rem;
    }

    .help-modal-content {
        padding: 16px;
    }

    .help-feature-grid,
    .help-shortcuts,
    .help-tiers {
        grid-template-columns: 1fr;
    }

    .help-color-level {
        flex-direction: column;
        gap: 10px;
    }

    .help-color-swatches {
        flex-wrap: wrap;
    }

    .help-swatch {
        width: 20px;
        height: 20px;
    }

    .chat-help-btn span {
        display: none;
    }

    .chat-help-btn {
        padding: 8px 10px;
    }
}

/* ================================================
   Research Mode (Sage tier only)
   ================================================ */

/* Research Mode Toggle Container */
#research-mode-container {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

#research-mode-container.visible {
    display: flex;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 24px;
    transition: background 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.research-label {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    line-height: 1.3;
}

.research-label span:first-child {
    color: var(--text);
    font-weight: 500;
}

.research-count {
    font-size: 11px;
    color: var(--text-muted);
}

/* Research response badge */
.badge-research {
    display: block;
    width: fit-content;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    margin-bottom: 10px;
}

/* Research response message styling */
.chat-msg.research-response {
    border-left: 3px solid #764ba2;
}

/* Subject guardrail redirect */
.chat-msg.subject-redirect {
    border-left: 3px solid #a1a1aa;
    background: rgba(255, 255, 255, 0.05);
}

.light-mode .chat-msg.subject-redirect {
    background: rgba(255, 255, 255, 0.08);
}

/* Safety redirect — profanity, off-topic, crisis, harmful, age-inappropriate.
   Rendered with a distinct warning style so users immediately see their
   message was filtered rather than mistaking the redirect for a tutor reply. */
.chat-msg.safety-redirect {
    border-left: 3px solid #a1a1aa;
    background: rgba(255, 255, 255, 0.06);
    position: relative;
}

.chat-msg.safety-redirect .msg-content::before {
    content: "Message filtered";
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #a1a1aa;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
}

:lang(fr) .chat-msg.safety-redirect .msg-content::before,
[lang="fr"] .chat-msg.safety-redirect .msg-content::before {
    content: "Message filtré";
}

.light-mode .chat-msg.safety-redirect {
    background: rgba(255, 255, 255, 0.08);
}

/* Citations Box */
.citations-box {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.citations-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.citations-list {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: citation;
}

.citation-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.citation-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.citation-item a {
    color: var(--primary);
    text-decoration: none;
    font-size: 13px;
    display: block;
}

.citation-item a:hover {
    text-decoration: underline;
}

.citation-num {
    font-weight: 600;
    margin-right: 6px;
    color: var(--text-secondary);
}

.citation-snippet {
    margin: 4px 0 0 20px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Light Mode adjustments for Research Mode */
:root.light-mode .toggle-slider {
    background: var(--border);
}

:root.light-mode input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

:root.light-mode .citations-box {
    background: var(--bg-secondary);
}

:root.light-mode .citation-item a {
    color: #4f46e5;
}

/* Mobile Responsive for Research Mode */
@media (max-width: 768px) {
    #research-mode-container {
        padding: 6px 10px;
    }

    .toggle-switch {
        width: 40px;
        height: 22px;
    }

    .toggle-slider:before {
        height: 16px;
        width: 16px;
    }

    input:checked + .toggle-slider:before {
        transform: translateX(18px);
    }

    .research-label {
        font-size: 12px;
    }

    .research-count {
        font-size: 10px;
    }
}

/* ============================================
   Review System Styles
   ============================================ */

.review-card {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 20px 24px;
}

.review-card-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.review-card-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.review-card-count {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.review-card-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.review-card-right .btn-primary {
    white-space: nowrap;
}

/* Review Overlay */
.review-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.review-session-container {
    background: var(--bg-card);
    border-radius: 16px;
    width: 90%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.review-session-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.review-session-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text);
}

.review-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.review-close-btn:hover {
    background: var(--bg-elevated);
}

.review-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    margin-bottom: 24px;
    overflow: hidden;
}

.review-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.review-question-badge {
    display: inline-block;
    background: var(--primary);
    color: var(--primary-fg);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.review-question-type {
    display: inline-block;
    background: var(--primary-muted);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 8px;
    margin-left: 8px;
}

.review-results-summary {
    text-align: center;
    padding: 20px 0;
}

.review-results-score {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.review-results-message {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.review-concept-results {
    list-style: none;
    padding: 0;
    margin: 0 0 24px 0;
}

.review-concept-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--bg-elevated);
}

.review-concept-name {
    font-weight: 500;
    color: var(--text);
}

.review-mastery-change {
    font-size: 0.85rem;
    font-weight: 600;
}

.review-mastery-up {
    color: #a1a1aa;
}

.review-mastery-down {
    color: #a1a1aa;
}

.review-mastery-same {
    color: var(--text-secondary);
}

.review-results-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.review-all-caught-up {
    text-align: center;
    padding: 40px 20px;
}

.review-all-caught-up .checkmark {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
}

.review-all-caught-up p {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

/* Loading state */
.review-loading {
    text-align: center;
    padding: 40px 20px;
}

.review-loading span {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Responsive */
@media (max-width: 768px) {
    .review-card-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .review-session-container {
        width: 95%;
        padding: 20px;
    }
}

/* ========================================================================
   LANDSCAPE PHONE LAYOUT (side-by-side restored)
   Must appear LAST to override all stacking breakpoints (1024px, 768px, 480px)
   ======================================================================== */

@media (orientation: landscape) and (max-width: 950px) {
    .chat-fullscreen-body {
        flex-direction: row !important;
    }

    .chat-fullscreen-body:not([data-panel-view="chat-only"]):not([data-panel-view="mindmap-only"]) .chat-panel-left {
        width: 40% !important;
        height: 100% !important;
        border-right: 1px solid var(--border);
        border-bottom: none;
    }

    .chat-fullscreen-body:not([data-panel-view="chat-only"]):not([data-panel-view="mindmap-only"]) .chat-panel-right {
        width: 60% !important;
        height: 100% !important;
    }

    .chat-fullscreen-header {
        height: 40px;
        padding: 6px 12px;
    }

    .chat-fullscreen-logo,
    .chat-fullscreen-logo-large {
        height: 22px;
    }

    .chat-fullscreen-product {
        font-size: 0.85rem;
    }

    .chat-fullscreen-session {
        display: none;
    }

    .chat-form {
        padding: 6px 10px;
        gap: 6px;
        flex-direction: row !important;
        flex-wrap: nowrap;
    }

    .chat-submit-btn {
        width: auto !important;
    }

    .chat-input-field {
        min-height: 36px;
        font-size: 14px;
    }
}

/* ============================================================================
   GAMIFICATION SYSTEM - Clean Premium Design
   ============================================================================ */

/* --- Action Bar --- */
/* =============================================
   DASHBOARD NEON PREMIUM STYLES
   ============================================= */

/* --- Entrance Animation --- */
.dash-animate {
    opacity: 0;
    transform: translateY(20px);
}

.dash-animate.dash-visible {
    animation: dashFadeInUp 0.5s ease-out forwards;
}

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

/* --- Tile Entrance Animation --- */
.tile-animate {
    opacity: 0;
    transform: scale(0.8);
    animation: tilePopIn 0.35s ease-out forwards;
}

@keyframes tilePopIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* --- Hero Action: Start Learning --- */
/* --- Start Learning Hero (command center) --- */
.learn-hero {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    overflow: hidden;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.learn-hero:hover {
    border-color: var(--border-hover);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.light-mode .learn-hero {
    background: var(--bg-card);
    border-color: var(--border);
}

.light-mode .learn-hero:hover {
    border-color: var(--border-hover);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}

.learn-hero .hw-card-body {
    padding: 40px 36px;
    gap: 24px;
}

.learn-hero .hw-card-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
}

/* Hero row — 2-column grid for secondary hero cards */
.hero-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

@media (max-width: 768px) {
    .hero-row {
        grid-template-columns: 1fr;
    }
    .learn-hero .hw-card-body {
        padding: 28px 24px;
    }
}

/* Ambient animated orbs */
.learn-hero-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.learn-hero-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.15;
}

.learn-orb-1 {
    width: 120px;
    height: 120px;
    background: #a1a1aa;
    top: -30px;
    right: -20px;
    animation: learnOrbFloat1 6s ease-in-out infinite;
}

.learn-orb-2 {
    width: 80px;
    height: 80px;
    background: #a1a1aa;
    bottom: -20px;
    left: 20%;
    animation: learnOrbFloat2 8s ease-in-out infinite;
}

.learn-orb-3 {
    width: 60px;
    height: 60px;
    background: #a1a1aa;
    top: 50%;
    left: 60%;
    animation: learnOrbFloat3 7s ease-in-out infinite;
}

@keyframes learnOrbFloat1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-15px, 10px); }
}

@keyframes learnOrbFloat2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(10px, -8px); }
}

@keyframes learnOrbFloat3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-10px, 5px) scale(1.1); }
}

.light-mode .learn-hero-orb { opacity: 0.08; }

/* Status strip */
.learn-hero-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: linear-gradient(180deg, #22252b 0%, #1a1d21 100%);
    border-bottom: 1px solid #2a2d33;
    font-family: 'Courier New', monospace;
    position: relative;
    z-index: 1;
}

.light-mode .learn-hero-strip {
    background: linear-gradient(180deg, #d5d7dd 0%, #eaebef 100%);
    border-bottom-color: #c0c3c8;
}

.learn-hero-led {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a1a1aa;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.7);
    animation: learnLedPulse 2s ease infinite;
}

@keyframes learnLedPulse {
    0%, 80%, 100% { opacity: 1; }
    90% { opacity: 0.3; }
}

.learn-hero-status {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #a1a1aa;
}

.learn-hero-sep {
    width: 1px;
    height: 12px;
    background: #2a2d33;
    margin: 0 4px;
}

.light-mode .learn-hero-sep { background: #c0c3c8; }

.learn-hero-agents {
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #666;
}

.light-mode .learn-hero-agents { color: #888; }

.learn-hero-spacer { flex: 1; }

.learn-hero-mode {
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #a1a1aa;
    padding: 1px 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

/* learn-hero body now uses shared .hw-card-body */

/* Bottom telemetry bar */
.learn-hero-telemetry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 5px;
    border-top: 1px solid #2a2d33;
    background: linear-gradient(0deg, #15171b 0%, #1a1d21 100%);
    font-family: 'Courier New', monospace;
    position: relative;
    z-index: 1;
}

.light-mode .learn-hero-telemetry {
    border-top-color: #c0c3c8;
    background: linear-gradient(0deg, #dddfe3 0%, #eaebef 100%);
}

.learn-telem-item {
    font-size: 8px;
    letter-spacing: 0.8px;
    color: #555;
    white-space: nowrap;
}

.light-mode .learn-telem-item { color: #999; }

.learn-telem-val {
    color: #a1a1aa;
    font-weight: 700;
}

.light-mode .learn-telem-val { color: #a1a1aa; }

.learn-telem-ok {
    color: #a1a1aa;
}

.learn-telem-ver {
    color: #444;
    font-size: 7px;
}

.light-mode .learn-telem-ver { color: #bbb; }

.learn-telem-dot {
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: #333;
    flex-shrink: 0;
}

.light-mode .learn-telem-dot { background: #ccc; }

@media (max-width: 768px) {
    .learn-hero-telemetry { overflow-x: auto; }
}

@media (max-width: 480px) {
    .learn-hero-body { padding: 14px 14px; gap: 12px; }
    .learn-hero-icon-area { width: 44px; height: 44px; }
    .learn-hero-icon { width: 36px; height: 36px; }
    .learn-hero-title { font-size: 15px; }
    .learn-hero-arrow { display: none; }
    .learn-hero-agents { display: none; }
    .learn-hero-telemetry { display: none; }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .learn-hero-orb,
    .learn-hero-pulse,
    .learn-hero-led {
        animation: none !important;
    }
}

/* --- Daily Review Monitor (status monitor aesthetic) --- */
.review-monitor {
    margin-bottom: 16px;
}

.review-monitor-inner {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.25s ease;
}

.review-monitor-inner:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.light-mode .review-monitor-inner {
    background: var(--bg-card);
    border-color: var(--border);
}

.light-mode .review-monitor-inner:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Status strip */
.review-mon-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: linear-gradient(180deg, #22252b 0%, #1a1d21 100%);
    border-bottom: 1px solid #2a2d33;
    font-family: 'Courier New', monospace;
}

.light-mode .review-mon-strip {
    background: linear-gradient(180deg, #d5d7dd 0%, #e8eaed 100%);
    border-bottom-color: #c0c3c8;
}

.review-mon-led {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a1a1aa;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    animation: reviewLedPulse 2s ease infinite;
}

@keyframes reviewLedPulse {
    0%, 80%, 100% { opacity: 1; }
    90% { opacity: 0.3; }
}

.review-mon-sys {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #666;
}

.light-mode .review-mon-sys { color: #888; }

.review-mon-divider {
    width: 1px;
    height: 12px;
    background: #2a2d33;
    margin: 0 4px;
}

.light-mode .review-mon-divider { background: #c0c3c8; }

.review-mon-tag {
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #a1a1aa;
    text-transform: uppercase;
}

.review-mon-spacer { flex: 1; }

.review-section-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 3px;
    background: #a1a1aa;
    color: #0a0b0f;
    font-size: 10px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

/* review-mon body now uses shared .hw-card-body */

/* Bottom status readout */
.review-mon-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 5px;
    border-top: 1px solid #2a2d33;
    background: linear-gradient(0deg, #15171b 0%, #1a1d21 100%);
    font-family: 'Courier New', monospace;
}

.light-mode .review-mon-bottom {
    border-top-color: #c0c3c8;
    background: linear-gradient(0deg, #dddfe3 0%, #e8eaed 100%);
}

.review-mon-stat {
    font-size: 8px;
    letter-spacing: 0.8px;
    color: #555;
    white-space: nowrap;
}

.light-mode .review-mon-stat { color: #999; }

.review-mon-stat-val {
    color: #a1a1aa;
    font-weight: 700;
}

.light-mode .review-mon-stat-val { color: #a1a1aa; }

.review-mon-stat-ok { color: #a1a1aa; }

.review-mon-stat-dim {
    color: #444;
    font-size: 7px;
}

.light-mode .review-mon-stat-dim { color: #bbb; }

.review-mon-stat-dot {
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: #333;
    flex-shrink: 0;
}

.light-mode .review-mon-stat-dot { background: #ccc; }

@media (max-width: 480px) {
    .review-mon-bottom { display: none; }
}

.light-mode .review-section-badge {
    color: #fff;
}

/* --- Virtual Lab Instrument Panel (lab equipment aesthetic) --- */
.vlab-card-row {
    margin-bottom: 16px;
}

.vlab-instrument {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.25s ease;
}

.vlab-instrument:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.light-mode .vlab-instrument {
    background: var(--bg-card);
    border-color: var(--border);
}

.light-mode .vlab-instrument:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Top instrument panel with LEDs and readouts */
.vlab-inst-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 12px;
    background: linear-gradient(180deg, #24272e 0%, #1c1e24 100%);
    border-bottom: 1px solid #2a2d35;
}

.light-mode .vlab-inst-panel {
    background: linear-gradient(180deg, #d5d7dd 0%, #eaebef 100%);
    border-bottom-color: #c0c3c8;
}

.vlab-inst-leds {
    display: flex;
    gap: 4px;
}

.vlab-inst-led {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1px solid #333;
}

.vlab-led-green {
    background: #a1a1aa;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    animation: vlabLedPulse 2s ease infinite;
}

.vlab-led-amber {
    background: #a1a1aa;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.4);
}

.vlab-led-red {
    background: #444;
}

@keyframes vlabLedPulse {
    0%, 80%, 100% { opacity: 1; }
    90% { opacity: 0.4; }
}

.vlab-inst-readout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.vlab-inst-readout-label {
    font-size: 6px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #555;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
}

.vlab-inst-readout-val {
    font-size: 10px;
    font-weight: 700;
    color: #a1a1aa;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.vlab-inst-readout-val small {
    font-size: 7px;
    color: #666;
    text-shadow: none;
}

.light-mode .vlab-inst-readout-label { color: #888; }
.light-mode .vlab-inst-readout-val { color: #a1a1aa; text-shadow: none; }

.vlab-inst-label {
    margin-left: auto;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 2px;
    color: #555;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
}

.light-mode .vlab-inst-label { color: #888; }

/* vlab-inst body now uses shared .hw-card-body */

.vlab-inst-flask-area {
    position: relative;
    color: #a1a1aa;
    overflow: visible;
}

/* Animated bubbles rising out of the flask icon — enhanced visibility */
.vlab-inst-flask-area .vlab-bubble {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
    animation: vlabBubbleRise 2.5s ease-in infinite;
    opacity: 0;
    pointer-events: none;
}

.vlab-b1 { width: 6px; height: 6px; top: 6px;  left: 12px; animation-delay: 0s;   --drift: -4px; }
.vlab-b2 { width: 5px; height: 5px; top: 8px;  left: 28px; animation-delay: 0.5s; --drift: 5px; }
.vlab-b3 { width: 7px; height: 7px; top: 4px;  left: 8px;  animation-delay: 1.0s; --drift: -3px; }
.vlab-b4 { width: 4px; height: 4px; top: 10px; left: 22px; animation-delay: 1.5s; --drift: 6px; }
.vlab-b5 { width: 6px; height: 6px; top: 5px;  left: 34px; animation-delay: 2.0s; --drift: -5px; }

@keyframes vlabBubbleRise {
    0%   { transform: translateY(0) scale(1);   opacity: 0; }
    10%  { opacity: 0.8; }
    40%  { opacity: 0.6; }
    100% { transform: translateY(-30px) scale(0.2) translateX(var(--drift, 0px)); opacity: 0; }
}

.vlab-inst-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.vlab-inst-title {
    font-size: 16px;
    font-weight: 700;
    color: #a1a1aa;
    letter-spacing: 0.5px;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.light-mode .vlab-inst-title {
    color: #a1a1aa;
    text-shadow: none;
}

.vlab-inst-sub {
    font-size: 11px;
    color: #666;
}

.light-mode .vlab-inst-sub { color: #888; }

/* Bottom knobs and gauge */
.vlab-inst-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 12px 7px;
    border-top: 1px solid #2a2d35;
    background: linear-gradient(0deg, #191b20 0%, #1c1e24 100%);
}

.light-mode .vlab-inst-bottom {
    border-top-color: #c0c3c8;
    background: linear-gradient(0deg, #dddfe3 0%, #eaebef 100%);
}

.vlab-inst-knob {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #555, #222);
    border: 1px solid #444;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.light-mode .vlab-inst-knob {
    background: radial-gradient(circle at 40% 35%, #bbb, #888);
    border-color: #999;
}

.vlab-inst-gauge {
    flex: 1;
    max-width: 120px;
    height: 4px;
    background: #222;
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid #333;
}

.light-mode .vlab-inst-gauge {
    background: #ccc;
    border-color: #aaa;
}

.vlab-inst-gauge-fill {
    width: 65%;
    height: 100%;
    background: linear-gradient(90deg, #a1a1aa, #a1a1aa);
    border-radius: 2px;
    animation: vlabGaugePulse 4s ease-in-out infinite;
}

@keyframes vlabGaugePulse {
    0%, 100% { width: 55%; }
    50% { width: 75%; }
}

/* --- GeoRadar Console Card (Furuno radar hardware aesthetic) --- */
.georadar-card-row {
    margin-bottom: 16px;
}

.georadar-console {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.25s ease;
}

.georadar-console:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.light-mode .georadar-console {
    background: var(--bg-card);
    border-color: var(--border);
}

.light-mode .georadar-console:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Hardware button bar */
.georadar-hw-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: linear-gradient(180deg, #22252b 0%, #1a1d21 100%);
    border-bottom: 1px solid #2a2d33;
}

.light-mode .georadar-hw-bar {
    background: linear-gradient(180deg, #d8dae0 0%, #e8eaed 100%);
    border-bottom-color: #c0c3c8;
}

.georadar-hw-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.georadar-hw-led {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #333;
    border: 1px solid #444;
}

.georadar-hw-led.georadar-led-on {
    background: #a1a1aa;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
    animation: georadarLedBlink 3s ease infinite;
}

@keyframes georadarLedBlink {
    0%, 90%, 100% { opacity: 1; }
    95% { opacity: 0.3; }
}

.georadar-hw-label {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #666;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
}

.light-mode .georadar-hw-label { color: #888; }

.georadar-hw-buttons {
    display: flex;
    gap: 4px;
}

.georadar-hw-btn {
    display: inline-block;
    padding: 2px 8px;
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #888;
    background: #15171b;
    border: 1px solid #333;
    border-radius: 3px;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    transition: color 0.2s, border-color 0.2s;
}

.georadar-console:hover .georadar-hw-btn {
    color: #a1a1aa;
    border-color: rgba(255, 255, 255, 0.3);
}

.light-mode .georadar-hw-btn {
    background: #ccc;
    border-color: #aaa;
    color: #666;
}

.light-mode .georadar-console:hover .georadar-hw-btn {
    color: #a1a1aa;
    border-color: rgba(255, 255, 255, 0.4);
}

.georadar-hw-knob {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #555, #222);
    border: 1px solid #444;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.light-mode .georadar-hw-knob {
    background: radial-gradient(circle at 40% 35%, #bbb, #888);
    border-color: #999;
}

/* Mini radar screen */
/* georadar-screen body now uses shared .hw-card-body */

.georadar-screen-inner {
    position: relative;
    width: 120px;
    min-width: 120px;
    height: 60px;
    background: #0a0e14;
    border: 1px solid #1a2a1a;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5), 0 0 8px rgba(255, 255, 255, 0.05);
}

.light-mode .georadar-screen-inner {
    background: #0d1117;
    border-color: #2a3a2a;
}

.georadar-minimap {
    width: 100%;
    height: 100%;
}

.georadar-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.02) 2px, rgba(255, 255, 255, 0.02) 4px);
    pointer-events: none;
}

.georadar-screen-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.georadar-screen-title {
    font-size: 16px;
    font-weight: 700;
    color: #a1a1aa;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.light-mode .georadar-screen-title {
    color: #a1a1aa;
    text-shadow: none;
}

.georadar-screen-sub {
    font-size: 11px;
    color: #666;
}

.light-mode .georadar-screen-sub {
    color: #888;
}

/* Bottom screws */
.georadar-hw-screws {
    display: flex;
    justify-content: space-between;
    padding: 4px 10px 6px;
}

.georadar-screw {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #444, #1a1a1a);
    border: 1px solid #333;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.light-mode .georadar-screw {
    background: radial-gradient(circle at 35% 30%, #aaa, #777);
    border-color: #999;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .georadar-minimap animate,
    .georadar-minimap animateTransform,
    .georadar-hw-led {
        animation: none !important;
    }
}

@media (max-width: 480px) {
    .georadar-screen-inner {
        width: 80px;
        min-width: 80px;
        height: 45px;
    }
    .georadar-hw-buttons {
        gap: 2px;
    }
    .georadar-hw-btn {
        padding: 2px 5px;
        font-size: 6px;
    }
}

/* --- Lock Badge (shown on gated tools for Explorer users) --- */
.hw-lock-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-block;
    padding: 3px 10px;
    font-family: inherit;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    text-transform: uppercase;
}

.light-mode .hw-lock-badge {
    color: #a1a1aa;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.25);
}

/* Hidden when user has Scholar/Sage */
.hw-lock-badge.hw-unlocked {
    display: none;
}

/* --- Shared Hardware Card Body (used by all 4 hero cards) --- */
.hw-card-body {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    position: relative;
    z-index: 1;
}

.hw-card-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    position: relative;
    overflow: visible;
}

.hw-icon-learn { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.hw-icon-review { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.hw-icon-vlab { color: var(--text-secondary); background: rgba(255, 255, 255, 0.04); }
.hw-icon-georadar { color: var(--text-secondary); background: rgba(255, 255, 255, 0.04); }

.light-mode .hw-icon-learn { background: rgba(0, 0, 0, 0.04); }
.light-mode .hw-icon-review { background: rgba(0, 0, 0, 0.04); }
.light-mode .hw-icon-vlab { background: rgba(0, 0, 0, 0.04); }
.light-mode .hw-icon-georadar { background: rgba(0, 0, 0, 0.04); }

/* Pulse ring on icon */
.hw-card-icon-pulse {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 12px;
    border: 1.5px solid currentColor;
    opacity: 0;
    animation: hwIconPulse 3s ease-out infinite;
    pointer-events: none;
}

.hw-pulse-learn { color: rgba(255, 255, 255, 0.4); }
.hw-pulse-review { color: rgba(255, 255, 255, 0.4); }
.hw-pulse-georadar { color: rgba(255, 255, 255, 0.4); }

@keyframes hwIconPulse {
    0% { opacity: 0.5; top: -3px; left: -3px; right: -3px; bottom: -3px; }
    100% { opacity: 0; top: -10px; left: -10px; right: -10px; bottom: -10px; }
}

.hw-card-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

.hw-card-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.hw-title-learn { color: var(--text); }
.hw-title-review { color: var(--text); }
.hw-title-vlab { color: var(--text); }
.hw-title-georadar { color: var(--text); }

.light-mode .hw-title-learn { color: var(--text); }
.light-mode .hw-title-review { color: var(--text); }
.light-mode .hw-title-vlab { color: var(--text); }
.light-mode .hw-title-georadar { color: var(--text); }

.hw-card-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.light-mode .hw-card-sub { color: var(--text); }

/* Bubbles still work on vlab icon */
.hw-icon-vlab .vlab-bubble {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
    animation: vlabBubbleRise 2.5s ease-in infinite;
    opacity: 0;
    pointer-events: none;
}

.hw-icon-vlab .vlab-b1 { width: 4px; height: 4px; top: 4px; left: 10px; animation-delay: 0s; --drift: -3px; }
.hw-icon-vlab .vlab-b2 { width: 3px; height: 3px; top: 6px; left: 22px; animation-delay: 0.7s; --drift: 4px; }
.hw-icon-vlab .vlab-b3 { width: 5px; height: 5px; top: 2px; left: 16px; animation-delay: 1.4s; --drift: -2px; }

@media (max-width: 480px) {
    .hw-card-body { padding: 12px 14px; gap: 12px; }
    .hw-card-icon { width: 40px; height: 40px; }
    .hw-card-title { font-size: 14px; }
}

/* --- ChronoScope Console Card (oscilloscope aesthetic) --- */
.chrono-card-row {
    margin-bottom: 16px;
}

.chrono-console {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.25s ease;
}

.chrono-console:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

.light-mode .chrono-console {
    background: var(--bg-card);
    border-color: var(--border);
}

.light-mode .chrono-console:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* Hardware bar */
.chrono-hw-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: linear-gradient(180deg, #22252b 0%, #1a1d21 100%);
    border-bottom: 1px solid #2a2d33;
}

.light-mode .chrono-hw-bar {
    background: linear-gradient(180deg, #d8dae0 0%, #e8eaed 100%);
    border-bottom-color: #c0c3c8;
}

.chrono-hw-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chrono-hw-led {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a1a1aa;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
    animation: chronoLedBlink 3s ease infinite;
}

@keyframes chronoLedBlink {
    0%, 90%, 100% { opacity: 1; }
    95% { opacity: 0.3; }
}

.chrono-hw-label {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #666;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
}

.light-mode .chrono-hw-label { color: #888; }

.chrono-hw-buttons {
    display: flex;
    gap: 4px;
}

.chrono-hw-btn {
    display: inline-block;
    padding: 2px 8px;
    font-size: 7px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #888;
    background: #15171b;
    border: 1px solid #333;
    border-radius: 3px;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    transition: color 0.2s, border-color 0.2s;
}

.chrono-console:hover .chrono-hw-btn {
    color: #a1a1aa;
    border-color: rgba(255, 255, 255, 0.3);
}

.light-mode .chrono-hw-btn {
    background: #ccc;
    border-color: #aaa;
    color: #666;
}

.light-mode .chrono-console:hover .chrono-hw-btn {
    color: #a1a1aa;
    border-color: rgba(255, 255, 255, 0.4);
}

.chrono-hw-knob {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #555, #222);
    border: 1px solid #444;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.light-mode .chrono-hw-knob {
    background: radial-gradient(circle at 40% 35%, #bbb, #888);
    border-color: #999;
}

/* ChronoScope icon color */
.hw-icon-chrono { color: var(--text-secondary); background: rgba(255, 255, 255, 0.04); }
.light-mode .hw-icon-chrono { background: rgba(0, 0, 0, 0.04); color: var(--text-secondary); }
.hw-title-chrono { color: #a1a1aa; text-shadow: 0 0 8px rgba(255, 255, 255, 0.25); }
.light-mode .hw-title-chrono { color: #a1a1aa; text-shadow: none; }
.hw-pulse-chrono { color: rgba(255, 255, 255, 0.4); }

/* Waveform bar */
.chrono-waveform-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px 6px;
    border-top: 1px solid #2a2d33;
    background: linear-gradient(0deg, #15171b 0%, #1a1d21 100%);
}

.light-mode .chrono-waveform-bar {
    border-top-color: #c0c3c8;
    background: linear-gradient(0deg, #dddfe3 0%, #e8eaed 100%);
}

.chrono-waveform {
    flex: 1;
    height: 16px;
}

.chrono-era-label {
    font-family: 'Courier New', monospace;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #555;
    white-space: nowrap;
}

.light-mode .chrono-era-label { color: #999; }

@media (prefers-reduced-motion: reduce) {
    .chrono-hw-led, .chrono-waveform animate {
        animation: none !important;
    }
}

@media (max-width: 480px) {
    .chrono-hw-buttons { gap: 2px; }
    .chrono-hw-btn { padding: 2px 5px; font-size: 6px; }
}

/* --- Dashboard Section Dividers --- */
.dash-section-divider {
    margin: 40px 0 16px;
}

.dash-section-divider:first-child {
    margin-top: 8px;
}

.dash-section-line {
    height: 1px;
    background: linear-gradient(90deg, var(--border), transparent);
    margin-bottom: 12px;
}

.light-mode .dash-section-line {
    background: linear-gradient(90deg, var(--border), transparent);
}

.dash-section-header {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    flex-wrap: wrap;
}

.dash-section-title {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.light-mode .dash-section-title {
    color: #71717a;
}

.dash-section-desc {
    font-size: 11px;
    color: var(--text-muted, #71717a);
    line-height: 1.4;
}

.light-mode .dash-section-desc {
    color: var(--text);
}

@media (max-width: 480px) {
    .dash-section-header {
        flex-direction: column;
        gap: 2px;
    }
    .dash-section-desc {
        font-size: 10px;
    }
}

/* --- Action Bar --- */
.action-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

/* --- Tools Bar --- */
.tools-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .action-bar {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }
    .tools-bar {
        grid-template-columns: 1fr 1fr;
    }
    .action-hero, .action-card, .vlab-card-row, .review-section {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

@media (max-width: 480px) {
    .tools-bar {
        grid-template-columns: 1fr;
    }
}

.action-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

/* Left accent borders removed for clean look */

/* Bottom neon line removed */
.action-card::after {
    display: none;
}

.action-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border-color: var(--border-hover);
    background: var(--bg-elevated);
}

.action-card-learn .action-card-icon {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.action-card-diagram .action-card-icon {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

/* --- Tool card accents (all B&W) --- */
.action-card-calc .action-card-icon,
.action-card-flashcards .action-card-icon,
.action-card-formulas .action-card-icon,
.action-card-converter .action-card-icon,
.action-card-graphing .action-card-icon,
.action-card-pomodoro .action-card-icon,
.action-card-ptable .action-card-icon {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.action-card-review .action-card-icon {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
}

.action-card-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .vlab-bubble {
        animation: none !important;
    }
}

/* Icon styling */
.action-card .action-card-icon {
    flex-shrink: 0;
}

.action-card-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.action-card-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text);
}

.action-card-subtitle {
    font-size: 0.7rem;
    color: var(--text);
}

.light-mode .action-card {
    background: var(--bg-card);
    border-color: var(--border);
}

.light-mode .action-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.light-mode .action-card-learn .action-card-icon,
.light-mode .action-card-diagram .action-card-icon,
.light-mode .action-card-review .action-card-icon {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text);
}

.light-mode .action-card-review .action-card-icon {
    background: rgba(255, 255, 255, 0.08);
}

/* --- Pulse Dot --- */
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neon-amber);
    animation: neonPulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes neonPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--neon-amber-glow); }
    50% { opacity: 0.7; box-shadow: 0 0 12px var(--neon-amber), 0 0 24px var(--neon-amber-glow); }
}

/* --- Card Premium --- */
.card-premium {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Top gradient accent -- always visible */
.card-premium::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    border-radius: 2px;
}

/* Knowledge Map card: emerald accent with color-shift animation */
#knowledge-map-card::before {
    background: linear-gradient(90deg, transparent, var(--neon-emerald), #a1a1aa, var(--neon-emerald), transparent);
    background-size: 200% 100%;
    animation: accentShift 6s ease-in-out infinite;
    box-shadow: 0 0 10px var(--neon-emerald-glow);
}


@keyframes accentShift {
    0%, 100% { background-position: 0% 0; }
    50% { background-position: 100% 0; }
}

.card-premium:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Dot marker before card titles */
.card-premium .card-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

#knowledge-map-card .card-title::before {
    background: var(--neon-emerald);
    box-shadow: 0 0 6px var(--neon-emerald-glow);
}


.card-premium .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0;
    border: none;
}

.card-premium .card-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.light-mode .card-premium {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

.light-mode #knowledge-map-card::before {
    box-shadow: 0 0 6px var(--neon-emerald-glow);
}


/* --- Knowledge Map --- */
.knowledge-map {
    min-height: 60px;
}

.knowledge-map-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--text-muted, #888);
    text-align: center;
}

.knowledge-map-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar-container {
    width: 120px;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #a1a1aa, var(--neon-emerald));
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 6px var(--neon-emerald-glow);
}

.progress-bar-label {
    font-size: 12px;
    color: var(--text-muted, #888);
    white-space: nowrap;
}

.light-mode .progress-bar-container {
    background: rgba(0, 0, 0, 0.06);
}

.knowledge-map-category {
    margin-bottom: 16px;
}

.knowledge-map-category:last-child {
    margin-bottom: 0;
}

.knowledge-map-category-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #888);
    margin-bottom: 8px;
    padding-left: 2px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.knowledge-map-category-header:hover {
    color: var(--text-secondary, #aaa);
}

.km-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.knowledge-map-category.collapsed .km-chevron {
    transform: rotate(-90deg);
}

.km-count {
    font-weight: 400;
    opacity: 0.6;
}

.knowledge-map-tiles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 600px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.knowledge-map-category.collapsed .knowledge-map-tiles {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

/* Formative insights collapsible */
.fi-section-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fi-section-header:hover {
    opacity: 0.8;
}

.fi-chevron {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.fi-section.collapsed .fi-chevron {
    transform: rotate(-90deg);
}

.fi-section-content {
    max-height: 600px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
}

.fi-section.collapsed .fi-section-content {
    max-height: 0;
    opacity: 0;
}

.fi-section-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 12px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fi-title {
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    margin: 0;
}

.fi-count {
    font-size: 0.75rem;
    opacity: 0.7;
    text-transform: none;
    letter-spacing: 0;
}

.fi-review-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fi-review-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    min-width: 140px;
    flex: 0 1 auto;
}

.fi-review-concept {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.fi-progress {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fi-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 2px;
    overflow: hidden;
}

.fi-progress-fill {
    height: 100%;
    background: var(--warning, #a1a1aa);
    border-radius: 2px;
}

.fi-progress-pct {
    font-size: 0.7rem;
    color: var(--text-muted);
    min-width: 28px;
    text-align: right;
}

.fi-more {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.fi-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fi-item {
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.fi-item:last-child {
    border-bottom: none;
}

.fi-item strong {
    color: var(--text);
}

.fi-item-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.fi-title-breakthrough {
    color: #a1a1aa;
}

@media (max-width: 480px) {
    .fi-review-card {
        min-width: 120px;
        flex: 1 1 45%;
    }
}

.concept-tile {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s ease;
    max-width: 180px;
    overflow: hidden;
}

.concept-tile-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile-new {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted, #888);
    border: 1px solid transparent;
}

.tile-new:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.tile-learning {
    background: rgba(255, 255, 255, 0.08);
    color: var(--neon-amber);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.tile-learning:hover {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 10px var(--neon-amber-glow);
}

.tile-mastered {
    background: rgba(255, 255, 255, 0.08);
    color: var(--neon-emerald);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.tile-mastered:hover {
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 10px var(--neon-emerald-glow);
}

.tile-due {
    border-color: #a1a1aa;
    animation: tileDuePulse 2s ease-in-out infinite;
}

@keyframes tileDuePulse {
    0%, 100% { box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0.2); }
    50% { box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.3), 0 0 6px rgba(255, 255, 255, 0.15); }
}

.light-mode .tile-new {
    background: rgba(0, 0, 0, 0.04);
}

.light-mode .tile-learning {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.light-mode .tile-mastered {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}



.review-badge-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.12);
    color: var(--neon-indigo);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.15);
    animation: badge-pop 0.4s ease;
}

/* --- Ghost Button (override) --- */
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-ghost:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.light-mode .btn-ghost {
    border-color: var(--border);
}

.light-mode .btn-ghost:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .action-bar {
        grid-template-columns: 1fr;
    }

    .tools-bar {
        grid-template-columns: 1fr;
    }

    .knowledge-map-progress {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ========================================
   Session End Loading Overlay
   ======================================== */

.session-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    background: var(--bg);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.session-loading-overlay.active {
    opacity: 1;
}

/* Animated concentric rings */
.session-end-anim {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.session-end-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top-color: var(--primary, #a1a1aa);
    animation: session-ring-spin 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.session-end-ring-2 {
    inset: 10px;
    border-top-color: transparent;
    border-right-color: var(--primary, #a1a1aa);
    opacity: 0.5;
    animation-duration: 2.2s;
    animation-direction: reverse;
}

.session-end-ring-3 {
    inset: 20px;
    border-top-color: transparent;
    border-bottom-color: var(--primary, #a1a1aa);
    opacity: 0.25;
    animation-duration: 3s;
}

@keyframes session-ring-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.session-end-icon {
    color: var(--primary, #a1a1aa);
    opacity: 0.9;
    animation: session-icon-pulse 2s ease-in-out infinite;
}

@keyframes session-icon-pulse {
    0%, 100% { opacity: 0.9; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.92); }
}

/* Text group */
.session-end-text-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.session-loading-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.session-loading-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.session-loading-dots::after {
    content: '';
    animation: session-dots 1.5s steps(4, end) infinite;
}

@keyframes session-dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* ========================================
   Session Summary Modal
   ======================================== */

.session-summary {
    font-size: 0.92rem;
    line-height: 1.6;
}

.session-summary-overview {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.session-summary-section {
    margin-bottom: 14px;
}

.session-summary-section h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.session-summary-section ul {
    margin: 0;
    padding-left: 18px;
}

.session-summary-section li {
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.session-summary-concepts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.session-summary-concept {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: var(--radius-md, 8px);
    background: var(--bg-elevated);
}

.session-summary-concept-name {
    font-weight: 500;
    color: var(--text);
}

.session-summary-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: var(--radius-full, 999px);
}

.session-summary-badge.mastery-solid {
    background: rgba(255, 255, 255, 0.15);
    color: #a1a1aa;
}

.session-summary-badge.mastery-developing {
    background: rgba(255, 255, 255, 0.15);
    color: #a1a1aa;
}

.session-summary-badge.mastery-review {
    background: rgba(255, 255, 255, 0.15);
    color: #a1a1aa;
}

/* ========================================
   Pedagogical Analytics
   ======================================== */

.ped-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.ped-section {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.ped-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

.ped-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.ped-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.ped-bar-fill.blooms {
    background: linear-gradient(90deg, #a1a1aa, #a1a1aa);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.ped-bar-fill.visual {
    background: linear-gradient(90deg, #a1a1aa, #a1a1aa);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.ped-bar-fill.auditory {
    background: linear-gradient(90deg, #a1a1aa, #a1a1aa);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.ped-bar-fill.reading {
    background: linear-gradient(90deg, #a1a1aa, #a1a1aa);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.ped-bar-fill.kinesthetic {
    background: linear-gradient(90deg, #a1a1aa, #a1a1aa);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.ped-bar-fill.metacog {
    background: linear-gradient(90deg, #a1a1aa, #a1a1aa);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.ped-bar-fill.mindset {
    background: linear-gradient(90deg, #a1a1aa, #a1a1aa);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

.ped-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full, 999px);
}

.ped-badge.remembering { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }
.ped-badge.understanding { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }
.ped-badge.applying { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }
.ped-badge.analyzing { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }
.ped-badge.evaluating { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }
.ped-badge.creating { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }

.ped-badge.visual { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }
.ped-badge.auditory { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }
.ped-badge.reading { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }
.ped-badge.kinesthetic { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }
.ped-badge.balanced { background: rgba(255, 255, 255, 0.2); color: #a1a1aa; }

.zpd-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.zpd-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.zpd-dot.below { background: #a1a1aa; }
.zpd-dot.zpd { background: #a1a1aa; }
.zpd-dot.above { background: #a1a1aa; }

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

/* ===== Quiz Mode Selector ===== */

.ifl-quiz-mode-select {
    padding: 12px 0;
}

.ifl-quiz-mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.ifl-quiz-mode-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.ifl-quiz-mode-close:hover {
    color: var(--text);
}

.ifl-quiz-mode-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.ifl-quiz-mode-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    text-align: center;
}

.ifl-quiz-mode-card:hover {
    border-color: var(--primary);
    background: var(--primary-muted);
    color: var(--text);
    transform: translateY(-2px);
}

.ifl-quiz-mode-card svg {
    color: var(--primary);
}

.mode-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.mode-card-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
}

.ifl-quiz-adaptive-msg {
    padding: 10px 14px;
    margin-top: 8px;
    background: var(--primary-muted);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
}

.ifl-quiz-next-round {
    display: inline-block;
    padding: 8px 20px;
    background: var(--primary);
    color: var(--primary-fg);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    margin-top: 8px;
    transition: background 0.2s;
}

.ifl-quiz-next-round:hover {
    background: var(--primary-hover);
}

@media (max-width: 480px) {
    .ifl-quiz-mode-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Agent Status Panel (Chat Toolbar) ===== */

.agent-status-panel {
    margin-left: auto;
    flex-shrink: 0;
    text-align: right;
}

.agent-panel-title {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.agent-panel-row {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    line-height: 1.4;
}

.agent-label {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    opacity: 0.35;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.agent-label.active {
    opacity: 1;
    font-weight: 700;
    animation: agent-text-pulse 1.5s ease-in-out infinite;
}

.agent-label.done {
    opacity: 0.9;
    font-weight: 600;
}

@keyframes agent-text-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

/* ===== Onboarding Tour ===== */

/* Tour — intentionally theme-independent (monochrome) so it stands apart
   from the page and always has predictable contrast. Dark by default,
   flips to light under html.light-mode. No --primary references. */

.tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
}

.tour-spotlight {
    position: fixed;
    z-index: 10002;
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.78);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.tour-tooltip {
    position: fixed;
    z-index: 10003;
    background: #0d0d0f;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 22px 26px;
    max-width: 400px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    animation: tourFadeIn 0.3s ease;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.tour-tooltip-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    margin-bottom: 14px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.tour-tooltip-body::-webkit-scrollbar { width: 6px; }
.tour-tooltip-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.tour-tooltip h3 {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #ffffff;
}

.tour-tooltip p {
    font-size: 13.5px;
    line-height: 1.65;
    color: #b5b5b8;
    margin-bottom: 0;
}

.tour-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.tour-progress {
    font-size: 11px;
    color: #888;
}

.tour-progress-dots {
    display: flex;
    gap: 5px;
    width: 100%;
    margin-bottom: 10px;
}

.tour-dot {
    width: 100%;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.25s ease;
}

.tour-dot-active {
    background: #ffffff;
}

.tour-btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}

.tour-btn-primary {
    background: #ffffff;
    color: #000000;
}

.tour-btn-primary:hover {
    background: #e5e5e5;
}

.tour-btn-secondary {
    background: transparent;
    color: #888;
}

.tour-btn-secondary:hover {
    color: #ffffff;
}

.tour-welcome {
    text-align: center;
}

.tour-welcome h3 {
    font-size: 22px;
    margin-bottom: 12px;
}

.tour-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: #888;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

.tour-close:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
}

.tour-nav-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.tour-progress-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 10px;
}

.tour-progress-bar-fill {
    height: 100%;
    background: #ffffff;
    border-radius: 2px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light-mode variant — flips to a white tooltip with black text & accents */
:root.light-mode .tour-tooltip {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

:root.light-mode .tour-tooltip h3 { color: #000000; }
:root.light-mode .tour-tooltip p { color: #555; }
:root.light-mode .tour-progress { color: #666; }
:root.light-mode .tour-dot { background: rgba(0, 0, 0, 0.15); }
:root.light-mode .tour-dot-active { background: #000000; }
:root.light-mode .tour-progress-bar { background: rgba(0, 0, 0, 0.12); }
:root.light-mode .tour-progress-bar-fill { background: #000000; }
:root.light-mode .tour-btn-primary { background: #000000; color: #ffffff; }
:root.light-mode .tour-btn-primary:hover { background: #2a2a2a; }
:root.light-mode .tour-btn-secondary { color: #666; }
:root.light-mode .tour-btn-secondary:hover { color: #000000; }
:root.light-mode .tour-close { color: #666; }
:root.light-mode .tour-close:hover { color: #000000; background: rgba(0, 0, 0, 0.05); }
:root.light-mode .tour-tooltip-body {
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}
:root.light-mode .tour-tooltip-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .tour-tooltip {
        padding: 18px 20px 16px;
        border-radius: 12px;
    }
    .tour-tooltip h3 {
        font-size: 15.5px;
        padding-right: 28px;
    }
    .tour-tooltip p {
        font-size: 13px;
        line-height: 1.55;
        margin-bottom: 14px;
    }
    .tour-btn {
        padding: 9px 16px;
        font-size: 13px;
    }
    .tour-welcome h3 {
        font-size: 19px;
    }
}

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

/* ===== Agent Showcase Card (Dashboard) ===== */

.agents-strip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-top: 16px;
    overflow: hidden;
}

.agents-strip-label {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.agents-strip-list {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.agents-strip-list::-webkit-scrollbar {
    display: none;
}

.agents-strip-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.agents-strip-item svg {
    opacity: 0.6;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .agents-strip {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    .agents-strip-list {
        width: 100%;
    }
    .agent-status-panel {
        display: none;
    }
}

/* ========================================================================
   EXERCISE UI - Right panel tab system + quiz interface
   ======================================================================== */

.right-panel-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary, #1a1a2e);
    padding: 0 12px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.rp-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted, #8a8fa1);
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.rp-tab:hover {
    color: var(--text, #e0e0e0);
}

.rp-tab.active {
    color: var(--primary, #4ecdc4);
    border-bottom-color: var(--primary, #4ecdc4);
}

/* When tabs are present, offset content below them */
.chat-panel-right.has-rp-tabs .mindmap-canvas {
    top: 38px;
}

.chat-panel-right.has-rp-tabs .mindmap-info {
    bottom: 16px;
}

/* Exercises container */
.exercises-container {
    position: absolute;
    top: 38px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.exercise-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-muted, #8a8fa1);
}

.exercise-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted, #8a8fa1);
    font-size: 14px;
}

/* ============================================
   KaTeX FIX: Hide aria-hidden duplicate content
   KaTeX renders both MathML (for accessibility) and HTML (for display).
   The katex-html block has aria-hidden="true" but this only hides from
   screen readers — not visually. KaTeX's own CSS handles this, but if
   the elements are inside tables or other containers, the rule can be
   overridden. This ensures it's always hidden.
   ============================================ */
.katex-html[aria-hidden="true"] {
    /* KaTeX CSS should handle this, but force it as backup */
}
.katex-mathml {
    /* MathML is the accessible version — visually hidden by KaTeX CSS */
    /* Force hide if KaTeX CSS fails to load */
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px) !important;
    padding: 0 !important;
    border: 0 !important;
    height: 1px !important;
    width: 1px !important;
    overflow: hidden !important;
}

/* ============================================
   POST-STREAM PROCESSING INDICATOR
   ============================================ */

.post-stream-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 8px 0;
    border-radius: 8px;
    background: var(--bg-tertiary, rgba(255,255,255,0.03));
    animation: psi-appear 0.3s ease-out;
}

.post-stream-indicator.psi-fade-out {
    animation: psi-disappear 0.3s ease-out forwards;
}

.psi-dots {
    display: flex;
    align-items: center;
    gap: 0;
}

.psi-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-primary, #6e8efb);
    animation: psi-pulse 1.5s ease-in-out infinite;
}

.psi-dot:nth-child(1) { animation-delay: 0s; }
.psi-dot:nth-child(3) { animation-delay: 0.3s; }
.psi-dot:nth-child(5) { animation-delay: 0.6s; }

.psi-line {
    width: 12px;
    height: 2px;
    background: var(--accent-primary, #6e8efb);
    opacity: 0.3;
    animation: psi-connect 1.5s ease-in-out infinite;
}

.psi-line:nth-child(2) { animation-delay: 0.15s; }
.psi-line:nth-child(4) { animation-delay: 0.45s; }

.psi-text {
    font-size: 12px;
    color: var(--text-muted, #8a8fa1);
    transition: opacity 0.3s;
}

@keyframes psi-pulse {
    0%, 100% { opacity: 0.6; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.3); }
}

@keyframes psi-connect {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

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

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

/* ============================================
   SYLLABUS VIEWER
   ============================================ */

.syllabus-container {
    position: absolute;
    top: 38px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.syllabus-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-muted, #8a8fa1);
}

.syllabus-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted, #8a8fa1);
    font-size: 14px;
}

.syllabus-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.syllabus-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.syllabus-section-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent-primary, #6e8efb);
    margin: 0;
}

.syllabus-intro {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary, #e4e6eb);
    margin: 0;
}

.syllabus-concepts {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.syllabus-concepts li {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary, #b0b3b8);
    padding: 10px 14px;
    background: var(--bg-tertiary, rgba(255,255,255,0.03));
    border-left: 3px solid var(--accent-primary, #6e8efb);
    border-radius: 4px;
}

.syllabus-facts {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.syllabus-facts li {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary, #b0b3b8);
    padding: 10px 14px;
    background: var(--bg-tertiary, rgba(255,255,255,0.03));
    border-left: 3px solid #52c97e;
    border-radius: 4px;
}

.syllabus-misconceptions {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.syllabus-misconceptions li {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary, #b0b3b8);
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid #f0a800;
    border-radius: 4px;
}

.syllabus-examples {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.syllabus-examples li {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary, #b0b3b8);
    padding: 12px 14px;
    background: var(--bg-tertiary, rgba(255,255,255,0.03));
    border-left: 3px solid #a1a1aa;
    border-radius: 4px;
}

.syllabus-realworld {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.syllabus-realworld li {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary, #b0b3b8);
    padding: 10px 14px;
    background: var(--bg-tertiary, rgba(255,255,255,0.03));
    border-left: 3px solid #38bdf8;
    border-radius: 4px;
}

.syllabus-formulas {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.syllabus-formulas li {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary, #b0b3b8);
    padding: 8px 14px;
    background: var(--bg-tertiary, rgba(255,255,255,0.03));
    border-radius: 4px;
}

.syllabus-formulas code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    color: #a1a1aa;
    background: transparent;
}

/* ============================================
   EXERCISES (legacy, kept for reference)
   ============================================ */

/* Header: progress + difficulty filter */
.exercise-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.exercise-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 120px;
}

.exercise-progress-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #e0e0e0);
    white-space: nowrap;
}

.exercise-progress-bar-bg {
    flex: 1;
    height: 4px;
    background: var(--bg-tertiary, #2a2a3e);
    border-radius: 2px;
    overflow: hidden;
}

.exercise-progress-bar-fill {
    height: 100%;
    background: var(--primary, #4ecdc4);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.exercise-difficulty-filter {
    display: flex;
    gap: 4px;
}

.ex-diff-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted, #8a8fa1);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
}

.ex-diff-btn:hover {
    color: var(--warning, #a1a1aa);
    background: var(--bg-tertiary, #2a2a3e);
}

.ex-diff-btn.active {
    color: var(--warning, #a1a1aa);
    background: var(--bg-tertiary, #2a2a3e);
    border-color: var(--warning, #a1a1aa);
}

/* Exercise card */
.exercise-card {
    background: var(--bg-elevated, #1e1e32);
    border: 1px solid var(--border, #2d2d44);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.exercise-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.exercise-type-badge {
    background: var(--bg-tertiary, #2a2a3e);
    color: var(--text-muted, #8a8fa1);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.exercise-diff-stars {
    color: var(--warning, #a1a1aa);
    font-size: 13px;
    letter-spacing: 1px;
}

.exercise-question {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text, #e0e0e0);
}

.exercise-question p {
    margin: 0 0 8px;
}

/* Answer inputs */
.exercise-answer-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.exercise-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exercise-option {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--bg-tertiary, #2a2a3e);
    border: 1px solid var(--border, #2d2d44);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text, #e0e0e0);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    line-height: 1.5;
}

.exercise-option:hover {
    border-color: var(--primary, #4ecdc4);
    background: rgba(255, 255, 255, 0.05);
}

.exercise-option.selected {
    border-color: var(--primary, #4ecdc4);
    background: rgba(255, 255, 255, 0.1);
}

.exercise-option.correct {
    border-color: #a1a1aa;
    background: rgba(255, 255, 255, 0.1);
}

.exercise-option.incorrect {
    border-color: #a1a1aa;
    background: rgba(255, 255, 255, 0.1);
}

.exercise-tf-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.exercise-tf-btn {
    text-align: center;
    font-weight: 600;
    padding: 14px 16px;
}

.exercise-input {
    background: var(--bg-tertiary, #2a2a3e);
    border: 1px solid var(--border, #2d2d44);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text, #e0e0e0);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.exercise-input:focus {
    border-color: var(--primary, #4ecdc4);
}

.exercise-textarea {
    background: var(--bg-tertiary, #2a2a3e);
    border: 1px solid var(--border, #2d2d44);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text, #e0e0e0);
    font-size: 14px;
    resize: vertical;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.exercise-textarea:focus {
    border-color: var(--primary, #4ecdc4);
}

/* Buttons */
.exercise-btn {
    background: var(--primary, #4ecdc4);
    color: #111;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    align-self: flex-start;
}

.exercise-btn:hover {
    opacity: 0.9;
}

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

.exercise-btn-secondary {
    background: var(--bg-tertiary, #2a2a3e);
    color: var(--text, #e0e0e0);
    border: 1px solid var(--border, #2d2d44);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.exercise-btn-secondary:hover {
    border-color: var(--primary, #4ecdc4);
    background: rgba(255, 255, 255, 0.05);
}

.exercise-btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Result display */
.exercise-result {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border, #2d2d44);
}

.exercise-result.correct {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

.exercise-result.incorrect {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
}

.exercise-result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.exercise-result.correct .exercise-result-icon {
    color: #a1a1aa;
    font-size: 20px;
}

.exercise-result.incorrect .exercise-result-icon {
    color: #a1a1aa;
    font-size: 20px;
}

.exercise-result.correct .exercise-result-label {
    color: #a1a1aa;
}

.exercise-result.incorrect .exercise-result-label {
    color: #a1a1aa;
}

.exercise-correct-answer {
    font-size: 14px;
    color: var(--text, #e0e0e0);
    line-height: 1.5;
}

.exercise-explanation {
    font-size: 13px;
    color: var(--text-muted, #8a8fa1);
    line-height: 1.6;
    border-top: 1px solid var(--border, #2d2d44);
    padding-top: 10px;
}

/* AI Explain */
.exercise-ai-btn {
    display: flex;
    align-items: center;
    gap: 6px;
}

.exercise-ai-cost {
    font-size: 11px;
    color: var(--text-muted, #8a8fa1);
    font-weight: 400;
}

.exercise-ai-explanation {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 14px;
}

.exercise-ai-label {
    font-size: 12px;
    font-weight: 600;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.exercise-ai-content {
    font-size: 14px;
    color: var(--text, #e0e0e0);
    line-height: 1.6;
}

/* Hints */
.exercise-hints {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exercise-hint {
    background: var(--bg-tertiary, #2a2a3e);
    border-left: 3px solid var(--warning, #a1a1aa);
    border-radius: 0 8px 8px 0;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text, #e0e0e0);
    line-height: 1.5;
}

.exercise-hint-num {
    font-weight: 600;
    color: var(--warning, #a1a1aa);
}

/* Navigation */
.exercise-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-top: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .exercises-container {
        padding: 12px;
    }
    .exercise-card {
        padding: 16px;
    }
    .exercise-question {
        font-size: 14px;
    }
    .exercise-header {
        flex-direction: column;
        align-items: stretch;
    }
    .exercise-tf-buttons {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   CONNECTION LOST BANNER
   ============================================================================ */
.connection-lost-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: #a1a1aa;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}
.connection-lost-banner.visible {
    transform: translateY(0);
}
.connection-lost-banner svg {
    flex-shrink: 0;
}

/* Session modal mobile fixes */
.new-session-modal {
    padding: 24px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.new-session-footer {
    position: sticky;
    bottom: 0;
    padding: 12px 0 0;
    background: var(--bg, #1a1b26);
    margin-top: auto;
    z-index: 1;
}

.new-session-footer .btn-primary {
    width: 100%;
    padding: 14px 24px;
    min-height: 48px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    background: var(--text);
    color: var(--bg);
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.01em;
}

.new-session-footer .btn-primary:hover {
    opacity: 0.85;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.new-session-footer .btn-primary:active {
    transform: translateY(0);
}

/* Mobile tab bar: hidden on desktop */
.mobile-tab-bar {
    display: none;
}

/* Mobile menu overlay: hidden on desktop */
.mobile-menu-overlay {
    display: none;
}

/* ============================================================================
   MOBILE MINDMAP TREE
   Vertical collapsible tree view replacing SVG radial mindmap on small screens.
   ============================================================================ */

@media (max-width: 768px) {
    .mm-container {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: var(--bg-primary, #0f0f23);
        z-index: 2;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .mm-search {
        position: sticky;
        top: 0;
        z-index: 3;
        padding: 8px 12px;
        background: var(--bg-primary, #0f0f23);
        border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
    }

    .mm-search-input {
        width: 100%;
        padding: 10px 14px;
        border-radius: 8px;
        border: 1px solid var(--border-color, rgba(255,255,255,0.12));
        background: var(--bg-secondary, #1a1a2e);
        color: var(--text-primary, #e0e0e0);
        font-size: 14px;
        font-family: inherit;
        outline: none;
        box-sizing: border-box;
    }

    .mm-search-input::placeholder {
        color: var(--text-muted, #888);
    }

    .mm-search-input:focus {
        border-color: var(--primary, #a1a1aa);
        box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
    }

    /* Legend bar */
    .mm-legend {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        padding: 6px 12px 8px;
        font-size: 11px;
        color: var(--text-muted, #888);
        border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
    }

    .mm-legend-item {
        display: flex;
        align-items: center;
        gap: 4px;
        white-space: nowrap;
    }

    /* Tree */
    .mm-tree {
        flex: 1;
        padding: 4px 0;
    }

    .mm-node {
        user-select: none;
        -webkit-user-select: none;
    }

    .mm-node-row {
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 44px;
        padding-right: 12px;
        cursor: pointer;
        transition: background 0.15s;
    }

    .mm-node-row:active {
        background: var(--bg-hover, rgba(255,255,255,0.04));
    }

    /* Chevron */
    .mm-chevron {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 20px;
        height: 20px;
        font-size: 18px;
        font-weight: bold;
        color: var(--text-muted, #888);
        transition: transform 0.2s ease;
        transform: rotate(0deg);
        flex-shrink: 0;
    }

    .mm-chevron.expanded {
        transform: rotate(90deg);
    }

    .mm-chevron-spacer {
        display: inline-block;
        width: 20px;
        flex-shrink: 0;
    }

    /* State dot */
    .mm-dot {
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .mm-dot-new { background: #a1a1aa; }
    .mm-dot-learning { background: #a1a1aa; }
    .mm-dot-reviewing { background: #a1a1aa; }
    .mm-dot-mastered { background: #a1a1aa; }

    /* Label */
    .mm-label {
        flex: 1;
        font-size: 14px;
        color: var(--text-primary, #e0e0e0);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        line-height: 1.3;
    }

    .mm-count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 18px;
        height: 18px;
        padding: 0 5px;
        border-radius: 9px;
        background: var(--bg-tertiary, rgba(255,255,255,0.08));
        color: var(--text-muted, #888);
        font-size: 11px;
        font-weight: 600;
        margin-left: 4px;
    }

    /* Actions button (three dots) */
    .mm-actions-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        font-size: 18px;
        font-weight: bold;
        letter-spacing: 1px;
        color: var(--text-muted, #888);
        border-radius: 6px;
        flex-shrink: 0;
        cursor: pointer;
        transition: background 0.15s;
    }

    .mm-actions-btn:active {
        background: var(--bg-hover, rgba(255,255,255,0.08));
    }

    /* Children container */
    .mm-children {
        /* no additional styling needed; indent handled by padding-left */
    }

    /* Empty state */
    .mm-empty {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 40px 24px;
        text-align: center;
        color: var(--text-muted, #888);
        font-size: 14px;
        line-height: 1.5;
    }

    /* ---- Action Sheet (bottom overlay) ---- */
    .mm-action-overlay {
        position: fixed;
        inset: 0;
        z-index: 9999;
        background: rgba(0, 0, 0, 0);
        display: flex;
        align-items: flex-end;
        justify-content: center;
        transition: background 0.25s ease;
    }

    .mm-action-overlay.visible {
        background: rgba(0, 0, 0, 0.5);
    }

    .mm-action-sheet {
        width: 100%;
        max-width: 500px;
        background: var(--bg-secondary, #1a1a2e);
        border-radius: 16px 16px 0 0;
        padding: 8px 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        transform: translateY(100%);
        transition: transform 0.25s ease;
    }

    .mm-action-sheet.visible {
        transform: translateY(0);
    }

    .mm-action-sheet-header {
        text-align: center;
        padding: 12px 8px 8px;
        font-size: 15px;
        font-weight: 600;
        color: var(--text-primary, #e0e0e0);
        border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.08));
        margin-bottom: 4px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mm-action-btn {
        display: block;
        width: 100%;
        padding: 14px 16px;
        background: none;
        border: none;
        font-size: 15px;
        font-family: inherit;
        color: var(--text-primary, #e0e0e0);
        text-align: left;
        cursor: pointer;
        border-radius: 8px;
        transition: background 0.15s;
    }

    .mm-action-btn:active {
        background: var(--bg-hover, rgba(255,255,255,0.06));
    }

    .mm-action-danger {
        color: #a1a1aa;
    }

    .mm-action-cancel {
        color: var(--text-muted, #888);
        text-align: center;
        margin-top: 4px;
        border-top: 1px solid var(--border-color, rgba(255,255,255,0.08));
    }
}

/* Light mode overrides for mobile mindmap */
:root.light-mode .mm-container {
    background: var(--bg-primary, #ffffff);
}

:root.light-mode .mm-search {
    background: var(--bg-primary, #ffffff);
}

:root.light-mode .mm-search-input {
    background: var(--bg-secondary, #f5f5f5);
    color: var(--text-primary, #1a1a1a);
    border-color: var(--border-color, #e0e0e0);
}

:root.light-mode .mm-action-sheet {
    background: var(--bg-secondary, #f5f5f5);
}

:root.light-mode .mm-action-btn {
    color: var(--text-primary, #1a1a1a);
}

:root.light-mode .mm-action-danger {
    color: #DC2626;
}

/* ============================================
   MOBILE PHONE FIX (360-480px)
   Must be LAST to override all other breakpoints
   ============================================ */

@media (max-width: 480px) {
    /* ---- Chat panel split: show chat fullscreen, mindmap behind toggle ---- */
    .chat-panel-left {
        height: 100% !important;
    }

    .chat-panel-right {
        height: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
        border: none !important;
    }

    /* When user toggles to mindmap-only view */
    .chat-fullscreen-body[data-panel-view="mindmap-only"] .chat-panel-left {
        height: 0 !important;
        overflow: hidden !important;
    }

    .chat-fullscreen-body[data-panel-view="mindmap-only"] .chat-panel-right {
        height: 100% !important;
        overflow: visible !important;
    }

    /* Panel toggle FAB — make it more visible on mobile */
    .panel-view-toggle {
        bottom: 70px !important;
        right: 12px !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 18px !important;
    }

    /* ---- Header: hide branding text, keep logo + close ---- */
    .chat-fullscreen-product {
        display: none !important;
    }

    .chat-fullscreen-session {
        font-size: 0.6rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chat-fullscreen-header-right {
        gap: 6px !important;
    }

    /* ---- Stats grid: single column on small phones ---- */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .stat-card {
        padding: 10px !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 10px !important;
    }

    .stat-value {
        font-size: 1.2rem !important;
    }

    .stat-label {
        font-size: 0.7rem !important;
    }

    /* ---- Channel tabs: horizontal scroll ---- */
    .channel-tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .channel-tabs::-webkit-scrollbar {
        display: none;
    }

    .channel-tab {
        flex-shrink: 0 !important;
        font-size: 11px !important;
        padding: 5px 8px !important;
    }

    /* ---- Session items: compact on mobile ---- */
    .session-item {
        padding: 10px 12px !important;
        margin: 4px 4px !important;
    }

    .session-item-title {
        font-size: 13px !important;
    }

    .session-item-meta {
        font-size: 11px !important;
    }

    /* ---- Action cards: compact ---- */
    .action-card {
        padding: 14px 16px !important;
        gap: 12px !important;
    }

    .action-card-icon {
        width: 36px !important;
        height: 36px !important;
    }

    /* ---- Mindmap toolbar: reposition for mobile ---- */
    .mindmap-toolbar {
        left: 8px !important;
        bottom: 8px !important;
        gap: 4px !important;
    }

    .mindmap-toolbar button {
        padding: 6px !important;
        font-size: 11px !important;
    }

    /* ---- Chat form: fix layout on narrow phones ---- */
    .chat-form {
        padding: 8px !important;
        gap: 6px !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: flex-end !important;
    }

    .chat-draw-toggle {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        flex-shrink: 0 !important;
        padding: 6px !important;
    }

    .chat-input-field {
        flex: 1 !important;
        min-width: 0 !important;
        min-height: 36px !important;
        padding: 8px 10px !important;
        font-size: 16px !important;
    }

    .chat-submit-btn {
        padding: 8px 12px !important;
        font-size: 12px !important;
        flex-shrink: 0 !important;
        min-width: auto !important;
        white-space: nowrap !important;
    }

    /* AI disclaimer: smaller on mobile */
    .ai-disclaimer {
        padding: 2px 8px 4px !important;
        font-size: 0.6rem !important;
    }

    /* Chat help buttons row: scroll horizontally */
    .chat-help-bar, .chat-actions-row {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        scrollbar-width: none;
    }

    .chat-help-bar::-webkit-scrollbar, .chat-actions-row::-webkit-scrollbar {
        display: none;
    }

    .chat-help-btn {
        flex-shrink: 0 !important;
        padding: 4px 8px !important;
        font-size: 11px !important;
    }

    .chat-help-btn span {
        display: none !important;
    }

    /* ---- Modal: full screen on mobile ---- */
    .modal-content {
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    /* ---- Diagram editor: full screen, no sidebars ---- */
    .ifl-editor-fullscreen {
        inset: 0 !important;
        border-radius: 0 !important;
    }

    .ifl-editor-sidebar {
        display: none !important;
    }

    .ifl-editor-toolbar {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
    }

    .ifl-toolbar-btn {
        flex-shrink: 0 !important;
    }

    /* ---- Equation bar: stack vertically on mobile ---- */
    .ifl-eq-bar {
        max-height: 120px !important;
        overflow-y: auto !important;
    }

    .ifl-eq-row {
        flex-wrap: wrap !important;
    }

    /* ---- Chat messages: wider on mobile ---- */
    .chat-msg {
        max-width: 95% !important;
        font-size: 13px !important;
    }

    .chat-msg.user {
        padding: 8px 12px !important;
    }

    .chat-msg.assistant {
        padding: 8px 12px !important;
    }

    .chat-log {
        padding: 8px !important;
    }

    /* Code blocks: horizontal scroll on mobile */
    .chat-msg pre, .chat-msg code {
        max-width: 100% !important;
        overflow-x: auto !important;
        font-size: 12px !important;
    }

    /* ---- Mobile notice banner ---- */
    .mobile-notice-banner {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 200000;
        background: var(--bg-secondary, #1e1e2e);
        border-bottom: 1px solid var(--border);
        padding: 12px 16px;
        animation: slideDown 0.3s ease;
    }

    @keyframes slideDown {
        from { transform: translateY(-100%); }
        to { transform: translateY(0); }
    }

    .mobile-notice-content {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        max-width: 480px;
        margin: 0 auto;
    }

    .mobile-notice-content svg {
        flex-shrink: 0;
        color: var(--primary, #a1a1aa);
        margin-top: 2px;
    }

    .mobile-notice-content p {
        flex: 1;
        font-size: 12px;
        line-height: 1.4;
        color: var(--text-secondary);
        margin: 0;
    }

    .mobile-notice-close {
        flex-shrink: 0;
        padding: 4px 12px;
        border-radius: 6px;
        border: 1px solid var(--border);
        background: var(--primary, #a1a1aa);
        color: #fff;
        font-size: 11px;
        font-weight: 600;
        cursor: pointer;
        white-space: nowrap;
    }

    /* ---- Toast/notification: full width on mobile ---- */
    .toast {
        left: 8px !important;
        right: 8px !important;
        max-width: none !important;
    }

    /* ---- Tributaries: horizontal scroll ---- */
    .ifl-tributaries {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
    }

    .ifl-tributary-btn {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }

    /* ---- Session modal: mobile-optimized ---- */
    .new-session-modal {
        padding: 16px !important;
        max-height: 85dvh !important;
        max-height: 85vh !important;
        border-radius: 12px !important;
    }

    .new-session-modal .choice-cards-horizontal {
        display: flex !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        gap: 8px !important;
        padding-bottom: 8px !important;
        scrollbar-width: none;
    }

    .new-session-modal .choice-cards-horizontal::-webkit-scrollbar {
        display: none;
    }

    .new-session-modal .choice-card-horizontal {
        min-width: 140px !important;
        flex-shrink: 0 !important;
    }

    .new-session-footer {
        position: sticky !important;
        bottom: -16px !important;
        padding: 12px 0 4px !important;
        margin: 0 -16px !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* ---- Chat fullscreen: iOS safe areas ---- */
    .chat-fullscreen {
        height: 100vh !important;
        height: 100dvh !important;
    }

    .chat-fullscreen-header {
        padding-top: max(8px, env(safe-area-inset-top)) !important;
        height: auto !important;
        min-height: 44px !important;
    }

    .chat-form {
        padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
    }

    /* ---- Touch targets: 44px minimum (Apple HIG) ---- */
    .btn-primary, .btn-secondary, .btn {
        min-height: 44px !important;
    }

    .choice-card-horizontal {
        min-height: 48px !important;
        padding: 12px 14px !important;
    }

    .chat-draw-toggle {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
    }

    .chat-submit-btn {
        min-height: 44px !important;
    }

    /* ---- Button tap feedback ---- */
    .btn-primary:active, .btn-secondary:active, .btn:active {
        opacity: 0.7 !important;
        transform: scale(0.97) !important;
    }

    .choice-card-horizontal:active {
        opacity: 0.8 !important;
        transform: scale(0.98) !important;
    }

    /* ---- Mobile notice banner: safe area ---- */
    .mobile-notice-banner {
        top: env(safe-area-inset-top, 0px) !important;
    }

    /* ---- Settings modal: dvh fix ---- */
    .settings-modal, .settings-layout {
        max-height: 100dvh !important;
        max-height: 100vh !important;
    }

    /* ---- Paywall: scrollable with sticky button ---- */
    .paywall-modal-content {
        max-height: 85dvh !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
    }

    .paywall-subscribe-btn, .paywall-cancel-btn, .paywall-downgrade-btn {
        min-height: 48px !important;
        font-size: 14px !important;
    }

    /* ============================================
       Phase 2: Mobile Bottom Tab Bar
       ============================================ */

    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(56px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
        z-index: 1000;
        justify-content: space-around;
        align-items: center;
    }

    .mobile-tab {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 8px 4px;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 0.65rem;
        cursor: pointer;
        transition: color 0.2s;
    }

    .mobile-tab.active {
        color: var(--primary);
    }

    .mobile-tab svg {
        width: 22px;
        height: 22px;
    }

    /* Hide FAB when tab bar exists */
    .panel-toggle-btn {
        display: none !important;
    }

    /* Hide top dash tabs on mobile */
    .dash-tabs {
        display: none !important;
    }

    /* Adjust chat form to sit above tab bar */
    .chat-form {
        margin-bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .ai-disclaimer {
        margin-bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Mobile menu sheet */
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1001;
    }

    .mobile-menu-overlay.active {
        display: block;
    }

    .mobile-menu-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        z-index: 1002;
        transform: translateY(100%);
        transition: transform 0.3s ease;
    }

    .mobile-menu-overlay.active .mobile-menu-sheet {
        transform: translateY(0);
    }

    .mobile-menu-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        border: none;
        background: none;
        color: var(--text);
        font-size: 0.95rem;
        width: 100%;
        text-align: left;
        cursor: pointer;
        border-radius: 8px;
    }

    .mobile-menu-item:active {
        background: var(--bg-elevated);
    }

    .mobile-menu-handle {
        width: 40px;
        height: 4px;
        background: var(--border);
        border-radius: 2px;
        margin: 0 auto 12px;
    }

    /* Add bottom padding to dashboard content for tab bar */
    .dash-tab-content {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* ============================================
       Phase 3: Chat Mobile UX
       ============================================ */

    /* Tributaries on mobile: keep cards with descriptions */
    .ifl-tributaries {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        padding: 8px 0 !important;
        margin-top: 8px !important;
    }

    /* Explore/Connect/Apply row: 3 compact cards side by side */
    .ifl-tributary-row {
        display: flex !important;
        flex-direction: row !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
    }

    .ifl-tributary {
        min-height: auto !important;
        padding: 8px 10px !important;
        font-size: 0.75rem !important;
    }

    .ifl-tributary .ifl-trib-label {
        font-size: 0.7rem !important;
        font-weight: 600 !important;
    }

    .ifl-tributary .ifl-trib-text {
        font-size: 0.65rem !important;
        line-height: 1.3 !important;
        margin-top: 2px !important;
    }

    /* Quiz and Feynman: full width single items */
    .ifl-tributary-row .ifl-tributary:only-child {
        max-width: 100% !important;
        flex: 1 1 100% !important;
    }

    /* Chat header: compact on mobile — show logo + name + close only */
    .chat-fullscreen-header {
        padding: 6px 10px !important;
        gap: 4px !important;
    }

    .chat-fullscreen-header-right {
        gap: 4px !important;
    }

    /* Hide non-essential header items on mobile — moved to bottom Menu tab */
    .chat-fullscreen-product,
    .chat-theme-toggle,
    #header-export-slot,
    .chat-tools-dropdown,
    #chat-help-btn {
        display: none !important;
    }

    .chat-fullscreen-logo-large {
        height: 28px !important;
    }

    .chat-fullscreen-session {
        font-size: 0.75rem !important;
        max-width: none !important;
        overflow: visible !important;
        text-overflow: unset !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    .chat-fullscreen-close {
        padding: 4px 10px !important;
        font-size: 0.75rem !important;
        flex-shrink: 0 !important;
    }

    /* Fix gap between send button and AI disclaimer */
    .chat-form {
        margin-bottom: 0 !important;
    }

    .ai-disclaimer {
        margin-bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
        padding: 2px 12px 4px !important;
    }

    /* Chat input fix for mobile */
    .chat-form {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: flex-end !important;
        padding: 8px 12px !important;
        gap: 8px !important;
    }

    .chat-input-field {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: auto !important;
        min-height: 40px !important;
        font-size: 16px !important; /* prevent iOS zoom */
    }

    .chat-submit-btn {
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: 80px !important;
        padding: 8px 14px !important;
        font-size: 13px !important;
    }

    .chat-draw-toggle {
        flex: 0 0 auto !important;
        width: 40px !important;
        height: 40px !important;
    }

    /* New session modal responsive */
    .new-session-modal .choice-cards {
        display: flex !important;
        overflow-x: auto !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px !important;
    }

    .new-session-modal .choice-card {
        flex-shrink: 0 !important;
        min-width: 140px !important;
        max-width: 160px !important;
    }
}

/* ============================================
   EXTRA SMALL PHONES (max-width: 360px)
   ============================================ */

@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .action-bar {
        grid-template-columns: 1fr !important;
    }
}
