/* ═══════════════════════════════════════════════════════════════
   NexusAI — Design System & Styles
   Theme: Deep blue / cyan accent (chat) · Purple/indigo (auth)
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ───────────────────────────────────────────── */
:root {
    /* ── Auth palette (purple — unchanged) ──────────────────── */
    --purple-50:  #f5f3ff;
    --purple-100: #ede9fe;
    --purple-200: #ddd6fe;
    --purple-300: #c4b5fd;
    --purple-400: #a78bfa;
    --purple-500: #8b5cf6;
    --purple-600: #7c3aed;
    --purple-700: #6d28d9;
    --purple-800: #5b21b6;
    --purple-900: #4c1d95;

    --indigo-400: #818cf8;
    --indigo-500: #6366f1;
    --indigo-600: #4f46e5;

    /* ── Chat palette (blue / cyan) ────────────────────────── */
    --blue-50:  #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --blue-900: #1e3a8a;

    --cyan-400: #22d3ee;
    --cyan-500: #06b6d4;

    /* ── Surfaces ──────────────────────────────────────────── */
    --bg-primary:   #0a0d14;
    --bg-secondary: #0f1320;
    --bg-tertiary:  #151a2e;
    --bg-elevated:  #1c2240;
    --bg-hover:     #232a4a;
    --bg-input:     #111628;

    /* ── Text ──────────────────────────────────────────────── */
    --text-primary:   #e8eaf0;
    --text-secondary: #9ca3b8;
    --text-muted:     #5b6380;
    --text-accent:    var(--blue-400);

    /* ── Borders ───────────────────────────────────────────── */
    --border-subtle:  rgba(59, 130, 246, 0.10);
    --border-default: rgba(59, 130, 246, 0.20);
    --border-hover:   rgba(59, 130, 246, 0.35);

    /* ── Gradients ─────────────────────────────────────────── */
    --gradient-brand-auth: linear-gradient(135deg, var(--purple-500), var(--indigo-500));
    --gradient-brand: linear-gradient(135deg, var(--blue-500), var(--cyan-500));
    --gradient-glow:  linear-gradient(135deg, rgba(59,130,246,0.12), rgba(6,182,212,0.12));

    /* ── Shadows ───────────────────────────────────────────── */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
    --shadow-md:  0 4px 14px rgba(0,0,0,0.4);
    --shadow-lg:  0 10px 40px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 30px rgba(59,130,246,0.12);

    /* ── Sizing ────────────────────────────────────────────── */
    --sidebar-width: 280px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* ── Transitions ───────────────────────────────────────── */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration: 0.3s;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, textarea { font-family: inherit; }

/* ── Page System ─────────────────────────────────────────────── */
.page {
    display: none;
    width: 100%;
    height: 100vh;
}
.page.active {
    display: flex;
}

/* ═══════════════════════════════════════════════════════════════
   AUTH PAGE  (kept purple)
   ═══════════════════════════════════════════════════════════════ */
#auth-page {
    position: relative;
    overflow: hidden;
}

/* ── Animated BG ─────────────────────────────────────────────── */
.auth-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: orbFloat 20s ease-in-out infinite;
}
.orb-1 {
    width: 500px; height: 500px;
    background: var(--purple-700);
    top: -10%; left: -5%;
    animation-delay: 0s;
}
.orb-2 {
    width: 400px; height: 400px;
    background: var(--indigo-600);
    bottom: -10%; right: -5%;
    animation-delay: -7s;
}
.orb-3 {
    width: 300px; height: 300px;
    background: var(--purple-500);
    top: 40%; left: 50%;
    animation-delay: -14s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(30px, -30px) scale(1.05); }
    66%      { transform: translate(-20px, 20px) scale(0.95); }
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image: 
        linear-gradient(rgba(139,92,246,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(139,92,246,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* ── Auth Container ──────────────────────────────────────────── */
.auth-container {
    display: flex;
    width: 100%;
    height: 100%;
    position: relative;
    z-index: 1;
}

.auth-brand {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.brand-content {
    max-width: 400px;
    animation: fadeSlideUp 0.8s var(--ease-out);
}

.brand-icon svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 20px rgba(139,92,246,0.3));
}

.brand-name {
    font-size: 3rem;
    font-weight: 800;
    background: var(--gradient-brand-auth);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.brand-tagline {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-weight: 400;
}

.brand-features {
    margin-top: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.925rem;
}

.feature-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gradient-brand-auth);
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(139,92,246,0.4);
}

/* ── Auth Form Section ───────────────────────────────────────── */
.auth-form-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(17, 17, 34, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.12);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg), 0 0 30px rgba(139,92,246,0.15);
    animation: fadeSlideUp 0.8s var(--ease-out) 0.1s both;
}

/* ── Auth Tabs ───────────────────────────────────────────────── */
.auth-tabs {
    display: flex;
    position: relative;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    padding: 4px;
    margin-bottom: 1.75rem;
}

.auth-tab {
    flex: 1;
    padding: 0.65rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius-full);
    transition: color var(--duration) var(--ease-out);
    z-index: 1;
}
.auth-tab.active {
    color: var(--text-primary);
}

.tab-indicator {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    transition: transform var(--duration) var(--ease-out);
    box-shadow: var(--shadow-sm);
}
.tab-indicator.right {
    transform: translateX(100%);
}

/* ── Forms ────────────────────────────────────────────────────── */
.auth-form {
    display: none;
    flex-direction: column;
    gap: 1.25rem;
}
.auth-form.active {
    display: flex;
    animation: fadeIn 0.3s var(--ease-out);
}

.form-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 0.25rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    letter-spacing: 0.02em;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--duration);
}

.input-wrapper input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all var(--duration) var(--ease-out);
    outline: none;
}
.input-wrapper input::placeholder {
    color: var(--text-muted);
}

/* Auth page inputs keep purple focus */
#auth-page .input-wrapper input:focus {
    border-color: var(--purple-500);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}
#auth-page .input-wrapper input:focus ~ .input-icon,
#auth-page .input-wrapper:focus-within .input-icon {
    color: var(--purple-400);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
    width: 100%;
    padding: 0.85rem 1.5rem;
    background: var(--gradient-brand-auth);
    color: white;
    font-size: 0.925rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    transition: all var(--duration) var(--ease-out);
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity var(--duration);
}
.btn-primary:hover::before {
    opacity: 1;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 20px rgba(139,92,246,0.3);
}
.btn-primary:active {
    transform: translateY(0);
}
.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Spinner */
.btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Auth Error ───────────────────────────────────────────────── */
.auth-error {
    font-size: 0.825rem;
    color: #f87171;
    text-align: center;
    min-height: 1.2em;
    transition: all var(--duration);
}

/* ═══════════════════════════════════════════════════════════════
   CHAT PAGE  (blue theme)
   ═══════════════════════════════════════════════════════════════ */
#chat-page {
    flex-direction: row;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--duration) var(--ease-out);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;  /* Never collapse the header */
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.sidebar-logo svg {
    width: 28px;
    height: 28px;
}
.sidebar-title {
    font-size: 1.05rem;
    font-weight: 700;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--duration);
}
.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* ── Sessions List (scrollable like ChatGPT) ─────────────────── */
.sidebar-sessions {
    flex: 1 1 0;          /* grow, shrink, base=0 forces scroll */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem;
    min-height: 0;         /* required for flex scroll */
}
.sidebar-sessions::-webkit-scrollbar { width: 4px; }
.sidebar-sessions::-webkit-scrollbar-track { background: transparent; }
.sidebar-sessions::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 4px; }

.session-item {
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    min-height: 40px;      /* each item has guaranteed height */
    flex-shrink: 0;        /* items never compress — list scrolls instead */
    gap: 0.5rem;
    position: relative;
}
.session-item .session-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.session-item::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--bg-elevated);
    flex-shrink: 0;
    transition: background var(--duration);
}
.session-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.session-item.active {
    background: var(--gradient-glow);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}
.session-item.active::before {
    background: var(--blue-400);
    box-shadow: 0 0 6px rgba(59,130,246,0.5);
}

/* ── Session Action Buttons ──────────────────────────────────── */
.session-actions {
    display: none;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    margin-left: auto;
}
.session-item:hover .session-actions,
.session-item.active .session-actions {
    display: flex;
}
.session-action-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--text-muted);
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.session-action-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.08);
}
.session-action-btn.delete:hover {
    color: #f87171;
    background: rgba(248,113,113,0.12);
}
.session-action-btn svg {
    width: 13px;
    height: 13px;
}

/* ── Session Rename Input ────────────────────────────────────── */
.session-rename-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--blue-500);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
    outline: none;
    min-width: 0;
    font-family: inherit;
}

/* ── Sidebar Footer ──────────────────────────────────────────── */
.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;  /* Never collapse the footer */
    background: var(--bg-secondary); /* Ensure it has its own bg */
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    overflow: hidden;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-name {
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    color: var(--text-muted);
}
.btn-logout:hover {
    color: #f87171;
    background: rgba(248,113,113,0.1);
}

/* ── Mobile Sidebar Toggle ────────────────────────────────────── */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 100;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}
.sidebar-toggle svg { width: 20px; height: 20px; }

/* ── Chat Main ────────────────────────────────────────────────── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

/* ── Animated Aurora Background ──────────────────────────────── */
.chat-main::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 600px 400px at 20% 50%, rgba(59, 130, 246, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 500px 350px at 80% 30%, rgba(6, 182, 212, 0.05) 0%, transparent 70%),
        radial-gradient(ellipse 400px 300px at 50% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 70%);
    animation: auroraShift 20s ease-in-out infinite alternate;
}

@keyframes auroraShift {
    0% {
        background:
            radial-gradient(ellipse 600px 400px at 20% 50%, rgba(59, 130, 246, 0.06) 0%, transparent 70%),
            radial-gradient(ellipse 500px 350px at 80% 30%, rgba(6, 182, 212, 0.05) 0%, transparent 70%),
            radial-gradient(ellipse 400px 300px at 50% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 70%);
    }
    33% {
        background:
            radial-gradient(ellipse 550px 450px at 40% 30%, rgba(6, 182, 212, 0.07) 0%, transparent 70%),
            radial-gradient(ellipse 600px 300px at 70% 70%, rgba(59, 130, 246, 0.05) 0%, transparent 70%),
            radial-gradient(ellipse 450px 350px at 20% 60%, rgba(139, 92, 246, 0.04) 0%, transparent 70%);
    }
    66% {
        background:
            radial-gradient(ellipse 500px 400px at 60% 60%, rgba(99, 102, 241, 0.06) 0%, transparent 70%),
            radial-gradient(ellipse 550px 380px at 30% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 70%),
            radial-gradient(ellipse 400px 350px at 80% 50%, rgba(6, 182, 212, 0.04) 0%, transparent 70%);
    }
    100% {
        background:
            radial-gradient(ellipse 600px 350px at 50% 40%, rgba(59, 130, 246, 0.06) 0%, transparent 70%),
            radial-gradient(ellipse 500px 400px at 25% 70%, rgba(6, 182, 212, 0.06) 0%, transparent 70%),
            radial-gradient(ellipse 450px 300px at 75% 25%, rgba(139, 92, 246, 0.04) 0%, transparent 70%);
    }
}

.chat-main > * {
    position: relative;
    z-index: 1;
}

/* ── Messages ─────────────────────────────────────────────────── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 6px; }

/* ── Welcome Screen ──────────────────────────────────────────── */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    animation: fadeSlideUp 0.6s var(--ease-out);
}

.welcome-icon svg {
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 30px rgba(59,130,246,0.2));
}

.welcome-screen h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.welcome-screen p {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 2.5rem;
}

/* ── Quick Prompts ────────────────────────────────────────────── */
.quick-prompts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    max-width: 520px;
    width: 100%;
}

.quick-prompt {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 0.825rem;
    color: var(--text-secondary);
    transition: all var(--duration) var(--ease-out);
    text-align: left;
}
.quick-prompt svg {
    width: 18px;
    height: 18px;
    color: var(--blue-400);
    flex-shrink: 0;
}
.quick-prompt:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ── Message Bubbles ──────────────────────────────────────────── */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 780px;
    width: 100%;
    margin: 0 auto;
    animation: fadeSlideUp 0.35s var(--ease-out);
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 2px;
}

.message.user .message-avatar {
    background: var(--bg-elevated);
    color: var(--text-secondary);
}
.message.assistant .message-avatar {
    background: var(--gradient-brand);
    color: white;
}

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

.message-role {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.message-text {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-primary);
    word-break: break-word;
}

/* Assistant text: NO purple box — just plain text, more natural */
.message.assistant .message-text {
    padding: 0.25rem 0;
}

/* ── Tables inside messages ──────────────────────────────────── */
.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.825rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.message-text thead {
    background: var(--bg-elevated);
}
.message-text th {
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--blue-300);
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}
.message-text td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}
.message-text tr:last-child td {
    border-bottom: none;
}
.message-text tr:hover td {
    background: rgba(59,130,246,0.04);
}

/* ── Unordered / Ordered Lists inside messages ───────────────── */
.message-text ul,
.message-text ol {
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}
.message-text li {
    margin-bottom: 0.3rem;
}

/* Code blocks inside messages */
.message-text pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    overflow-x: auto;
    margin: 0.75rem 0;
    font-size: 0.8rem;
    line-height: 1.6;
}
.message-text code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.825rem;
    background: var(--bg-tertiary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}
.message-text pre code {
    background: none;
    padding: 0;
}

/* ── Message Action Bar (edit / regenerate) ──────────────────── */
.message-actions {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.message:hover .message-actions {
    opacity: 1;
}
.msg-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}
.msg-action-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
}
.msg-action-btn svg {
    width: 12px;
    height: 12px;
}

/* ── Inline Edit Textarea ────────────────────────────────────── */
.edit-area {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--blue-500);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    padding: 0.65rem 0.85rem;
    resize: vertical;
    outline: none;
    min-height: 60px;
    margin-bottom: 0.4rem;
}
.edit-buttons {
    display: flex;
    gap: 0.4rem;
}
.edit-btn-save,
.edit-btn-cancel {
    padding: 0.35rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}
.edit-btn-save {
    background: var(--gradient-brand);
    color: white;
}
.edit-btn-save:hover { opacity: 0.9; }
.edit-btn-cancel {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}
.edit-btn-cancel:hover { background: var(--bg-hover); }

/* ── Thinking Dots ────────────────────────────────────────────── */
.thinking-indicator {
    display: flex;
    gap: 0.75rem;
    max-width: 780px;
    width: 100%;
    margin: 0 auto;
    animation: fadeSlideUp 0.35s var(--ease-out);
}

.thinking-dots {
    display: flex;
    gap: 5px;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 2px var(--radius-md) var(--radius-md) var(--radius-md);
}

.thinking-dot {
    width: 8px;
    height: 8px;
    background: var(--blue-400);
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out both;
}
.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }
.thinking-dot:nth-child(3) { animation-delay: 0s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Input Area ───────────────────────────────────────────────── */
.chat-input-area {
    padding: 0 2rem 1.5rem;
    flex-shrink: 0;
}

.chat-input-container {
    max-width: 780px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 0.5rem 0.5rem 0.5rem 1.25rem;
    transition: all var(--duration) var(--ease-out);
}
.chat-input-container:focus-within {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1), var(--shadow-md);
}

#chat-input {
    flex: 1;
    resize: none;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
    padding: 0.5rem 0;
    max-height: 150px;
    outline: none;
}
#chat-input::placeholder {
    color: var(--text-muted);
}

.btn-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-brand);
    border-radius: var(--radius-sm);
    color: white;
    transition: all var(--duration) var(--ease-out);
    flex-shrink: 0;
}
.btn-send svg { width: 18px; height: 18px; }
.btn-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(59,130,246,0.3);
}
.btn-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.input-hint {
    max-width: 780px;
    margin: 0.5rem auto 0;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   CONFIRM DELETE MODAL
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}
.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 360px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: fadeSlideUp 0.25s var(--ease-out);
}
.modal-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}
.modal-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
}
.modal-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}
.modal-btn-cancel {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    transition: all 0.15s ease;
}
.modal-btn-cancel:hover { background: var(--bg-hover); }
.modal-btn-delete {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    background: #dc2626;
    color: white;
    transition: all 0.15s ease;
}
.modal-btn-delete:hover { background: #b91c1c; }

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */
@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR (Global)
   ═══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .auth-container { flex-direction: column; }
    .auth-brand { padding: 2rem 2rem 0; }
    .brand-content { text-align: center; max-width: 100%; }
    .brand-features { display: none; }
    .brand-name { font-size: 2.25rem; }
    .auth-form-section { padding: 1.5rem; }
    .quick-prompts { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 50;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }
    .chat-messages { padding: 1rem; padding-top: 3.5rem; }
    .chat-input-area { padding: 0 1rem 1rem; }
}
.md-h3 {
    margin: 1rem 0 0.5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--blue-300);
}
.inline-thinking {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0;
}
.inline-thinking .thinking-dot {
    width: 6px;
    height: 6px;
    background: var(--blue-500);
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out both;
}
.inline-thinking .thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.inline-thinking .thinking-dot:nth-child(2) { animation-delay: -0.16s; }
.inline-thinking .thinking-dot:nth-child(3) { animation-delay: 0s; }
