/**
 * Aethon Frontend
 * Modern minimal dark theme - Mobile responsive
 */

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

/* Dark Theme (Default) - Orange/Amber Accent */
:root {
    --primary: #f59e0b;
    --primary-hover: #fbbf24;
    --primary-muted: rgba(245, 158, 11, 0.1);
    --bg: #0a0b0f;
    --bg-secondary: #13141a;
    --bg-card: #13141a;
    --bg-elevated: #1a1b24;
    --bg-tertiary: #20212d;
    --text: #ffffff;
    --text-secondary: #a0a3b8;
    --text-muted: #6b6d7f;
    --border: #2a2b38;
    --border-hover: #3a3b48;
    --success: #10b981;
    --error: #EF4444;
    --warning: #F59E0B;
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

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

    /* Transitions */
    --transition: 0.15s ease;
    --transition-slow: 0.3s ease;

    /* Rich content colors */
    --code-bg: #1E1E2E;
    --code-text: #CDD6F4;
    --table-header: #1a1b24;
    --table-row-alt: rgba(255, 255, 255, 0.02);
    --chip-bg: rgba(245, 158, 11, 0.15);
    --chip-text: #fde68a;
    --search-highlight: rgba(250, 204, 21, 0.4);

    /* User/Assistant message colors */
    --msg-user-bg: rgba(245, 158, 11, 0.1);
    --msg-user-text: #fcd34d;
    --msg-assistant-bg: var(--bg-elevated);
    --msg-assistant-text: #e9ebf0;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
}

/* Light Theme */
:root.light-mode {
    --primary: #f59e0b;
    --primary-hover: #d97706;
    --primary-muted: rgba(245, 158, 11, 0.1);
    --bg: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-card: #ffffff;
    --bg-elevated: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    --text: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-hover: #d1d5db;
    --success: #059669;
    --error: #DC2626;
    --warning: #D97706;

    /* Rich content colors */
    --code-bg: #f3f4f6;
    --code-text: #111827;
    --table-header: #f3f4f6;
    --table-row-alt: rgba(0, 0, 0, 0.02);
    --chip-bg: rgba(245, 158, 11, 0.1);
    --chip-text: #b45309;
    --search-highlight: rgba(250, 204, 21, 0.5);

    /* User/Assistant message colors */
    --msg-user-bg: rgba(245, 158, 11, 0.08);
    --msg-user-text: #b45309;
    --msg-assistant-bg: var(--bg-elevated);
    --msg-assistant-text: #111827;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1);
}

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;
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    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: 10px 18px;
    border-radius: var(--radius);
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

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

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

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

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

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

.btn-danger:hover {
    background: #dc2626;
}

/* 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);
}

/* Header */
.header {
    background: var(--bg-card);
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.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;
}

.welcome h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 2px;
}

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

/* 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;
}

/* 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: white;
}

.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(124, 58, 237, 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: white;
    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;
}

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

/* Chrome Header - 64px */
.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);
}

.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(99, 102, 241, 0.1);
    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(99, 102, 241, 0.05) 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: white;
}

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

:root.light-mode .mindmap-node circle {
    stroke: #d1d5db;
}

:root.light-mode .mindmap-node text {
    fill: #1f2937 !important;
    stroke: #f9fafb !important;
    stroke-width: 3px !important;
    font-weight: 500 !important;
}

:root.light-mode .mindmap-link {
    stroke: #9ca3af;
}

: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: 40%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg);
}

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

/* 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;
}

.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: white;
    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;
}

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

.mindmap-svg {
    width: 100%;
    height: 100%;
    display: block;
    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-panel-left {
        height: 70%;
    }

    .chat-panel-right {
        height: 30%;
    }

    .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(245, 158, 11, 0.15);
    color: #f59e0b;
    border-color: #f59e0b;
}

.node-btn.active.mastered {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border-color: #4ade80;
}

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

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

.node-btn.primary {
    background: var(--primary);
    color: white;
    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;
}

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

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

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

/* LEARNING state - Pulsing indicator, in progress */
.mindmap-node.state-learning circle {
    stroke: #fbbf24 !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(251, 191, 36, 0.3));
    }
    50% {
        stroke-width: 4px;
        filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.5));
    }
}

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

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

/* MASTERED state - Strong green, stable appearance */
.mindmap-node.state-mastered circle {
    stroke: #22c55e !important;
    stroke-width: 3px !important;
    filter: drop-shadow(0 0 2px rgba(34, 197, 94, 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: white;
    border-color: var(--primary);
}

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

.state-filter-btn[data-state="new"] .state-dot {
    background: #93c5fd;
    box-shadow: 0 0 4px rgba(147, 197, 253, 0.6);
}

.state-filter-btn[data-state="learning"] .state-dot {
    background: #fbbf24;
}

.state-filter-btn[data-state="reviewing"] .state-dot {
    background: #ef4444;
    animation: dotPulse 1.5s ease-in-out infinite;
}

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

@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;
}

/* 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;
}

.mindmap-state-legend .legend-dot.new {
    border-color: #93c5fd;
}

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

.mindmap-state-legend .legend-dot.reviewing {
    border-color: #ef4444;
}

.mindmap-state-legend .legend-dot.mastered {
    border-color: #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;
}

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

/* 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(147, 197, 253, 0.2);
    color: #93c5fd;
}

.popover-state.state-learning {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.popover-state.state-reviewing {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.popover-state.state-mastered {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.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: white;
}

.popover-btn.mastered {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.popover-btn.learning {
    background: #f59e0b;
    border-color: #f59e0b;
    color: white;
}

.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: white;
    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-status {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

/* 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(99, 102, 241, 0.15);
    border-color: #6366f1;
}

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

.popover-trib-btn.connect:hover {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
}

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

.popover-trib-btn.apply:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: #f59e0b;
}

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

.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: white;
}

.mindmap-info {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 16px;
    padding: 8px 14px;
    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: white;
}

.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: white;
}

.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;
}

/* 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: white;
}

/* 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: white;
}

/* Smart Focus button */
.mindmap-info .smart-focus-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

.mindmap-info .smart-focus-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.mindmap-info .smart-focus-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.3);
}

/* 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);
}

/* 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);
}

.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: rgba(34, 197, 94, 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: white;
    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;
    }

    .header {
        padding: 14px 16px;
    }

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

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

    .header-logo {
        height: 28px;
    }

    .welcome h1 {
        font-size: 1rem;
    }

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

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

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

    .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%;
    }
}

/* ==================== */
/* 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;
}

@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(124, 58, 237, 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(124, 58, 237, 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;
}

/* 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: nowrap;
}

.math-error {
    color: var(--error);
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
    background: rgba(239, 68, 68, 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;
}

.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: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.chat-search 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;
}

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

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

.chat-search-btn {
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-search-btn:hover {
    border-color: var(--primary);
    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: 300px;
    overflow-y: auto;
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s ease;
}

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

.session-item:hover {
    background: var(--bg-elevated);
}

.session-item-info {
    flex: 1;
    min-width: 0;
}

.session-item-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-item-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.session-item-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.session-item:hover .session-item-actions {
    opacity: 1;
}

.session-action-btn {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.session-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.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-summary {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.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);
}

.session-panel-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.session-pagination {
    padding: 12px 20px;
    text-align: center;
    border-top: 1px solid var(--border);
}

/* 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: 50;
    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);
}

/* ================================
   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;
}

.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;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    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;
}

/* Second row has 2 items */
.ifl-tributary-row:last-child .ifl-tributary {
    max-width: 50%;
}

.ifl-tributary:hover {
    background: rgba(255,255,255,0.08);
    transform: translateY(-2px);
}

.ifl-tributary.deeper { border-left: 3px solid #8b5cf6; }
.ifl-tributary.wider { border-left: 3px solid #06b6d4; }
.ifl-tributary.practical { border-left: 3px solid #10b981; }
.ifl-tributary.quiz { border-left: 3px solid #f59e0b; }
.ifl-tributary.feynman { border-left: 3px solid #ec4899; }

.ifl-tributary.deeper:hover { box-shadow: 0 4px 20px rgba(139,92,246,0.2); }
.ifl-tributary.wider:hover { box-shadow: 0 4px 20px rgba(6,182,212,0.2); }
.ifl-tributary.practical:hover { box-shadow: 0 4px 20px rgba(16,185,129,0.2); }
.ifl-tributary.quiz:hover { box-shadow: 0 4px 20px rgba(245,158,11,0.2); }
.ifl-tributary.feynman:hover { box-shadow: 0 4px 20px rgba(236,72,153,0.2); }

.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: #a78bfa; }
.ifl-tributary.wider .ifl-trib-label { color: #22d3ee; }
.ifl-tributary.practical .ifl-trib-label { color: #4ade80; }
.ifl-tributary.quiz .ifl-trib-label { color: #fbbf24; }
.ifl-tributary.feynman .ifl-trib-label { color: #f472b6; }

.ifl-trib-text {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* 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(34, 197, 94, 0.2);
    border-color: #22c55e;
}

.ifl-quiz-option.incorrect {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

.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: #22c55e;
    color: white;
}

.ifl-quiz-option.incorrect .ifl-quiz-option-letter {
    background: #ef4444;
    color: white;
}

.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: white;
}

.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: white;
}

.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;
    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;
}

.ifl-feynman-prompt {
    font-size: 16px;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 12px;
}

.ifl-feynman-prompt strong {
    color: #f472b6;
}

.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: #ec4899;
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 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, #ec4899, #8b5cf6);
    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(236, 72, 153, 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: #4ade80; }
.ifl-feynman-section.gaps h4 { color: #fbbf24; }
.ifl-feynman-section.suggestions h4 { color: #60a5fa; }

.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, #ec4899, #8b5cf6);
    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: #f87171;
}

.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: #7c3aed; }
[data-theme="light"] .ifl-tributary.wider .ifl-trib-label { color: #0891b2; }
[data-theme="light"] .ifl-tributary.practical .ifl-trib-label { color: #059669; }
[data-theme="light"] .ifl-tributary.quiz .ifl-trib-label { color: #d97706; }
[data-theme="light"] .ifl-tributary.feynman .ifl-trib-label { color: #db2777; }

/* ============================================================================
   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: white;
}

.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(245, 158, 11, 0.1);
    color: var(--warning);
}

.free-messages-counter.exhausted {
    background: rgba(239, 68, 68, 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 {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.insight-card.progress .insight-icon {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
}

.insight-card.recommendation .insight-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.insight-card.streak .insight-icon {
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
}

.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;
}

.visualization-graph {
    min-height: 280px;
    background: rgba(30, 30, 46, 0.8);
}

/* 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(239, 68, 68, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .visualization-graph {
        min-height: 250px;
    }
}

/* ============================================
   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;
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 8px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-menu-trigger:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-muted);
}

.user-avatar {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 20px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.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(139, 92, 246, 0.25), rgba(59, 130, 246, 0.25));
    color: var(--primary);
}

.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: 1000;
}

.user-menu.open .user-menu-dropdown,
.user-menu-dropdown.active {
    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(139, 92, 246, 0.1), rgba(59, 130, 246, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.chat-msg.paywall-message .paywall-subscribe-btn {
    margin-top: 12px;
}

/* 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;
    }

    .user-menu-trigger {
        padding: 6px;
    }

    .user-menu-plan {
        display: none;
    }

    .user-menu-trigger svg:last-child {
        display: none;
    }

    .user-menu-dropdown {
        width: 260px;
        right: -10px;
    }
}

/* ================================
   Admin/Teacher Dashboard Layout
   ================================ */

.dashboard-container {
    min-height: 100vh;
    background: var(--bg);
}

.dashboard-header {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.dashboard-header .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

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

.dashboard-header .header-logo {
    height: 40px;
    width: auto;
}

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

.dashboard-header .header-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: 0;
}

.dashboard-header .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* ================================
   Tabs Component
   ================================ */

.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-elevated);
    padding: 4px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.tab {
    flex: 1;
    padding: 12px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}

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

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

.tab-content {
    display: none;
}

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

/* ================================
   Table Styles
   ================================ */

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg);
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 12px 16px;
    font-size: 0.875rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

tbody tr:hover {
    background: var(--bg);
}

/* ================================
   Empty State
   ================================ */

.empty-state {
    text-align: center;
    padding: 48px 24px;
}

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

.empty-state-description {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* ================================
   Badge
   ================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-primary {
    background: var(--primary-muted);
    color: var(--primary);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

/* ================================
   Utility Extensions
   ================================ */

.items-center { align-items: center; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.mt-md { margin-top: 12px; }
.mt-lg { margin-top: 24px; }
.text-sm { font-size: 0.875rem; }
.text-error { color: var(--error); }

/* Admin Stats Card Icon */
.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--primary-muted);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

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

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

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg) 25%, var(--bg-elevated) 50%, var(--bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   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;
    position: relative;
}

.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);
}

@keyframes pulse-status {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.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);
}

.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;
    }
}

@media (max-width: 480px) {
    .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;
    }
}

/* ============================================================================
   Help Button and Modal
   ============================================================================ */

/* 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: #ffffff;
    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);
}

/* 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;
}

/* 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;
}

/* Light Mode Adjustments */
:root.light-mode .help-modal {
    background: #ffffff;
}

:root.light-mode .help-modal-header {
    background: #f9fafb;
}

:root.light-mode .help-feature {
    background: #f9fafb;
}

:root.light-mode .help-shortcut kbd {
    background: #f3f4f6;
}

/* 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 {
        grid-template-columns: 1fr;
    }

    .chat-help-btn span {
        display: none;
    }

    .chat-help-btn {
        padding: 8px 10px;
    }
}
