/* =========================================
   UMBRAIX AI — STYLE SYSTEM v2026
   "EDITORIAL CLARITY" — Solid, Sharp, Modern
   Light-first. No Glass. No Blur.
   ========================================= */

/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@600;700&family=Manrope:wght@400;500;600&family=JetBrains+Mono:ital,wght@0,400;0,500;1,400&display=swap');


/* =========================================
   :ROOT — LIGHT THEME (Default)
   "Perplexity-inspired Editorial Clarity"
   ========================================= */
:root {
    /* 1. BRAND COLORS */
    --brand-primary: oklch(48% 0.18 268);        /* Deep Indigo */
    --brand-hover:   oklch(42% 0.20 268);
    --brand-active:  oklch(38% 0.22 268);
    --brand-surface: oklch(96% 0.03 268);

    /* 2. SEMANTIC STATUS */
    --color-success: oklch(52% 0.16 148);
    --color-warning: oklch(62% 0.18 85);
    --color-error:   oklch(54% 0.20 25);
    --color-info:    oklch(54% 0.14 240);

    /* 3. BACKGROUNDS — SOLID, NO GLASS */
    --primary-bg:     oklch(99% 0.005 268);       /* Cool-tinted white, matches brand hue */
    --bg-gradient:    none;

    /* Solid Surface Layers */
    --surface-0:     #ffffff;
    --surface-1:     #f7f8fc;
    --surface-2:     #eef1f7;
    --surface-3:     #e4e8f0;
    --surface-hover: #eaecf4;
    --surface-input: #f2f4f9;

    /* Panel Backgrounds — Solid, not glass */
    --bg-panel:      #ffffff;
    --bg-panel-alt:  #f8f9fb;
    --bg-sidebar:    #f8f9fb;

    /* Code Block Surfaces */
    --code-bg:        #f4f5f8;
    --code-text:      oklch(28% 0.03 270);
    --hljs-bg:        #f8f9fb;
    --code-header-bg: #edf0f4;
    --code-border:    #dde1e8;

    /* Send Button Text Color */
    --send-btn-color: #ffffff;

    /* 4. TYPOGRAPHY */
    --text-main:      oklch(12% 0.02 270);
    --text-secondary: oklch(28% 0.02 270);
    --text-muted:     oklch(46% 0.02 270);
    --text-dim:       oklch(60% 0.015 270);
    --text-disabled:  oklch(72% 0.01 270);

    /* Font Families */
    --font-display: 'Plus Jakarta Sans', 'Space Grotesk', -apple-system, sans-serif;
    --font-body:    'Manrope', -apple-system, sans-serif;
    --font-code:    'JetBrains Mono', 'Cascadia Code', monospace;

    /* Font Scale */
    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.25rem;
    --text-2xl:  1.5rem;
    --text-3xl:  1.875rem;

    /* Line Heights */
    --leading-tight:   1.25;
    --leading-normal:  1.5;
    --leading-relaxed: 1.625;

    /* 5. BORDERS — Clean, Crisp */
    --border-subtle: #e5e8ed;
    --border-medium: #d8dce4;
    --border-strong: #c6ccd6;
    --border-focus:  var(--brand-primary);

    /* 6. SHADOWS — Solid depth, no glow */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.09);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.12);

    /* Brand-tinted shadow (subtle, no glow) */
    --shadow-brand: 0 4px 16px oklch(48% 0.18 268 / 0.16);
    --brand-focus-ring: oklch(48% 0.18 268 / 0.13);

    /* 7. SPACING */
    --radius-xs:   0.375rem;
    --radius-sm:   0.75rem;
    --radius-md:   1rem;
    --radius-lg:   1.5rem;
    --radius-xl:   2rem;
    --radius-pill: 9999px;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2rem;
    --space-6: 3rem;

    /* Containers */
    --container-sm:  640px;
    --container-md:  900px;
    --container-lg:  1100px;

    /* Sidebar */
    --sidebar-width:      280px;
    --sidebar-transition: transform 0.35s cubic-bezier(0.215, 0.61, 0.355, 1);

    /* 8. EASING */
    --ease-out:    cubic-bezier(0.215, 0.61, 0.355, 1);
    --ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    --transition-fast: 120ms;
    --transition-base: 220ms;
    --transition-slow: 340ms;

    /* NO GLASS — these are kept for variable compatibility but set to 0 */
    --glass-blur: 0px;
    --glass-blur-strong: 0px;
    --glass-saturate: 100%;
}


/* =========================================
   [data-theme="dark"] — VELOX MIDNIGHT
   Deep dark, solid surfaces, no glass.
   ========================================= */
[data-theme="dark"] {
    /* Brand */
    --brand-primary: oklch(68% 0.23 265);
    --brand-hover: oklch(74% 0.24 265);
    --brand-active: oklch(62% 0.25 265);
    --brand-surface: oklch(20% 0.06 265);

    /* Status */
    --color-success: oklch(68% 0.20 148);
    --color-warning: oklch(78% 0.18 88);
    --color-error:   oklch(64% 0.22 25);
    --color-info:    oklch(68% 0.18 242);

    /* Backgrounds */
    --primary-bg:  oklch(13% 0.014 272);
    --bg-gradient: none;

    /* Solid Surfaces */
    --surface-0:     oklch(13% 0.014 272);
    --surface-1:     oklch(17% 0.016 272);
    --surface-2:     oklch(21% 0.018 272);
    --surface-3:     oklch(25% 0.020 272);
    --surface-hover: oklch(19% 0.017 272);
    --surface-input: oklch(16% 0.014 272);

    /* Panels */
    --bg-panel:     oklch(17% 0.016 272);
    --bg-panel-alt: oklch(20% 0.018 272);
    --bg-sidebar:   oklch(15% 0.015 272);

    /* Code */
    --code-bg:        oklch(17% 0.016 272);
    --code-text:      oklch(88% 0.02 265);
    --hljs-bg:        oklch(14% 0.014 272);
    --code-header-bg: oklch(19% 0.017 272);
    --code-border:    oklch(26% 0.020 272);

    --send-btn-color: #ffffff;

    /* Typography */
    --text-main:      oklch(96% 0.01 265);
    --text-secondary: oklch(88% 0.02 265);
    --text-muted:     oklch(70% 0.025 265);
    --text-dim:       oklch(54% 0.02 265);
    --text-disabled:  oklch(40% 0.015 265);

    /* Borders */
    --border-subtle: oklch(24% 0.018 272);
    --border-medium: oklch(28% 0.020 272);
    --border-strong: oklch(34% 0.022 272);

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.40);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.50);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.55);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.60);
    --shadow-brand: 0 4px 20px oklch(68% 0.23 265 / 0.32);
    --brand-focus-ring: oklch(68% 0.23 265 / 0.18);
}


/* =========================================
   [data-theme="void"] — ABSOLUTE VOID
   OLED black, max contrast, solid & crisp.
   ========================================= */
[data-theme="void"] {
    /* Brand */
    --brand-primary: oklch(72% 0.22 265);
    --brand-hover:   oklch(78% 0.23 265);
    --brand-active:  oklch(66% 0.24 265);
    --brand-surface: oklch(15% 0.08 265);

    /* Status */
    --color-success: oklch(70% 0.22 148);
    --color-warning: oklch(80% 0.20 88);
    --color-error:   oklch(66% 0.24 25);
    --color-info:    oklch(70% 0.20 242);

    /* OLED Black Backgrounds */
    --primary-bg:  #000000;
    --bg-gradient: none;

    /* Solid Surfaces — near-black layering */
    --surface-0: #000000;
    --surface-1: #0f0f0f;
    --surface-2: #1b1b1b;
    --surface-3: #272727;
    --surface-hover: #171717;
    --surface-input: #0b0b0b;
    
    /* Panels */
    --bg-panel: #0f0f0f;
    --bg-panel-alt: #141414;
    --bg-sidebar: #090909;

    /* Code */
    --code-bg:        #0d0d0d;
    --code-text:      oklch(90% 0.02 265);
    --hljs-bg:        #050505;
    --code-header-bg: #111111;
    --code-border:    #222222;

    --send-btn-color: #000000;

    /* Typography */
    --text-main:      #f5f5f5;
    --text-secondary: #d0d0d0;
    --text-muted:     #888888;
    --text-dim:       #555555;
    --text-disabled:  #383838;

    /* Borders — thin, crisp */
    --border-subtle: #1e1e1e;
    --border-medium: #282828;
    --border-strong: #333333;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.70);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.80);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.85);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.90);
    --shadow-xl: 0 16px 40px rgba(0, 0, 0, 0.95);
    --shadow-brand: 0 4px 24px oklch(72% 0.22 265 / 0.36);
    --brand-focus-ring: oklch(72% 0.22 265 / 0.22);
}

/* =========================================
   WELCOME / EMPTY STATE
   ========================================= */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem 2rem;
    text-align: center;
    animation: fadeIn 0.5s var(--ease-out) forwards;
    min-height: 55vh;
}

.welcome-logo {
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    background: var(--brand-surface);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-brand);
}

.welcome-logo i {
    font-size: 1.5rem;
    color: var(--brand-primary);
}

.welcome-title {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.6rem;
    letter-spacing: -0.025em;
    text-align: center;
}

.welcome-tagline {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    max-width: 400px;
    line-height: 1.65;
}

.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    justify-content: center;
    max-width: 580px;
}

.welcome-chip {
    background: var(--surface-0);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-xs);
    text-align: left;
    -webkit-user-select: none;
    user-select: none;
}

.welcome-chip:hover {
    background: var(--surface-2);
    border-color: var(--brand-primary);
    color: var(--text-main);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.welcome-chip:active {
    transform: translateY(0);
}

.welcome-chip i {
    color: var(--brand-primary);
    font-size: 0.82rem;
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .welcome-state {
        padding: 3rem 1.25rem 1.5rem;
        min-height: 45vh;
    }
    .welcome-chips {
        flex-direction: column;
        align-items: stretch;
        max-width: 100%;
    }
    .welcome-chip {
        justify-content: flex-start;
    }
}


/* =========================================
   RESET & BASE
   ========================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--text-main);
    text-align: center;
    line-height: var(--leading-tight);
}

body, p, input {
    font-family: var(--font-body);
    color: var(--text-muted);
    font-weight: 500;
}

code, pre { font-family: var(--font-code); }
button, a {
    font-family: var(--font-display);
    font-weight: 600;
    text-decoration: none;
}

/* =========================================
   BODY
   ========================================= */
body {
    background-color: var(--primary-bg);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    /* Disable tap highlight / selection for UI */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    /* GPU layer */
    transform: translateZ(0);
}

/* Re-enable selection inside inputs */
input, textarea {
    -webkit-user-select: auto;
    user-select: auto;
}


/* =========================================
   AI GENERATING ANIMATION (SHIMMER WAVE)
   ========================================= */
.ai-generating-text {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0.02em;

    background: linear-gradient(
        110deg,
        var(--text-muted) 40%,
        var(--brand-primary) 50%,
        var(--text-muted) 60%
    );
    background-size: 400% auto;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;

    animation: shimmerWave 1.8s linear infinite;
}

@keyframes shimmerWave {
    0%   { background-position: 100% center; }
    100% { background-position:   0% center; }
}

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


/* =========================================
   SIDEBAR
   ========================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    z-index: 1000;
    transform: translateX(-100%);
    transition: var(--sidebar-transition);
    display: flex;
    flex-direction: column;
    /* NO backdrop-filter */
}

.sidebar.active {
    transform: translateX(0);
}

@media (max-width: 767px) {
    .sidebar {
        width: 100%;
        border-right: none;
    }
}

/* Sidebar Header */
.sidebar-header-wrapper {
    padding: var(--space-3);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 0.25rem;
}

.sidebar-pill-header {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    font-size: var(--text-lg);
    cursor: pointer;
    border-radius: var(--radius-pill);
    padding: 0.5rem 1.2rem;
    gap: 1.5rem;
    box-shadow: var(--shadow-xs);
    width: 100%;
    height: 3rem;
    max-width: 9rem;
    transition: background var(--transition-fast) ease;
}

.sidebar-pill-header:hover {
    background: var(--surface-3);
}

.brand-name {
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.close-sidebar-btn {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--surface-1);
    color: var(--text-muted);
    font-size: var(--text-base);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast) ease;
    flex-shrink: 0;
}

.close-sidebar-btn:hover {
    background: var(--surface-2);
    color: var(--color-error);
    border-color: var(--color-error);
}

/* Sidebar Content / Scroll Area */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.sidebar-content::-webkit-scrollbar { width: 0px; }

.sidebar-section-title {
    font-family: var(--font-display);
    font-size: var(--text-xs);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.10em;
    margin-bottom: 0.6rem;
    padding-left: 0.5rem;
}

.history-grid {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background var(--transition-fast) ease,
    color var(--transition-fast) ease,
    padding-left var(--transition-fast) ease,
    border-color var(--transition-fast) ease;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--text-muted);
    border: 1px solid transparent;
    position: relative;
}

.history-item:hover {
    color: var(--text-main);
    background: var(--surface-2);
    padding-left: 1.15rem;
}

.history-item.active {
    background: var(--surface-2);
    border-color: var(--border-subtle);
    color: var(--text-main);
    box-shadow: var(--shadow-xs);
}

.history-item i {
    font-size: var(--text-sm);
    opacity: 0.55;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.history-item.active i {
    opacity: 1;
    color: var(--brand-primary);
}

/* History item inner layout */
.history-item-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.history-item-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item-actions {
    opacity: 0;
    display: flex;
    gap: 0.2rem;
    transition: opacity var(--transition-fast) ease;
}

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

.history-action-btn {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 0.78rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast) ease;
}

.history-action-btn:hover {
    background: var(--surface-3);
    color: var(--text-main);
}

.history-action-btn.delete:hover {
    color: var(--color-error);
    background: oklch(96% 0.03 25);
}

[data-theme="dark"] .history-action-btn.delete:hover,
[data-theme="void"] .history-action-btn.delete:hover {
    background: oklch(20% 0.05 25);
}

/* Sidebar Footer */
.sidebar-footer-minimal {
    margin-top: auto;
    padding: var(--space-4);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-sidebar);
}

.footer-settings-btn {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--surface-1);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base) ease;
    flex-shrink: 0;
}

.footer-settings-btn:hover {
    background: var(--surface-2);
    color: var(--text-main);
    transform: rotate(45deg);
    border-color: var(--border-medium);
}

.footer-login-btn {
    flex: 1;
    height: 2.75rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    background: var(--surface-2);
    color: var(--text-main);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    transition: all var(--transition-base) ease;
}

.footer-login-btn:hover {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: var(--send-btn-color);
}


/* =========================================
   FLOATING HEADER
   ========================================= */
.floating-header {
    position: fixed;
    top: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: var(--container-lg);
    height: auto;
    min-height: 3.75rem;
    background: transparent;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-2) 0;
    z-index: 500;
    transition: left var(--transition-slow) var(--ease-out),
                width var(--transition-slow) var(--ease-out);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 900px;
}

/* Desktop sidebar-open shift */
@media (min-width: 768px) {
    body {
        transition: padding-left var(--transition-slow) var(--ease-out);
    }

    body.sidebar-open {
        padding-left: var(--sidebar-width);
    }

    body.sidebar-open .floating-header,
    body.sidebar-open .input-area {
        left: calc(50% + var(--sidebar-width) / 2);
        width: calc(90% - var(--sidebar-width) * 0.9);
    }

    .close-sidebar-btn {
        display: none;
    }
}

/* Standalone icon button (menu toggle) */
.icon-btn.standalone {
    width: 2.85rem;
    height: 2.85rem;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--surface-0);
    color: var(--text-main);
    font-size: var(--text-base);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base) ease;
    box-shadow: var(--shadow-sm);
}

.icon-btn.standalone:hover,
.icon-btn.standalone.active {
    background: var(--surface-2);
    color: var(--brand-primary);
    border-color: var(--border-medium);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Header right pill */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--surface-0);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    padding: 0.45rem;
    box-shadow: var(--shadow-sm);
    /* NO backdrop-filter */
}

.header-right .icon-btn {
    width: 2rem;
    height: 2rem;
    background: transparent;
    border: none;
    box-shadow: none;
    color: var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-base);
    cursor: pointer;
    transition: all var(--transition-fast) ease;
}

#new-chat-btn {
    margin-right: 0.2rem;
}

.header-right .icon-btn:hover {
    background: var(--surface-2);
    color: var(--brand-primary);
    transform: scale(1.05);
}

.header-right .icon-btn.active {
    background: var(--brand-surface);
    color: var(--brand-primary);
}

.icon-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-3);
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    pointer-events: none;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-xs);
}


/* =========================================
   CHAT CONTAINER
   ========================================= */
.chat-container {
    flex: 1;
    width: 100%;
    max-width: var(--container-md);
    margin: 0 auto;
    padding: 100px var(--space-4) 110px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 10px;
}
.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--border-medium);
}

/* Message Wrapper */
.message-wrapper {
    display: flex;
    width: 100%;
    max-width: 100%;
    opacity: 0;
    animation: fadeIn 0.35s var(--ease-out) forwards;
}

.message-wrapper.user {
    justify-content: flex-end;
}
.message-wrapper.user .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
}

.message-wrapper.ai {
    justify-content: flex-start;
    padding-left: 0.15rem;
}

.message-content {
    max-width: 100%;
    min-width: 0;
}


/* =========================================
   USER MESSAGE BUBBLE
   ========================================= */
.message.user {
    background: var(--brand-primary);
    color: #ffffff;
    padding: 11px 18px;
    border-radius: 1.15rem;
    border-bottom-right-radius: 0.35rem;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.55;
    max-width: 85%;
    box-shadow: var(--shadow-brand);
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    display: inline-block;
}


/* =========================================
   AI MESSAGE
   ========================================= */
.message.ai {
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    max-width: 100%;
    min-width: 0;
    padding: 4px 0;
    position: relative;
    text-align: left;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    margin-bottom: 0;
}

/* Markdown elements inside AI messages */
.message.ai h1,
.message.ai h2,
.message.ai h3 {
    text-align: left;
    margin-top: 1.25rem;
    margin-bottom: 0.6rem;
    overflow-wrap: break-word;
}

.message.ai p {
    margin-bottom: 0.85rem;
    text-align: left;
    overflow-wrap: break-word;
    word-break: break-word;
}

.message.ai ul,
.message.ai ol {
    text-align: left;
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.message.ai li {
    overflow-wrap: break-word;
    word-break: break-word;
    margin-bottom: 0.25rem;
}

.message.ai blockquote {
    border-left: 3px solid var(--brand-primary);
    padding: 0.6rem 1rem;
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 1rem;
    background: var(--surface-1);
    overflow-wrap: break-word;
}


/* =========================================
   TABLES
   ========================================= */
.message.ai table {
    display: block;
    width: 100%;
    overflow-x: auto;
    background: var(--surface-0);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin: 1.5rem 0;
    border-collapse: separate;
    border-spacing: 0;
    box-shadow: var(--shadow-sm);
}

.message.ai thead {
    background: var(--surface-1);
}

.message.ai th {
    padding: 0.9rem 1.25rem;
    text-align: left;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.message.ai td {
    padding: 0.8rem 1.25rem;
    font-family: var(--font-body);
    font-size: 0.93rem;
    color: var(--text-muted);
    line-height: 1.6;
    border-bottom: 1px solid var(--border-subtle);
    min-width: 120px;
}

.message.ai tr:nth-child(even) td {
    background: var(--surface-1);
}

.message.ai tr:hover td {
    background: var(--surface-2);
    color: var(--text-main);
    transition: background var(--transition-fast) ease,
                color var(--transition-fast) ease;
}

.message.ai tr:last-child td {
    border-bottom: none;
}

/* Table scrollbar */
.message.ai table::-webkit-scrollbar { height: 6px; }
.message.ai table::-webkit-scrollbar-track {
    background: var(--surface-1);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.message.ai table::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 4px;
}
.message.ai table::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}


/* =========================================
   CODE BLOCKS
   ========================================= */

/* Inline code */
.message.ai code:not(pre code) {
    font-family: var(--font-code);
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.18em 0.45em;
    border-radius: 4px;
    font-size: 0.875em;
    overflow-wrap: break-word;
    word-break: break-word;
    border: 1px solid var(--code-border);
}

/* Code block container */
.message.ai .code-block-container {
    margin: 1.5rem 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--code-border);
    max-width: 100%;
    box-sizing: border-box;
    box-shadow: var(--shadow-sm);
}

/* Code block header */
.message.ai .code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--code-header-bg);
    padding: 0.6em 1em;
    border-bottom: 1px solid var(--code-border);
    position: sticky;
    top: 0;
    z-index: 2;
}

.message.ai .lang-name {
    font-size: 0.72rem;
    font-family: var(--font-code);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.message.ai .copy-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.78rem;
    padding: 0.35em 0.75em;
    border-radius: 6px;
    transition: all var(--transition-fast) ease;
    font-family: var(--font-body);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.45em;
}

.message.ai .copy-btn:hover {
    background: var(--surface-2);
    color: var(--text-main);
    border-color: var(--border-subtle);
}

.message.ai .copy-btn.copied {
    color: var(--color-success);
    border-color: var(--color-success);
}

/* Pre block inside container */
.message.ai .code-block-container pre {
    background: var(--hljs-bg);
    margin: 0;
    padding: 1.2rem;
    border-radius: 0;
    border: none;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: pre;
    word-wrap: normal;
    word-break: normal;
}

.message.ai .code-block-container pre code {
    padding: 0;
    background: none;
    border: none;
    color: inherit;
    font-family: var(--font-code);
    font-size: 0.875em;
    line-height: 1.65;
    white-space: inherit;
}

/* Fallback pre (no container) */
.message.ai pre:not(.code-block-container pre) {
    background: var(--hljs-bg);
    border-radius: var(--radius-sm);
    padding: 1.2rem;
    margin: 1rem 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: pre;
    word-wrap: normal;
    word-break: normal;
    border: 1px solid var(--code-border);
    text-align: left;
    position: relative;
    color: var(--code-text);
    box-shadow: var(--shadow-xs);
}

.message.ai pre:not(.code-block-container pre) code {
    font-family: var(--font-code);
    font-size: 0.875em;
    white-space: inherit;
    color: inherit;
    background: none;
    padding: 0;
    border: none;
}

/* Code block scrollbars */
.message.ai pre::-webkit-scrollbar,
.message.ai .code-block-container pre::-webkit-scrollbar {
    height: 6px;
}

.message.ai pre::-webkit-scrollbar-track,
.message.ai .code-block-container pre::-webkit-scrollbar-track {
    background: var(--surface-1);
    border-radius: 4px;
}

.message.ai pre::-webkit-scrollbar-thumb,
.message.ai .code-block-container pre::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 4px;
}

.message.ai pre::-webkit-scrollbar-thumb:hover,
.message.ai .code-block-container pre::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}

/* Force HLJS to respect theme variables in dark modes */
[data-theme="dark"] .message.ai .code-block-container pre,
[data-theme="void"] .message.ai .code-block-container pre {
    background: var(--hljs-bg) !important;
}
[data-theme="dark"] .message.ai .code-block-header,
[data-theme="void"] .message.ai .code-block-header {
    background: var(--code-header-bg) !important;
}


/* =========================================
   AI INDICATOR
   ========================================= */
.ai-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    margin-top: 0.6rem;
    font-size: 0.68rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-family: var(--font-display);
    font-weight: 700;
}

.ai-dot {
    width: 5px;
    height: 5px;
    background: var(--brand-primary);
    border-radius: 50%;
}


/* =========================================
   MESSAGE ACTIONS (Copy, Like, Dislike, Regen)
   ========================================= */
.message-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.65rem;
    margin-bottom: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-subtle);
    opacity: 0.65;
    transition: opacity var(--transition-fast) ease;
}

.message-wrapper.ai:hover .message-actions {
    opacity: 1;
}

.message-wrapper.ai.generating .message-actions {
    display: none;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.83rem;
    padding: 5px 7px;
    border-radius: 6px;
    transition: all var(--transition-fast) ease;
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-body);
    margin-bottom: 0;
}

.action-btn:hover {
    color: var(--brand-primary);
    background: var(--surface-2);
}

.action-btn.active.like-msg {
    color: var(--color-success);
    background: var(--surface-1);
}

.action-btn.active.dislike-msg {
    color: var(--color-error);
    background: var(--surface-1);
}

.feedback-group {
    margin-left: auto;
    display: flex;
    gap: 2px;
}

/* =========================================
   USER ACTIONS (Copy, Edit)
   ========================================= */
.user-actions {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    margin-top: 0.35rem;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity var(--transition-fast) ease;
    padding-right: 0.5rem;
}

.message-wrapper.user:hover .user-actions {
    opacity: 0.75;
}

.user-actions:hover {
    opacity: 1 !important;
}

.user-actions .action-btn {
    padding: 5px 8px;
    font-size: 0.8rem;
    margin-bottom: 0;
    background: transparent;
    border: none;
    color: var(--text-dim);
    height: auto;
    width: auto;
    border-radius: 6px;
}

.user-actions .action-btn:hover {
    background: var(--surface-2);
    color: var(--brand-primary);
}

/* Inline Edit Interface */
.edit-message-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    max-width: 600px;
    align-self: flex-end;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.2s ease-out;
}

.edit-message-textarea {
    width: 100%;
    background: var(--surface-0);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.9rem;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.55;
    resize: none;
    outline: none;
    transition: border-color var(--transition-fast) ease, box-shadow var(--transition-fast) ease;
}

.edit-message-textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px oklch(from var(--brand-primary) l c h / 0.1);
}

.edit-button-group {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

.edit-btn {
    padding: 0.5rem 1.1rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition-fast) ease;
}

.edit-btn.save {
    background: var(--brand-primary);
    color: #ffffff;
    box-shadow: var(--shadow-brand);
}

.edit-btn.save:hover {
    background: var(--brand-hover);
    transform: translateY(-1px);
}

.edit-btn.cancel {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.edit-btn.cancel:hover {
    background: var(--surface-3);
    color: var(--text-main);
}


/* =========================================
   INPUT AREA
   ========================================= */
.input-area {
    position: fixed;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: var(--container-lg);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 500;
    transition: left var(--transition-slow) var(--ease-out),
                width var(--transition-slow) var(--ease-out);
}

.input-area-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: var(--space-3);
    width: 100%;
    max-width: 900px;
}

@media (min-width: 1400px) {
    .chat-container,
    .header-container,
    .input-area-container {
        max-width: 1000px;
    }
}

/* Plus Button */
.plus-btn {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--surface-0);
    color: var(--text-main);
    font-size: var(--text-base);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base) ease;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    position: relative;
    z-index: 601;
}

.plus-btn:hover {
    background: var(--surface-2);
    border-color: var(--border-medium);
    transform: rotate(90deg);
    box-shadow: var(--shadow-md);
}

/* Input Wrapper — Solid Panel */
.input-div-wrapper {
    flex: 1;
    max-width: 800px;
    position: relative;
    background: var(--surface-0);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);

    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;

    padding: 0.5rem 0.55rem 0.5rem 1rem;
    min-height: 3rem;
    height: auto;

    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast) ease,
                box-shadow var(--transition-fast) ease;
}

.input-div-wrapper:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-focus-ring, oklch(48% 0.18 268 / 0.13)),
                var(--shadow-md);
}

/* Chips Container */
.input-chips-container {
    flex-basis: 100%;
    width: 100%;
    order: -1;
    display: none;
}

.input-chips-container:not(:empty) {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.2rem;
}

/* Individual Chip */
.input-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 8px;
    background: var(--brand-surface);
    border: 1px solid var(--brand-primary);
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 0.73rem;
    color: var(--brand-primary);
    font-family: var(--font-display);
    animation: fadeIn 0.2s ease;
}

.chip-close {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity var(--transition-fast) ease;
}
.chip-close:hover { opacity: 1; color: var(--color-error); }

.input-chip[data-type="web"] {
    border-color: #3b82f6;
    color: #3b82f6;
    background: oklch(96% 0.04 240);
}
[data-theme="dark"] .input-chip[data-type="web"],
[data-theme="void"] .input-chip[data-type="web"] {
    background: oklch(18% 0.06 240);
}

.input-chip[data-type="think"] {
    border-color: #ec4899;
    color: #ec4899;
    background: oklch(97% 0.03 330);
}
[data-theme="dark"] .input-chip[data-type="think"],
[data-theme="void"] .input-chip[data-type="think"] {
    background: oklch(18% 0.06 330);
}

/* Textarea */
textarea#main-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 1rem;
    resize: none;
    outline: none;
    line-height: 1.5rem;
    height: 1.5rem;
    max-height: 200px;
    padding: 0;
    margin: 0 0 0.25rem 0;
    overflow-y: hidden;
    min-width: 50px;
}

textarea#main-input::placeholder {
    color: var(--text-dim);
}

/* Send Button */
.send-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--brand-primary);
    color: var(--send-btn-color);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 10px;
    transition: all var(--transition-fast) ease;
    box-shadow: var(--shadow-brand);
}

.send-btn:hover {
    background: var(--brand-hover);
    transform: scale(1.08);
}

.send-btn:disabled {
    background: var(--surface-3);
    color: var(--text-dim);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}


/* =========================================
   PLUS MENU (DropUp) — Solid Panel
   ========================================= */
.plus-menu {
    position: absolute;
    bottom: 100%;
    left: 50%;
    width: 100%;
    max-width: 600px;
    margin-bottom: 1rem;

    /* Solid panel — NO glass */
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);

    padding: 1.25rem;

    /* Hidden state */
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(16px) scale(0.97);
    transition: all 0.28s var(--ease-spring);

    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 600;
    pointer-events: none;
}

.plus-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1);
    pointer-events: auto;
}

/* Grid Row */
.menu-grid-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
}

.menu-grid-item {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: 0.65rem;
    padding: 0.85rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
}

.menu-grid-item.left {
    border-top-left-radius: 2.25rem;
    border-bottom-left-radius: 2.25rem;
}

.menu-grid-item.right {
    border-top-right-radius: 2.25rem;
    border-bottom-right-radius: 2.25rem;
}

.menu-grid-item:hover {
    background: var(--surface-2);
    border-color: var(--border-medium);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.menu-icon-box {
    font-size: 1.4rem;
    color: var(--brand-primary);
}

.menu-grid-item span {
    font-size: 0.78rem;
    font-family: var(--font-body);
    color: var(--text-muted);
}

.menu-divider {
    height: 1px;
    background: var(--border-subtle);
    width: 100%;
}

.menu-list-col {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.menu-list-item {
    background: transparent;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-main);
    text-align: left;
    transition: all var(--transition-fast) ease;
    width: 100%;
}

.menu-list-item:hover {
    background: var(--surface-2);
    border-color: var(--border-subtle);
}

.menu-list-item i {
    font-size: 1rem;
    width: 22px;
    text-align: center;
    color: var(--text-dim);
    transition: color var(--transition-fast) ease;
}

.menu-list-item:hover i {
    color: var(--brand-primary);
}

.menu-list-item span {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
}

/* Active web search state in menu */
.menu-list-item.web-search-active {
    background: oklch(96% 0.04 240) !important;
    border-color: oklch(80% 0.12 240) !important;
}
[data-theme="dark"] .menu-list-item.web-search-active,
[data-theme="void"] .menu-list-item.web-search-active {
    background: oklch(18% 0.06 240) !important;
    border-color: oklch(30% 0.10 240) !important;
}

.menu-list-item.web-search-active i {
    color: #3b82f6 !important;
}


/* =========================================
   MODEL DROPDOWN — Solid Panel
   ========================================= */
.model-dropdown-wrapper {
    position: relative;
}

.model-dropdown {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    width: 300px;

    /* Solid panel — NO glass */
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);

    padding: 0.5rem;
    display: none;
    flex-direction: column;
    gap: 0.2rem;
    z-index: 100;

    /* Scrollable */
    max-height: 340px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-medium) transparent;
}

.model-dropdown.active {
    display: flex;
    animation: fadeIn 0.18s var(--ease-out);
}

.model-dropdown::-webkit-scrollbar { width: 4px; }
.model-dropdown::-webkit-scrollbar-track { background: transparent; }
.model-dropdown::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

.dropdown-header {
    font-size: 0.68rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin: 0.5rem 0.75rem 0.35rem;
    font-family: var(--font-display);
    font-weight: 700;
}

.model-option {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    text-align: left;
}

.model-option:hover {
    background: var(--surface-1);
    border-color: var(--border-subtle);
}

.model-option.active {
    background: var(--surface-2);
    border-color: var(--border-medium);
}

.model-option i {
    font-size: 1rem;
    color: var(--text-dim);
    width: 22px;
    text-align: center;
    transition: color var(--transition-fast) ease;
    flex-shrink: 0;
}

.model-option:hover i,
.model-option.active i {
    color: var(--brand-primary);
}

.model-info {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.model-name {
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 600;
    font-family: var(--font-display);
}

.model-desc {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-family: var(--font-body);
}

@media (max-width: 600px) {
    .model-dropdown {
        width: min(280px, calc(100vw - 2rem));
        right: 0;
        max-height: 280px;
    }
}


/* =========================================
   SYSTEM ALERTS
   ========================================= */
.message-wrapper.system {
    justify-content: center;
    width: 100%;
    margin: 0.75rem 0;
    padding: 0 var(--space-4);
}

.system-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.9rem 1.2rem;
    border-radius: var(--radius-md);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    line-height: 1.55;
    color: var(--text-muted);
    max-width: 600px;
    width: 100%;
    box-shadow: var(--shadow-xs);
    animation: fadeIn 0.3s ease-out forwards;
}

.system-alert i {
    font-size: 1.05rem;
    margin-top: 2px;
    flex-shrink: 0;
}

.system-alert.error {
    background: oklch(98% 0.02 25);
    border-color: oklch(88% 0.08 25);
    color: var(--text-main);
}
[data-theme="dark"] .system-alert.error,
[data-theme="void"] .system-alert.error {
    background: oklch(16% 0.05 25);
    border-color: oklch(26% 0.10 25);
}
.system-alert.error i { color: var(--color-error); }

.system-alert.warning {
    background: oklch(98.5% 0.02 85);
    border-color: oklch(90% 0.08 85);
    color: var(--text-main);
}
[data-theme="dark"] .system-alert.warning,
[data-theme="void"] .system-alert.warning {
    background: oklch(16% 0.05 85);
    border-color: oklch(26% 0.10 85);
}
.system-alert.warning i { color: var(--color-warning); }

.system-alert.info {
    background: oklch(98% 0.02 240);
    border-color: oklch(88% 0.08 240);
    color: var(--text-main);
}
[data-theme="dark"] .system-alert.info,
[data-theme="void"] .system-alert.info {
    background: oklch(16% 0.05 240);
    border-color: oklch(26% 0.10 240);
}
.system-alert.info i { color: var(--color-info); }

.system-alert.success {
    background: oklch(98% 0.02 148);
    border-color: oklch(88% 0.08 148);
    color: var(--text-main);
}
[data-theme="dark"] .system-alert.success,
[data-theme="void"] .system-alert.success {
    background: oklch(16% 0.05 148);
    border-color: oklch(26% 0.10 148);
}
.system-alert.success i { color: var(--color-success); }


/* =========================================
   RENAME MODAL
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base) ease,
                visibility var(--transition-base) ease;
}

[data-theme="void"] .modal-overlay {
    background: rgba(0, 0, 0, 0.70);
}

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

.modal-container {
    /* Solid panel — NO glass */
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-xl);

    transform: scale(0.96) translateY(16px);
    transition: transform var(--transition-slow) var(--ease-spring);
}

.modal-overlay.active .modal-container {
    transform: scale(1) translateY(0);
}

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

.modal-header h3 {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.modal-close-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--surface-1);
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast) ease;
}

.modal-close-btn:hover {
    background: var(--surface-2);
    color: var(--color-error);
    border-color: oklch(from var(--color-error) l c h / 0.5);
}

.modal-body {
    padding: var(--space-4);
}

.modal-input {
    width: 100%;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: var(--text-base);
    outline: none;
    transition: border-color var(--transition-fast) ease,
                box-shadow var(--transition-fast) ease;
}

.modal-input:focus {
    border-color: var(--brand-primary);
    background: var(--surface-0);
    box-shadow: 0 0 0 3px oklch(from var(--brand-primary) l c h / 0.10);
}

.modal-input::placeholder {
    color: var(--text-dim);
}

.modal-warning {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-muted);
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 0;
}

.modal-warning i {
    color: var(--color-warning);
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 2px;
}

#delete-chat-name {
    color: var(--text-main);
    font-weight: 600;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.65rem;
    padding: var(--space-4);
    border-top: 1px solid var(--border-subtle);
}

.modal-btn {
    padding: 0.6rem 1.35rem;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    border: 1px solid transparent;
}

.modal-btn.secondary {
    background: var(--surface-1);
    color: var(--text-main);
    border-color: var(--border-subtle);
}
.modal-btn.secondary:hover {
    background: var(--surface-2);
    border-color: var(--border-medium);
}

.modal-btn.primary {
    background: var(--brand-primary);
    color: #ffffff;
}
.modal-btn.primary:hover {
    background: var(--brand-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-brand);
}

.modal-btn.danger {
    background: var(--color-error);
    color: #ffffff;
}
.modal-btn.danger:hover {
    background: oklch(48% 0.22 25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px oklch(from var(--color-error) l c h / 0.30);
}


/* =========================================
   AUTH MODAL — Solid Panel
   ========================================= */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base) ease;
}

[data-theme="void"] .auth-modal {
    background: rgba(0, 0, 0, 0.72);
}

.auth-modal.active {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.auth-content {
    /* Solid panel — NO glass */
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96) translateY(16px);
    transition: transform var(--transition-slow) var(--ease-spring);
}

.auth-modal.active .auth-content {
    transform: scale(1) translateY(0);
}

.auth-header {
    padding: 1.4rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.auth-header h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--text-main);
    margin: 0;
}

.close-popup {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-popup:hover {
    background: var(--surface-2);
    color: var(--color-error);
}

.auth-body {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.auth-body .input-group {
    margin-bottom: 0.75rem;
}

.auth-body label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    text-align: left;
    font-family: var(--font-display);
    font-weight: 700;
}

.auth-body input {
    width: 100%;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.92rem;
    outline: none;
    transition: all var(--transition-fast) ease;
}

.auth-body input:focus {
    border-color: var(--brand-primary);
    background: var(--surface-0);
    box-shadow: 0 0 0 3px oklch(from var(--brand-primary) l c h / 0.10);
}

.auth-button {
    width: 100%;
    padding: 0.85rem;
    border-radius: var(--radius-md);
    border: none;
    background: var(--brand-primary);
    color: #ffffff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-fast) ease;
    margin-top: 0.4rem;
    box-shadow: var(--shadow-brand);
}

.auth-button:hover {
    background: var(--brand-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-brand), var(--shadow-md);
}

.auth-switch {
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
}

.auth-switch a {
    color: var(--brand-primary);
    cursor: pointer;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-error {
    color: var(--color-error);
    font-size: 0.82rem;
    text-align: center;
    background: oklch(98% 0.02 25);
    border: 1px solid oklch(88% 0.08 25);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    display: none;
}
[data-theme="dark"] .auth-error,
[data-theme="void"] .auth-error {
    background: oklch(16% 0.05 25);
    border-color: oklch(26% 0.10 25);
}


/* =========================================
   WEB SEARCH BADGE
   ========================================= */
.web-search-badge {
    background: oklch(95% 0.04 240);
    border: 1px solid oklch(78% 0.12 240);
    color: #3b82f6;
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    cursor: default;
    user-select: none;
}

[data-theme="dark"] .web-search-badge,
[data-theme="void"] .web-search-badge {
    background: oklch(18% 0.06 240);
    border-color: oklch(32% 0.12 240);
}

.chip-close-btn {
    background: transparent;
    border: none;
    color: #3b82f6;
    cursor: pointer;
    padding: 0;
    width: 1.1rem;
    height: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast) ease;
    font-size: 0.8rem;
}

.chip-close-btn:hover {
    background: oklch(88% 0.10 240);
    transform: scale(1.1);
}


/* =========================================
   SEARCH RESULTS PANEL — Solid
   ========================================= */
.search-results-container {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 0.75rem 0;
    max-width: 100%;
    box-shadow: var(--shadow-xs);
}

.search-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.7rem;
    margin-bottom: 0.7rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: var(--font-display);
}

.search-header i {
    color: var(--brand-primary);
    font-size: 0.9rem;
}

.search-result-item {
    display: flex;
    gap: 0.7rem;
    padding: 0.7rem;
    margin-bottom: 0.4rem;
    border-radius: var(--radius-sm);
    background: var(--surface-0);
    border: 1px solid var(--border-subtle);
    transition: all var(--transition-fast) ease;
}

.search-result-item:hover {
    background: var(--surface-2);
    border-color: var(--border-medium);
    transform: translateX(2px);
}

.search-result-item:last-child {
    margin-bottom: 0;
}

.result-index {
    min-width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-primary);
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

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

.result-title {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--brand-primary);
    text-decoration: none;
    margin-bottom: 0.2rem;
    transition: all var(--transition-fast) ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.result-title:hover {
    text-decoration: underline;
}

.result-title i {
    font-size: 0.65rem;
    opacity: 0.6;
}

.result-source {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
    font-family: var(--font-code);
}

.result-snippet {
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--text-muted);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-no-results {
    padding: 1.75rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    background: var(--surface-1);
    border: 1px dashed var(--border-medium);
    border-radius: var(--radius-md);
}


/* =========================================
   COLLAPSIBLE SEARCH TOGGLE
   ========================================= */
.search-results-toggle-container {
    margin: 1rem 0 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-1);
    overflow: hidden;
    transition: all var(--transition-base) ease;
    box-shadow: var(--shadow-xs);
}

.search-toggle-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.8rem 1.2rem;
    background: var(--surface-2);
    border: none;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    transition: all var(--transition-fast) ease;
    position: relative;
}

.search-toggle-btn:hover {
    background: var(--surface-3);
    color: var(--brand-primary);
}

.search-toggle-btn i:first-child {
    color: var(--brand-primary);
    font-size: 0.95rem;
}

.search-toggle-btn span {
    flex: 1;
    text-align: left;
}

.toggle-icon {
    font-size: 0.8rem;
    color: var(--text-dim);
    transition: transform var(--transition-base) ease;
}

.search-results-toggle-container.expanded .toggle-icon {
    transform: rotate(180deg);
}

.search-results-toggle-container.expanded .search-toggle-btn {
    border-bottom-color: var(--border-subtle);
}

.search-results-collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-results-toggle-container.expanded .search-results-collapsible {
    max-height: 2000px;
}

.search-results-collapsible .search-results-container {
    margin: 0;
    padding: 1rem 1.2rem;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.ai-response-content {
    margin-top: 0.5rem;
}

/* KaTeX Overrides for Design System */
.katex-display {
    margin: 1.25rem 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.75rem 0.5rem;
    text-align: center;
    background: var(--surface-1);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.katex {
    font-size: 1.05em;
    color: var(--text-main);
    line-height: 1.2;
}

/* Ensure math doesn't overflow container */
.message.ai .katex-display > .katex {
    white-space: normal;
}

/* Chemistry / Science specific spacing */
.katex .mchem {
    padding: 0 0.1em;
}

/* Scrollbar for long equations */
.katex-display::-webkit-scrollbar { height: 4px; }
.katex-display::-webkit-scrollbar-track { background: transparent; }
.katex-display::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 10px;
}

/* Source count badge */
.search-toggle-btn::after {
    content: attr(data-count);
    background: var(--brand-primary);
    color: white;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-pill);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.search-toggle-btn[data-count]::after {
    opacity: 1;
}


/* =========================================
   FOOTER PILL (legacy, keep for compat)
   ========================================= */
.footer-pill {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    padding: 0.5rem 1.4rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background var(--transition-fast) ease;
}

.footer-pill:hover {
    background: var(--surface-2);
}

.footer-text {
    font-size: var(--text-xs);
    color: var(--text-muted);
    font-family: var(--font-body);
}


/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 600px) {
    :root { --space-4: 1rem; }

    .floating-header {
        width: 95%;
        top: 0.85rem;
    }

    .chat-container {
        padding-top: 88px;
        padding-bottom: 96px;
    }

    .message.user {
        max-width: 88%;
    }

    .input-area {
        width: 95%;
        bottom: 0.85rem;
    }

    .header-right .icon-btn {
        width: 1.85rem;
        height: 1.85rem;
    }

    .plus-menu {
        border-radius: var(--radius-lg);
    }

    .search-results-toggle-container {
        margin: 0.75rem 0 1.25rem;
    }

    .search-toggle-btn {
        font-size: 0.82rem;
        padding: 0.7rem 1rem;
    }

    .search-results-collapsible .search-results-container {
        padding: 0.75rem 1rem;
    }

    .search-result-item {
        flex-direction: column;
        gap: 0.45rem;
    }

    .result-snippet {
        -webkit-line-clamp: 2;
    }
}