/* Import Fonts */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cascadia+Code:wght@400;500;600&display=swap');

/* =========================================
   USER PROVIDED VARIABLES (RAZEN CORE)
   ========================================= */
:root {
    /* 1. CORE BRAND COLORS (OKLCH) */
    --brand-primary: oklch(75% 0.15 260);
    --brand-hover: oklch(78% 0.15 260);
    --brand-surface: oklch(96% 0.03 260);

    /* 2. SEMANTIC STATUS COLORS (OKLCH) */
    --color-success: oklch(75% 0.18 145);
    --color-warning: oklch(85% 0.18 85);
    --color-error: oklch(65% 0.20 25);
    --color-info: oklch(70% 0.18 240);

    /* 3. THE VOID BACKGROUND */
    --primary-bg: oklch(18% 0.02 265);
    
    /* Layered Surfaces */
    --surface-1: rgba(255, 255, 255, 0.03);
    --surface-2: rgba(255, 255, 255, 0.05);
    --surface-3: rgba(255, 255, 255, 0.08);
    --surface-input: rgba(0, 0, 0, 0.2);
    --bg-glass-panel: rgba(30, 30, 35, 0.7); /* Fallback/Dark default */
    --bg-code: #282c34;

    /* Gradient Background */
    --bg-void-gradient: radial-gradient(circle at center, oklch(22% 0.04 270) 0%, var(--primary-bg) 80%);
    
    /* 4. TYPOGRAPHY & TEXT */
    --text-main: oklch(98% 0.01 265);
    --text-muted: oklch(75% 0.03 265);
    --text-dim: oklch(55% 0.02 265);

    /* Font Families */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Manrope', sans-serif;
    --font-code: '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;

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

    /* 5. BORDERS & SHADOWS */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: var(--brand-primary);
    --border-strong: rgba(255, 255, 255, 0.2);

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.2);

    /* 6. SPACING & LAYOUT */
    --radius-sm: 1rem;
    --radius-md: 1.5rem;
    --radius-lg: 2rem;
    --radius-pill: 9rem;
    --radius-card: 3rem;

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

    /* Container Widths */
    --container-md: 900px;
    --container-lg: 1100px;

    /* 7. ANIMATION */
    --ease-out: cubic-bezier(0.215, 0.61, 0.355, 1);
    --glass-blur: 16px;
}

[data-theme="light"] {
    /* 1. CORE BRAND COLORS (OKLCH) */
    --brand-primary: oklch(55% 0.20 260);
    --brand-hover: oklch(50% 0.22 260);
    --brand-surface: oklch(96% 0.03 260);
    
    /* 2. SEMANTIC STATUS COLORS (OKLCH) */
    --color-success: oklch(55% 0.18 145);
    --color-warning: oklch(65% 0.18 85);
    --color-error: oklch(55% 0.20 25);
    --color-info: oklch(55% 0.18 240);
    
    /* 3. LIGHT BACKGROUND */
    --primary-bg: oklch(98% 0.01 260);
    
    /* Layered Surfaces (Now Black Alpha for contrast on White) */
    --surface-1: rgba(0, 0, 0, 0.03); 
    --surface-2: rgba(0, 0, 0, 0.05);
    --surface-3: rgba(0, 0, 0, 0.08);
    --surface-input: rgba(0, 0, 0, 0.05);
    --bg-glass-panel: rgba(255, 255, 255, 0.85); /* White Glass */
    --bg-code: #f3f4f6; /* Light Grey Code Block */
    
    /* Gradient Background */
    --bg-void-gradient: radial-gradient(circle at center, oklch(96% 0.02 270) 0%, var(--primary-bg) 80%);
    
    /* 4. TYPOGRAPHY & TEXT */
    --text-main: oklch(20% 0.02 260);
    --text-muted: oklch(45% 0.03 260);
    --text-dim: oklch(60% 0.02 260);
    
    /* 5. BORDERS & SHADOWS */
    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-focus: var(--brand-primary);
    --border-strong: rgba(0, 0, 0, 0.15);
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.15);
}

[data-theme="dark"] {
    /* 1. CORE BRAND COLORS (OKLCH) */
    --brand-primary: oklch(70% 0.18 260);
    --brand-hover: oklch(75% 0.18 260);
    --brand-surface: oklch(25% 0.03 260);
    
    /* 2. SEMANTIC STATUS COLORS (OKLCH) */
    --color-success: oklch(70% 0.18 145);
    --color-warning: oklch(80% 0.18 85);
    --color-error: oklch(60% 0.20 25);
    --color-info: oklch(65% 0.18 240);
    
    /* 3. DARK BACKGROUND */
    --primary-bg: oklch(25% 0.02 260);
    
    /* Layered Surfaces (White Alpha for contrast on Dark) */
    --surface-1: rgba(255, 255, 255, 0.05);
    --surface-2: rgba(255, 255, 255, 0.08);
    --surface-3: rgba(255, 255, 255, 0.12);
    --surface-input: rgba(0, 0, 0, 0.25);
    --bg-glass-panel: rgba(30, 30, 35, 0.85); /* Dark Glass */
    --bg-code: #282c34; /* Dark Code Block */
    
    /* Gradient Background */
    --bg-void-gradient: radial-gradient(circle at center, oklch(28% 0.04 270) 0%, var(--primary-bg) 80%);
    
    /* 4. TYPOGRAPHY & TEXT */
    --text-main: oklch(95% 0.01 260);
    --text-muted: oklch(70% 0.03 260);
    --text-dim: oklch(55% 0.02 260);
    
    /* 5. BORDERS & SHADOWS */
    --border-subtle: rgba(255, 255, 255, 0.10);
    --border-focus: var(--brand-primary);
    --border-strong: rgba(255, 255, 255, 0.20);
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.40);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.25);
}

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

h1, h2, h3, h4, h5, h6 { 
    font-family: 'Space Grotesk', sans-serif; 
    font-weight: 700;
    color: var(--text-main);
    text-align: center;
}

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

code, pre { font-family: 'Cascadia Code', monospace; }
button, a { font-family: 'Space Grotesk', sans-serif; font-weight: 600; text-decoration: none; }

/* ===== BODY: KEEP ORIGINAL - DO NOT CHANGE! ===== */
body {
    background-color: var(--primary-bg);
    background-image: var(--bg-void-gradient);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased; 
    height: 100vh;
    overflow: hidden; /* MUST STAY - This is your fixed layout design */
    display: flex;
    flex-direction: column;
}

/* =========================================
   MINIMALIST SIDEBAR (Floating Pill Logic)
   ========================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Seamless Background - Matches Chat Container exactly */
    background: var(--bg-void-gradient);
    /* Very subtle blur just for text readability */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.5s var(--ease-out);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-subtle);
}

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

/* Floating Header Pill inside Sidebar */
.sidebar-header-wrapper {
    padding: var(--space-3);
    display: flex;
    justify-content: space-between; /* Center the pill */
    align-items: center;
    margin: 0.5rem 0 0 0;
}

.sidebar-pill-header {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Glass Pill Style */
    border: 1px solid var(--border-subtle);
    background: var(--surface-2);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    color: var(--text-main);
    font-size: var(--text-lg);
    cursor: pointer;
    border-radius: var(--radius-pill);
    padding: 0.5rem 1rem;
    gap: 1.5rem;
    box-shadow: var(--shadow-sm);
    width: 100%;
    height: 3rem;
    max-width: 8rem; /* Constraint width */
}

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

/* Reuse Icon Button Logic for Sidebar Close */
.close-sidebar-btn {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--surface-2);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    color: var(--text-main);
    font-size: var(--text-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

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

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) var(--space-4); /* Compact padding */
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.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.1em;
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.history-grid {
    display: flex;
    flex-direction: column;
    gap: 0.25rem; /* Compact gap */
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.8rem; /* Compact padding */
    border-radius: var(--radius-pill); /* Fully rounded pill */
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-body);
    font-size: var(--text-md); /* Smaller font */
    color: var(--text-muted);
    border: 1px solid transparent;
}

/* Hover State */
.history-item:hover {
    color: var(--text-main);
    background: var(--surface-1);
    transform: translateX(4px);
}

/* Active Chat State ("Slaps") */
.history-item.active {
    background: var(--surface-2);
    border-color: var(--border-subtle);
    color: var(--text-main);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.history-item i {
    font-size: var(--text-lg);
    opacity: 0.6;
    width: 16px;
    text-align: center;
}

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


.footer-pill {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    padding: 0.5rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

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

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

.icon-btn.standalone {
    width: 3rem; 
    height: 3rem;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--surface-2);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    color: var(--text-main);
    font-size: var(--text-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin: 0;
    box-shadow: var(--shadow-lg);
}

.icon-btn.standalone:hover {
    background: var(--surface-3);
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    transform: translateY(-1px);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem; 
    
    background: var(--surface-2);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill); 
    padding: 0.5rem; 
    box-shadow: var(--shadow-lg);
}

.header-right .icon-btn {
    width: 3rem; 
    height: 3rem;
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    color: var(--text-main); 
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0;
}

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

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

.header-right .icon-btn.active {
    background: var(--brand-surface); /* Uses variable now */
    color: var(--brand-primary);
}

.icon-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    pointer-events: none;
}

/* =========================================
   MAIN CHAT AREA - HORIZONTAL OVERFLOW FIX
   ========================================= */
.chat-container {
    flex: 1;
    width: 100%;
    max-width: var(--container-md);
    margin: 0 auto;
    padding: 100px var(--space-4) 100px var(--space-4);
    overflow-y: auto; /* Vertical scroll - KEEP */
    overflow-x: hidden; /* ✅ FIX: Prevent horizontal scroll */
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    scroll-behavior: smooth;
}

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

/* ✅ FIX: Contain message wrapper */
.message-wrapper {
    display: flex;
    width: 100%;
    max-width: 100%; /* Prevent expansion beyond container */
    opacity: 0;
    animation: fadeIn 0.4s forwards;
}
@keyframes fadeIn { to { opacity: 1; transform: translateY(0); } }

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

/* ✅ FIX: Contain message-content (wrapper for AI messages) */
.message-content {
    max-width: 100%;
    min-width: 0; /* Allow flex shrinking */
    width: 100%;
}

/* =========================================
   USER MESSAGE (Fixed Alignment)
   ========================================= */
.message.user {
    /* Base Styles */
    background: var(--brand-primary);
    color: white; /* Keep white for contrast on brand color */
    padding: 12px 20px;
    
    /* Rounded Corners */
    border-radius: 1.5rem;
    border-bottom-right-radius: 0.25rem; /* Bubble effect */
    
    /* Typography */
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.5;
    
    /* Layout & Sizing */
    max-width: 75%;
    box-shadow: var(--shadow-glow);
    transition: border-radius 0.2s ease;
    
    /* FIX: Force text to align left inside the bubble */
    text-align: left; 
    
    /* FIX: Handle spacing & wrapping perfectly */
    white-space: pre-wrap;  /* Preserves Enters/Newlines */
    word-break: break-word; /* Prevents overflow */
    display: inline-block;  /* Wraps tightly around text */
}

/* ✅ CRITICAL FIXES FOR AI MESSAGES */
.message.ai {
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    max-width: 100%; /* ✅ FIX: Use full available width */
    min-width: 0; /* ✅ FIX: Allow shrinking */
    padding: 4px 0;
    position: relative;
    text-align: left;
    
    /* ✅ CRITICAL: Text wrapping for long words/URLs */
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* Markdown Styles for AI Messages */
.message.ai h1, .message.ai h2, .message.ai h3 { 
    text-align: left; 
    margin-top: 1rem; 
    margin-bottom: 0.5rem;
    overflow-wrap: break-word; /* ✅ FIX */
}

.message.ai p { 
    margin-bottom: 0.8rem; 
    text-align: left;
    overflow-wrap: break-word; /* ✅ FIX */
    word-break: break-word; /* ✅ FIX */
}

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

.message.ai li {
    overflow-wrap: break-word; /* ✅ FIX */
    word-break: break-word; /* ✅ FIX */
}

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

/* ✅ FIX: Inline code */
.message.ai code:not(pre code) {
    overflow-wrap: break-word;
    word-break: break-word;
    background: var(--surface-2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--text-main);
}

/* ✅ FIX: Tables */
.message.ai table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    margin: 1rem 0;
}

/* =========================================
   ✅ CRITICAL FIX: CODE BLOCK HORIZONTAL SCROLL
   ========================================= */
.message.ai pre {
    background: var(--bg-code); /* ✅ FIXED: Uses variable for light/dark mode */
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    
    /* ✅ CRITICAL: Constrain to parent width */
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    
    /* ✅ CRITICAL: Enable horizontal scroll */
    overflow-x: auto;
    overflow-y: hidden;
    
    /* ✅ CRITICAL: Preserve code formatting */
    white-space: pre;
    word-wrap: normal;
    word-break: normal;
    
    border: 1px solid var(--border-subtle);
    text-align: left;
    position: relative;
    color: var(--text-main); /* Ensure text is visible in light mode */
}

.message.ai code {
    font-family: 'Cascadia Code', monospace;
    font-size: 0.9em;
    white-space: inherit;
    color: inherit;
}

/* Custom Scrollbar for Code Blocks */
.message.ai pre::-webkit-scrollbar {
    height: 8px;
}
.message.ai pre::-webkit-scrollbar-track {
    background: var(--surface-1);
    border-radius: 4px;
}
.message.ai pre::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: 4px;
}
.message.ai pre::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}


.ai-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.ai-dot {
    width: 5px;
    height: 5px;
    background: var(--brand-primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--brand-primary);
}

/* =========================================
   INPUT AREA (Fixed with Chips)
   ========================================= */
.input-area {
    position: fixed;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: var(--container-lg);
    display: flex;
    align-items: flex-end; /* Keeps buttons anchored at bottom */
    gap: var(--space-3);
    z-index: 500;
}

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

.plus-btn:hover {
    background: var(--surface-3);
    transform: rotate(90deg);
}

/* Wrapper - The Pill Container */
.input-div-wrapper {
    flex: 1;
    position: relative;
    background: var(--surface-2);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--border-subtle);
    border-radius: 1.5rem; 
    
    /* KEY FOR STACKING: Allow wrap */
    display: flex;
    flex-wrap: wrap; 
    align-items: flex-end; 
    
    padding: 0.5rem 0.55rem 0.5rem 1rem; 
    
    min-height: 3rem; 
    height: auto;
    
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-div-wrapper:focus-within {
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
    border-color: var(--brand-primary);
}

/* CHIPS CONTAINER (Hidden by default to save space) */
.input-chips-container {
    flex-basis: 100%; 
    width: 100%; 
    order: -1;
    /* KEY: This ensures 3rem height when empty */
    display: none; 
}

/* Show only when chips are added */
.input-chips-container:not(:empty) {
    display: flex; 
    flex-wrap: wrap; 
    gap: 0.5rem;
    margin-bottom: 0.5rem; /* Push text down */
    padding-bottom: 0.2rem;
}

/* CHIP STYLE */
.input-chip {
    display: flex; align-items: center; gap: 0.5rem;
    margin-top: 8px;
    background: rgba(139, 92, 246, 0.15); /* Brand tint */
    border: 1px solid var(--brand-primary);
    padding: 4px 10px; border-radius: 12px;
    font-size: 0.75rem; color: var(--brand-primary); font-family: var(--font-display);
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
.chip-close { cursor: pointer; opacity: 0.6; transition: 0.2s; }
.chip-close:hover { opacity: 1; color: var(--color-error); }

.input-chip[data-type="web"] { border-color: #3b82f6; color: #3b82f6; background: rgba(59, 130, 246, 0.1); }
.input-chip[data-type="think"] { border-color: #ec4899; color: #ec4899; background: rgba(236, 72, 153, 0.1); }

/* Text Area */
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;
    
    /* CONSTANT LINE HEIGHT */
    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(--text-main);
    border: none;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 10px;
    transition: all 0.2s ease;
}

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

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

/* Responsive */
@media (max-width: 600px) {
    :root { --space-4: 1rem; }
    .floating-header { width: 95%; top: 1rem; }
    .chat-container { padding-top: 90px; padding-bottom: 90px; }
    .message.user { max-width: 85%; }
    .input-area { width: 95%; }
    .header-right .icon-btn { width: 32px; height: 32px; }
}

/* =========================================
   PLUS BUTTON MENU (DropUp)
   ========================================= */
.plus-menu {
    position: absolute;
    bottom: 100%; /* Sits exactly on top of the input area */
    left: 0;
    width: 100%;
    margin-bottom: 1rem; /* Space between input and menu */
    
    background: var(--bg-glass-panel); /* ✅ FIXED: Uses variable to switch themes */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: 2rem; /* Matches your Input Radius */
    
    padding: 1.25rem;
    
    /* Animation State (Hidden by default) */
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.98);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy pop-up */
    
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 600;
    pointer-events: none;
}

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

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

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

.menu-grid-item.left {
    border-top-left-radius: 2.5rem;
    border-bottom-left-radius: 2.5rem;
    margin-right: -0.25rem;
}

.menu-grid-item.right {
    border-top-right-radius: 2.5rem;
    border-bottom-right-radius: 2.5rem;
    margin-left: -0.25rem;
}

.menu-grid-item:hover {
    background: var(--surface-2);
    transform: translateY(-2px);
}

.menu-icon-box {
    font-size: 1.5rem;
    color: var(--brand-primary);
    margin-bottom: 2px;
}

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

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

/* --- Row 2: List Items --- */
.menu-list-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-list-item {
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    cursor: pointer;
    color: var(--text-main);
    text-align: left;
    transition: background 0.2s;
    width: 100%;
}

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

.menu-list-item i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    color: var(--text-dim);
    transition: color 0.2s;
}

.menu-list-item:hover i {
    color: var(--brand-primary); /* Icon glows on hover */
}

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

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

.footer-settings-btn {
    width: 3rem; height: 3rem; border-radius: 50%;
    border: 1px solid var(--border-subtle); background: var(--surface-2);
    color: var(--text-muted); font-size: 1.1rem; backdrop-filter: blur(var(--glass-blur));
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.3s ease; flex-shrink: 0;
}
.footer-settings-btn:hover { background: var(--surface-3); color: var(--text-main); transform: rotate(45deg); border-color: rgba(255, 255, 255, 0.2); }

.footer-login-btn {
    flex: 1; height: 3rem; 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.95rem;
    backdrop-filter: blur(var(--glass-blur)); cursor: pointer; display: flex; align-items: center;
    justify-content: center; gap: 0.75rem; transition: all 0.3s ease;
}
.footer-login-btn:hover { background: var(--brand-primary); border-color: var(--brand-primary); color: white; transform: translateY(-1px); }

/* =========================================
   MODEL DROPDOWN (Matches Plus Menu Style)
   ========================================= */
.model-dropdown-wrapper {
    position: relative;
}

.model-dropdown {
    position: absolute;
    top: 120%;
    right: 0;
    width: 300px;
    
    /* EXACT MATCH: Plus Menu Background */
    background: var(--bg-glass-panel); /* ✅ FIXED */
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    
    border: 1px solid var(--border-subtle);
    border-radius: 2rem;
    padding: 0.85rem;
    
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    
    /* EXACT MATCH: Plus Menu Shadow */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    
    /* Animation */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 600;
    margin-top: 1rem;
    margin-right: 0.1rem;
}

.model-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown Header */
.dropdown-header {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0.25rem 0.75rem 0.5rem;
    font-family: var(--font-display);
    font-weight: 600;
}

/* Model Option (Matches menu-list-item style) */
.model-option {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 2rem;
    padding: 0.75rem 1rem;
    
    display: flex;
    align-items: center;
    gap: 0.85rem;
    
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

/* Hover State - EXACT MATCH */
.model-option:hover {
    background: var(--surface-1);
}

/* Active State - Subtle Purple Highlight */
.model-option.active {
    background: var(--surface-2);
    border-color: var(--border-subtle);
}

/* Icon Styling - EXACT MATCH */
.model-option i {
    font-size: 1.1rem;
    color: var(--text-dim);
    width: 24px;
    text-align: center;
    transition: color 0.2s ease;
}

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

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

/* Model Info Container */
.model-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

/* Model Name - EXACT MATCH */
.model-name {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 600;
    font-family: var(--font-display);
}

/* Model Description */
.model-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-body);
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .model-dropdown {
        width: 240px;
        right: -10px;
    }
}

/* =========================================
   MODALS (Rename & Delete)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75); /* Standard Overlay stays dark */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal-container {
    background: var(--bg-glass-panel); /* ✅ FIXED: Uses variable */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow-lg);
    
    /* Animation */
    transform: scale(0.95) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Modal Header */
.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: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

/* Modal Body */
.modal-body {
    padding: var(--space-4);
}

.modal-input {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: var(--text-base);
    outline: none;
    transition: all 0.2s ease;
}

.modal-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.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.25rem;
    flex-shrink: 0;
    margin-top: 2px;
}

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

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

.modal-btn {
    padding: 0.65rem 1.5rem;
    border-radius: var(--radius-lg);
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s 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);
}

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

.modal-btn.primary:hover {
    background: var(--brand-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

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

.modal-btn.danger:hover {
    background: oklch(60% 0.22 25);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* =========================================
   HISTORY ITEM ACTIONS (3-dot menu)
   ========================================= */
.history-item {
    position: relative;
}

.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.25rem;
    transition: opacity 0.2s ease;
}

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

.history-action-btn {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 12px;
    background: transparent;
    border: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.history-action-btn.delete:hover {
    color: var(--color-error);
    border-color: var(--color-error);
    background: rgba(220, 38, 38, 0.1); /* Keep red tint for danger */
}

/* =========================================
   AUTH MODAL STYLING (Glassmorphism)
   ========================================= */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6); /* Dim background */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 3000; /* Highest priority */
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.auth-content {
    background: var(--bg-glass-panel); /* Matches Settings Panel */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Header */
.auth-header {
    padding: 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.25rem;
    color: var(--text-main);
    margin: 0;
}

.close-popup {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
    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);
}

/* Body */
.auth-body {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

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

.auth-body input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0.8rem 1rem;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.auth-body input:focus {
    border-color: var(--brand-primary);
    background: var(--input-bg-focus);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.1);
}

/* Buttons */
.auth-button {
    width: 100%;
    padding: 0.9rem;
    border-radius: var(--radius-lg);
    border: none;
    background: var(--brand-primary);
    color: white; /* Always white for contrast */
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.auth-button:hover {
    background: var(--brand-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* Switch Text */
.auth-switch {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 1rem;
}

.auth-switch a {
    color: var(--brand-primary);
    cursor: pointer;
    text-decoration: none;
}

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

/* Error Message (Dynamic) */
.auth-error {
    color: var(--color-error);
    font-size: 0.85rem;
    text-align: center;
    background: rgba(220, 38, 38, 0.1);
    padding: 0.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: none;
}
