/**
 * Mirror Ai - Premium Chat Interface
 * ===================================
 * Billion-dollar luxury chat experience
 * Deep purple/blue aesthetic with glass morphism
 * 
 * Version: 3.0.0 - Complete Redesign
 * Last Updated: January 2026
 *
 * Contents:
 * 1. CSS Variables (Premium Palette)
 * 2. Ambient Background
 * 3. Chat Layout & Container
 * 4. Sidebar - Premium Glass Design
 * 5. Sidebar Navigation
 * 6. Chat History Items
 * 7. Main Chat Area
 * 8. Messages Container
 * 9. Message Bubbles (User & AI)
 * 10. Conversation Starters
 * 11. Follow-up Questions
 * 12. Input Area
 * 13. Thinking/Loading States
 * 14. Code Blocks
 * 15. Scrollbars
 * 16. Animations
 * 17. Utility Classes
 */

/* ============================================================================
   1. CSS VARIABLES - PREMIUM PALETTE
   ============================================================================ */
:root {
    /* Deep Luxury Background Colors */
    --chat-bg-deepest: #05060f;
    --chat-bg-deep: #080a1a;
    --chat-bg-primary: #0a0e1f;
    --chat-bg-secondary: #0f1529;
    --chat-bg-tertiary: #141a32;
    --chat-bg-elevated: #1a2142;
    
    /* Premium Accent Colors */
    --chat-accent-primary: #00f2fe;
    --chat-accent-secondary: #764ba2;
    --chat-accent-tertiary: #667eea;
    --chat-accent-pink: #f093fb;
    
    /* Text Hierarchy */
    --chat-text-primary: #ffffff;
    --chat-text-secondary: rgba(255, 255, 255, 0.85);
    --chat-text-muted: rgba(255, 255, 255, 0.6);
    --chat-text-subtle: rgba(255, 255, 255, 0.4);
    
    /* Premium Gradients */
    --chat-gradient-glow: linear-gradient(135deg, #00f2fe 0%, #764ba2 100%);
    --chat-gradient-user: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --chat-gradient-ai: linear-gradient(135deg, rgba(20, 26, 50, 0.9) 0%, rgba(15, 21, 41, 0.95) 100%);
    --chat-gradient-sidebar: linear-gradient(180deg, rgba(15, 21, 41, 0.95) 0%, rgba(10, 14, 31, 0.98) 100%);
    
    /* Glass Effects */
    --chat-glass-bg: rgba(255, 255, 255, 0.03);
    --chat-glass-border: rgba(255, 255, 255, 0.08);
    --chat-glass-border-hover: rgba(0, 242, 254, 0.3);
    
    /* Premium Shadows */
    --chat-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --chat-shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --chat-shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    --chat-shadow-glow-cyan: 0 0 40px rgba(0, 242, 254, 0.15);
    --chat-shadow-glow-purple: 0 0 40px rgba(118, 75, 162, 0.2);
    
    /* Layout Dimensions */
    --chat-sidebar-width: 280px;
    --chat-sidebar-collapsed: 72px;
    --chat-message-max-width: 900px;
    --chat-input-max-width: 900px;
    
    /* Transitions */
    --chat-transition-fast: 0.15s ease;
    --chat-transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --chat-transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* -------------------------------------------------------------------------
   Z-Index Layers (from design-system.css)
   ------------------------------------------------------------------------- */
/*
   --z-base: 1          ? Ambient background, base elements
   --z-sidebar: 300     ? Chat sidebar (desktop)
   --z-header: 350      ? Header/navbar
   --z-feature-view: 400 ? Chat/Doc/Blog views
   --z-floating-nav: 600 ? Floating navigation bar
   --z-input-area: 650  ? Chat input area (above nav)
   --z-menu-toggle: 700 ? Mobile hamburger menu
   --z-overlay: 800     ? Overlay backdrops
   --z-sidebar-mobile: 850 ? Mobile slide-in sidebar
   --z-modal-backdrop: 1000 ? Modal overlays
   --z-modal: 1050      ? Modal content
   --z-toast: 1300      ? Notifications
   --z-max: 10000       ? Critical modals, top-level overlays
*/

/* ============================================================================
   2. AMBIENT BACKGROUND - MOVED TO workspace.css
   ============================================================================
   NOTE: Ambient background styles have been moved to workspace/workspace.css
   since they are a workspace-level component, not chat-specific.
   This prevents duplication and ensures animations work on all views.
   See: workspace.css lines 57-128
   ============================================================================ */

/* ============================================================================
   3. CHAT LAYOUT & CONTAINER - FULL SCREEN IMMERSIVE
   ============================================================================ */

/* Chat view wrapper - Full screen overlay */
.chat-view-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: var(--z-chat-view, 400);
    /* Visibility controlled by visibility-system.css */
    /* Add padding-top to account for floating navigation */
    padding-top: var(--floating-nav-height, 74px); /* Uses design-system.css variable */
}

/* Main container - Full screen flex layout */
.modern-chat-container {
    display: flex;
    height: 100%; /* Mobile-safe default; desktop override below */
    width: 100%;
    position: relative;
    /* NOTE: overflow:hidden moved to desktop-only media query to prevent
       clipping fixed-position children (input area, menu toggle) on mobile */
    background: var(--chat-bg-deepest);
}

/* Desktop only - contain scrolling and apply nav height offset */
@media (min-width: 768px) {
    .modern-chat-container {
        height: calc(100% - var(--floating-nav-height, 74px)); /* Scoped to desktop only */
        overflow: hidden;
    }
}

/* Ensure content is above ambient background */
.modern-chat-container > * {
    position: relative;
    z-index: var(--z-base, 1);
}

/* ============================================================================
   4. SIDEBAR - PREMIUM GLASS DESIGN
   ============================================================================ */
.chat-sidebar {
    width: var(--chat-sidebar-width);
    height: 100%;
    background: linear-gradient(180deg,
        rgba(15, 21, 41, 0.98) 0%,
        rgba(10, 14, 31, 0.99) 100%);
    border-right: 1px solid rgba(0, 242, 254, 0.15);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: var(--z-sidebar, 300);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    transition: width var(--chat-transition-base);
    flex-shrink: 0;
}

/* Premium animated glow accent line */
.chat-sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg,
        rgba(0, 242, 254, 0.6) 0%,
        rgba(118, 75, 162, 0.5) 50%,
        rgba(0, 242, 254, 0.4) 100%);
    animation: sidebarGlow 4s ease-in-out infinite;
    z-index: var(--z-sticky, 150);
}

@keyframes sidebarGlow {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Secondary subtle glow line */
.chat-sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 2px;
    width: 8px;
    height: 100%;
    background: linear-gradient(180deg,
        rgba(0, 242, 254, 0.1) 0%,
        rgba(118, 75, 162, 0.08) 50%,
        rgba(0, 242, 254, 0.05) 100%);
    filter: blur(4px);
    opacity: 0.6;
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--chat-glass-border);
    display: flex;
    gap: 10px;
}

/* New Chat Button - ULTRA PREMIUM with spinning border */
.new-chat-btn {
    flex: 1;
    padding: 14px 20px;
    background: var(--chat-gradient-glow);
    border: none;
    border-radius: 14px;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--chat-transition-base);
    box-shadow:
        0 4px 20px rgba(0, 242, 254, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: visible;  /* Allow spinning border to show */
    z-index: var(--z-base, 1);
}

/* Spinning conic gradient border - hidden by default */
.new-chat-btn::before {
    content: '';
    position: absolute;
    inset: -3px;
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(0, 242, 254, 0.8) 60deg,
        transparent 120deg,
        rgba(118, 75, 162, 0.8) 180deg,
        transparent 240deg,
        rgba(0, 242, 254, 0.8) 300deg,
        transparent 360deg
    );
    border-radius: 17px;
    z-index: -2;
    opacity: 0;
    animation: buttonBorderSpin 3s linear infinite;
    transition: opacity 0.3s ease;
}

/* Button background cover */
.new-chat-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--chat-gradient-glow);
    border-radius: inherit;
    z-index: -1;
}

@keyframes buttonBorderSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Show spinning border on hover */
.new-chat-btn:hover::before {
    opacity: 1;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 35px rgba(0, 242, 254, 0.5),
        0 0 20px rgba(0, 242, 254, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.new-chat-btn:active {
    transform: translateY(0);
}

.new-chat-btn i {
    font-size: 1rem;
    position: relative;
    z-index: var(--z-base, 1);
}

.new-chat-btn span {
    position: relative;
    z-index: var(--z-base, 1);
}

/* Sidebar Collapse Button */
.sidebar-collapse-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-glass-border);
    border-radius: 12px;
    color: var(--chat-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--chat-transition-fast);
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--chat-text-primary);
    border-color: var(--chat-glass-border-hover);
}

.sidebar-collapse-btn i {
    transition: transform var(--chat-transition-base);
}

/* Collapsed state */
body.sidebar-collapsed .chat-sidebar {
    width: var(--chat-sidebar-collapsed);
}

body.sidebar-collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

body.sidebar-collapsed .new-chat-btn span,
body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .sidebar-sessions-title,
body.sidebar-collapsed .chat-title,
body.sidebar-collapsed .chat-preview,
body.sidebar-collapsed .chat-item-footer,
body.sidebar-collapsed .service-tab span,
body.sidebar-collapsed .sidebar-back-btn span {
    display: none;
}

body.sidebar-collapsed .sidebar-header {
    flex-direction: column;
    padding: 12px;
}

body.sidebar-collapsed .new-chat-btn {
    padding: 14px;
}

body.sidebar-collapsed .sidebar-collapse-btn {
    width: 100%;
}

body.sidebar-collapsed .sidebar-service-switcher {
    padding: 12px;
}

body.sidebar-collapsed .service-tabs {
    flex-direction: column;
}

body.sidebar-collapsed .service-tab {
    justify-content: center;
    padding: 12px;
}

body.sidebar-collapsed .sidebar-back-btn {
    padding: 12px;
    justify-content: center;
}

/* ============================================================================
   4B. SERVICE SWITCHER IN SIDEBAR
   ============================================================================ */
.sidebar-service-switcher {
    padding: 12px 20px;
    border-bottom: 1px solid var(--chat-glass-border);
}

.service-tabs {
    display: flex;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--chat-glass-border);
}

.service-tab {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--chat-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--chat-transition-fast);
    position: relative;
}

.service-tab i {
    font-size: 0.9rem;
}

.service-tab:hover {
    background: rgba(0, 242, 254, 0.07);
    color: var(--chat-text-secondary);
}

.service-tab.active {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.85) 0%, rgba(118, 75, 162, 0.85) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(0, 242, 254, 0.28);
}

.sidebar-back-btn {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--chat-glass-border);
    border-radius: 10px;
    color: var(--chat-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    transition: all var(--chat-transition-fast);
}

.sidebar-back-btn:hover {
    background: rgba(0, 242, 254, 0.06);
    color: var(--chat-text-secondary);
    border-color: rgba(0, 242, 254, 0.25);
}

.sidebar-back-btn i {
    font-size: 0.9rem;
}

/* ============================================================================
   5. SIDEBAR NAVIGATION
   ============================================================================ */
.sidebar-nav {
    padding: 16px 12px 8px;
}

.nav-section-title {
    padding: 8px 16px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--chat-text-subtle);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    color: var(--chat-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--chat-transition-fast);
    position: relative;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: rgba(0, 242, 254, 0.06);
    color: var(--chat-text-secondary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.12) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: var(--chat-text-primary);
    border: 1px solid rgba(0, 242, 254, 0.25);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--chat-gradient-glow);
    border-radius: 0 4px 4px 0;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

/* ============================================================================
   6. CHAT HISTORY / SESSIONS
   ============================================================================ */
.sidebar-sessions {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 12px;
}

.sidebar-sessions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
}

.sidebar-sessions-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--chat-text-subtle);
}

.sidebar-sessions-title i {
    font-size: 0.75rem;
    color: var(--chat-accent-primary);
}

.sidebar-sessions-refresh {
    background: none;
    border: none;
    color: var(--chat-text-subtle);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all var(--chat-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-sessions-refresh:hover {
    color: var(--chat-accent-primary);
    background: rgba(0, 242, 254, 0.1);
}

.sidebar-sessions-refresh.refreshing i {
    animation: spin 1s linear infinite;
}

.sidebar-sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

/* Loading State */
.sidebar-sessions-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    color: var(--chat-text-muted);
    font-size: 0.85rem;
}

.sidebar-sessions-loading i {
    color: var(--chat-accent-primary);
}

/* Chat Items */
.chat-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 13px 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--chat-transition-fast);
    margin-bottom: 6px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.012) 100%);
    position: relative;
    overflow: hidden;
}

/* Staggered entrance animation for sidebar chat items — desktop only.
   On mobile, sidebar is a drawer; items should be immediately visible
   to avoid requiring !important overrides in chat-mobile.css. */
@media (min-width: 768px) {
    .sidebar-sessions-list .chat-item {
        animation: chatItemFadeIn 0.3s ease forwards;
        opacity: 0;
    }
    .sidebar-sessions-list .chat-item:nth-child(1) { animation-delay: 0.03s; }
    .sidebar-sessions-list .chat-item:nth-child(2) { animation-delay: 0.06s; }
    .sidebar-sessions-list .chat-item:nth-child(3) { animation-delay: 0.09s; }
    .sidebar-sessions-list .chat-item:nth-child(4) { animation-delay: 0.12s; }
    .sidebar-sessions-list .chat-item:nth-child(5) { animation-delay: 0.15s; }
}

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

.chat-item:hover {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.06) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-color: rgba(0, 242, 254, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.chat-item.active {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-color: rgba(0, 242, 254, 0.3);
    box-shadow: 0 0 22px rgba(0, 242, 254, 0.1), 0 6px 18px rgba(0, 0, 0, 0.22);
}

.chat-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--chat-gradient-glow);
    border-radius: 0 4px 4px 0;
    opacity: 1;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* NOTE: .chat-title, .chat-preview, .chat-actions, .chat-action-btn
   are defined in the "Chat Item Styles" section below (lines ~1460+)
   with more comprehensive styling including gradients and focus states */

.chat-item-footer {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-time {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--chat-text-subtle);
    background: rgba(0, 242, 254, 0.08);
    padding: 4px 8px;
    border-radius: 6px;
}

.chat-time i {
    font-size: 0.6rem;
}

.chat-message-count {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--chat-accent-primary);
    background: rgba(118, 75, 162, 0.15);
    padding: 4px 8px;
    border-radius: 6px;
}

.chat-message-count i {
    font-size: 0.6rem;
}

/* ============================================================================
   7. MAIN CHAT AREA
   ============================================================================ */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: var(--z-base, 1);
    background: transparent;
    min-width: 0;
    /* Smooth transition when sidebar collapses */
    transition: margin-left var(--chat-transition-base), width var(--chat-transition-base);
}

/* Mobile Menu Toggle */
.chat-mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 70px;
    left: 16px;
    z-index: var(--z-header, 350);
    width: 48px;
    height: 48px;
    background: rgba(15, 21, 41, 0.95);
    border: 1px solid var(--chat-glass-border);
    border-radius: 12px;
    color: var(--chat-text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all var(--chat-transition-fast);
    align-items: center;
    justify-content: center;
}

.chat-mobile-menu-toggle:hover {
    background: rgba(20, 26, 50, 0.95);
    border-color: var(--chat-glass-border-hover);
    color: var(--chat-text-primary);
}

/* ============================================================================
   8. MESSAGES CONTAINER
   ============================================================================ */
.chat-messages-container {
    flex: 1;
    min-height: 0; /* Required for flex child to scroll properly */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px 0; /* Vertical padding only - full width edge-to-edge */
    display: flex;
    flex-direction: column;
}

/* Messages wrapper - FULL WIDTH PREMIUM LAYOUT
   AI messages align LEFT, User messages align RIGHT
   Uses entire viewport with responsive edge padding */
.messages-wrapper {
    width: 100%;
    max-width: min(1280px, 92%);  /* Use the available width; bounded so text stays readable on ultrawide */
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    gap: 22px;  /* Generous breathing room between turns */
}

/* ============================================================================
   9. MESSAGE BUBBLES - PREMIUM DESIGN
   ============================================================================ */
.chat-messages-container .chat-message {
    display: flex;
    gap: 13px;
    width: 100%;
    animation: messageEntrance 0.45s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* AI Messages - LEFT ALIGNED (flush to left edge) */
.chat-messages-container .chat-message.assistant-message {
    justify-content: flex-start;
}

/* User Messages - FLUSH RIGHT via row-reverse (avatar naturally on right) */
.chat-messages-container .chat-message.user-message {
    justify-content: flex-start;
    flex-direction: row-reverse;
    /* Breathing room when scrollIntoView({block: 'start'}) anchors a freshly
       sent user message to the top of the chat viewport (see chat.js
       scrollUserMessageToTop). */
    scroll-margin-top: 16px;
}

/* Premium message entrance animation */
@keyframes messageEntrance {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Message Avatar */
.chat-messages-container .message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    margin-top: 2px;  /* Align avatar with the first line of text */
}

.chat-messages-container .assistant-avatar {
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.18);
    box-shadow: none;
    padding: 5px;
}

.chat-messages-container .assistant-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-messages-container .user-avatar {
    background: var(--chat-gradient-user, linear-gradient(135deg, #667eea 0%, #764ba2 100%));
    color: white;
    font-weight: 700;
    font-size: 1rem;
}

/* Message Content - EXPANDED WIDTH */
.chat-messages-container .message-content {
    flex: 0 1 auto;  /* Don't grow, allow shrink */
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;  /* Prevent flex overflow */
}

/* AI message content - GENEROUS WIDTH for readability
   NOTE: Uses min() instead of clamp() to avoid a fixed minimum that overflows
   on small devices (320px). Mobile CSS handles further reductions for phones */
.chat-messages-container .assistant-message .message-content {
    max-width: min(85vw, 1100px);
}

/* User message content - right-aligned with generous width */
.chat-messages-container .user-message .message-content {
    max-width: min(65vw, 720px);
}

.chat-messages-container .message-bubble {
    padding: 20px 24px;
    border-radius: 20px;
    position: relative;
    max-width: 100%;  /* Prevent overflow */
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
    overflow: hidden;
}

/* Code blocks and pre elements scroll horizontally */
.chat-messages-container .message-bubble pre,
.chat-messages-container .message-bubble code {
    overflow-x: auto;
    max-width: 100%;
}

.chat-messages-container .chat-message.assistant-message .message-bubble {
    /* Premium "answer card": a refined glass surface with depth so AI replies
       read as a designed artifact, not flat pasted text. */
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.018) 100%);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 16px;
    padding: 22px 26px;
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
    position: relative;
}

.chat-messages-container .chat-message.user-message .message-bubble {
    /* Phase 1: restrained, branded user bubble (subtle tint + hairline) —
       not a full-saturation gradient (frontend-design "AI Slop Test"). */
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.20) 0%, rgba(118, 75, 162, 0.22) 100%);
    border: 1px solid rgba(118, 75, 162, 0.32);
    border-top-right-radius: 6px;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.22);
}

/* Consecutive same-sender: tighter spacing */
.chat-messages-container .user-message + .user-message,
.chat-messages-container .assistant-message + .assistant-message {
    margin-top: -6px;
}

/* Add subtle shine overlay to user bubbles */
.chat-messages-container .chat-message.user-message .message-bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.06) 0%,
        transparent 55%);
    border-radius: inherit;
    pointer-events: none;
    /* z-index: 0 removed - background layer doesn't need explicit z-index */
}

/* Ensure text is above the shine overlay */
.chat-messages-container .chat-message.user-message .message-text {
    position: relative;
    z-index: 1;
}

.message-text {
    font-size: 1rem;
    line-height: 1.72;
    color: var(--chat-text-secondary);
}

/* Phase 1: calm assistant reading column — generous measure + brighter ink */
.chat-messages-container .chat-message.assistant-message .message-text {
    max-width: 78ch;
    color: rgba(255, 255, 255, 0.90);
}

.chat-messages-container .chat-message.user-message .message-text {
    color: white;
}

.message-text p {
    margin-bottom: 12px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

/* Phase 1: sender name label above each message (matches spike) */
.message-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.6));
    letter-spacing: 0.1px;
    line-height: 1.3;
    margin-bottom: 2px;
}

/* Right-align the user's name / bubble / time within their column */
.chat-messages-container .user-message .message-content {
    align-items: flex-end;
}

/* Message timestamp */
.message-time,
.message-timestamp {
    font-size: 0.75rem;
    color: var(--chat-text-subtle, rgba(255, 255, 255, 0.4));
    margin-top: 0;
    width: 100%;  /* Take full content width */
}

/* Right-align for user messages */
.chat-messages-container .chat-message.user-message .message-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.7);
}

/* Left-align for AI messages */
.chat-messages-container .chat-message.assistant-message .message-time {
    text-align: left;
}

/* ============================================================================
   FULL-WIDTH PREMIUM LAYOUT - Message Constraints
   AI messages on LEFT, User messages on RIGHT with generous widths
   ============================================================================ */

/* AI message bubble - wider, left-aligned */
.chat-messages-container .assistant-message .message-bubble {
    max-width: min(68vw, 880px);
}

/* User message bubble - slightly narrower, right-aligned */
.chat-messages-container .user-message .message-bubble {
    max-width: min(58vw, 720px);
}

/* ============================================================================
   10. INPUT AREA - PREMIUM DESIGN
   ============================================================================ */
.chat-input-container {
    padding: 20px 0 32px; /* Vertical padding only - full width */
    background: linear-gradient(180deg, transparent 0%, rgba(10, 14, 31, 0.9) 100%);
}

.chat-input-wrapper {
    width: calc(100% - 64px); /* Full width minus side margins */
    margin: 0 32px; /* Side margins for proper spacing */
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(20, 26, 50, 0.9) 0%, rgba(15, 21, 41, 0.95) 100%);
    border: 1px solid var(--chat-glass-border);
    border-radius: 20px;
    transition: all var(--chat-transition-base);
}

.chat-input-wrapper:focus-within {
    border-color: var(--chat-accent-primary);
    box-shadow: 
        0 0 0 4px rgba(0, 242, 254, 0.1),
        0 8px 32px rgba(0, 0, 0, 0.3);
}

.chat-input-field {
    flex: 1;
    background: none;
    border: none;
    color: var(--chat-text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    line-height: 1.5;
    padding: 8px 0;
}

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

.chat-input-field:focus {
    outline: none;
}

.chat-send-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 14px;
    background: var(--chat-gradient-glow);
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--chat-transition-base);
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.3);
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(0, 242, 254, 0.4);
}

.chat-send-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* ============================================================================
   14. CODE BLOCKS
   ============================================================================ */
.message-text pre {
    background: #0c1024;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    padding: 14px 16px;
    overflow-x: auto;
    margin: 14px 0;
}

.message-text code {
    background: rgba(0, 242, 254, 0.1);
    color: var(--chat-accent-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9em;
}

.message-text pre code {
    background: none;
    padding: 0;
    color: var(--chat-text-secondary);
}

/* Phase 1: premium code block — header bar (window dots + language + copy) */
.code-block {
    margin: 14px 0;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    overflow: hidden;
    background: #0c1024;
}

.message-text .code-block pre {
    margin: 0;
    border: none;
    border-radius: 0;
    background: transparent;
}

.code-block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.025);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.code-block-dots {
    display: inline-flex;
    gap: 6px;
}

.code-block-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.code-block-dots span:nth-child(1) { background: #ff5f57; }
.code-block-dots span:nth-child(2) { background: #febc2e; }
.code-block-dots span:nth-child(3) { background: #28c840; }

.code-block-lang {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.6));
}

/* Copy button now lives in the header (override the legacy absolute positioning) */
.code-block .code-copy-btn {
    position: static;
    margin-left: auto;
    width: auto;
    height: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 500;
    opacity: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.6));
    cursor: pointer;
    transition: all 0.15s ease;
}

.code-block .code-copy-btn:hover {
    color: var(--chat-accent-primary, #00f2fe);
    border-color: rgba(0, 242, 254, 0.3);
    background: rgba(0, 242, 254, 0.08);
}

.code-block .code-copy-btn.copied {
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
    background: rgba(34, 197, 94, 0.12);
}

/* ============================================================================
   14b. BLOCKQUOTES, IMAGES, HR, ADDITIONAL TYPOGRAPHY
   ============================================================================ */

/* Blockquotes */
.message-text blockquote {
    border-left: 3px solid rgba(0, 242, 254, 0.4);
    padding: 10px 0 10px 16px;
    margin: 12px 0;
    background: rgba(0, 242, 254, 0.04);
    border-radius: 0 8px 8px 0;
    color: rgba(255, 255, 255, 0.85);
    font-style: italic;
}

.message-text blockquote p:last-child {
    margin-bottom: 0;
}

/* Images inside messages */
.message-text img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 8px 0;
    display: block;
}

/* Horizontal rules */
.message-text hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 16px 0;
}

/* h5 and h6 styling */
.message-text h5 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #ffffff;
    margin-top: 1em;
    margin-bottom: 0.4em;
    line-height: 1.4;
}

.message-text h6 {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 1em;
    margin-bottom: 0.4em;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Links — brand accent + prevent long URL overflow (Phase 1) */
.message-text a {
    color: var(--chat-accent-primary, #00f2fe);
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 242, 254, 0.35);
    overflow-wrap: anywhere;
    word-break: break-word;
    transition: border-color 0.15s ease;
}

.message-text a:hover {
    border-bottom-color: var(--chat-accent-primary, #00f2fe);
}

/* Tables — quiet borders + zebra rows (Phase 1) */
.message-text .table-responsive {
    overflow-x: auto;
    margin: 14px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}

.message-text table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin: 14px 0;
}

.message-text .table-responsive table {
    margin: 0;
}

.message-text thead th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.035);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    white-space: nowrap;
}

.message-text tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.message-text tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.018);
}

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

/* Nested lists — cap indentation depth */
.message-text ul ul,
.message-text ol ol,
.message-text ul ol,
.message-text ol ul {
    padding-left: 1.25em;
    margin-bottom: 0.25em;
    margin-top: 0.25em;
}

/* Third-level nesting — tighter */
.message-text ul ul ul,
.message-text ol ol ol,
.message-text ul ul ol,
.message-text ol ol ul {
    padding-left: 1em;
}

/* ============================================================================
   15. SCROLLBARS - PREMIUM THIN
   ============================================================================ */
.chat-messages-container::-webkit-scrollbar,
.sidebar-sessions-list::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-container::-webkit-scrollbar-track,
.sidebar-sessions-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-container::-webkit-scrollbar-thumb,
.sidebar-sessions-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.chat-messages-container::-webkit-scrollbar-thumb:hover,
.sidebar-sessions-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Firefox scrollbar */
.chat-messages-container,
.sidebar-sessions-list {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ============================================================================
   16. ANIMATIONS
   ============================================================================ */
/* @keyframes messageSlideIn — centralized in design-system.css */

/* @keyframes spin and fadeIn defined in design-system.css */

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

/* ============================================================================
   17. UTILITY CLASSES
   ============================================================================ */
.chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--chat-text-muted);
    gap: 0.75rem;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(0, 242, 254, 0.2);
    border-top-color: var(--chat-accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--chat-text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--chat-text-secondary);
}

.empty-state p {
    font-size: 0.9rem;
}

/* Error state */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: #ef4444;
}

.error-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

/* ============================================================================
   REDUCED MOTION SUPPORT — consolidated into the Performance section below.
   See: "Reduce animations on preference - accessibility" block.
   ============================================================================ */

.chat-title {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 2rem;
    letter-spacing: -0.01em;
}

.chat-item.active .chat-title {
    background: linear-gradient(90deg, #ffffff 0%, var(--accent-cyan, #00f2fe) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chat-preview {
    color: var(--text-secondary);
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    opacity: 0.85;
}

.chat-time {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
    font-size: 0.7rem;
    background: rgba(0, 242, 254, 0.08);
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid rgba(0, 242, 254, 0.1);
    font-weight: 500;
}

.chat-time::before {
    content: '?';
    font-size: 0.65rem;
}

.chat-actions {
    position: absolute;
    right: 0.75rem;
    top: 0.75rem;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    gap: 0.375rem;
}

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

.chat-action-btn {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #ef4444;
    cursor: pointer;
    padding: 0.375rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.chat-action-btn:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
    transform: scale(1.1);
}

.chat-action-btn:focus-visible {
    outline: 2px solid #ef4444;
    outline-offset: 2px;
}

/* Chat Item Header & Footer */
.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.chat-item-header .chat-actions {
    position: static;
    opacity: 0;
    transform: translateY(-2px);
}

.chat-item:hover .chat-item-header .chat-actions {
    opacity: 1;
    transform: translateY(0);
}

.chat-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.chat-message-count {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--accent-cyan, #00f2fe);
    font-size: 0.7rem;
    background: rgba(139, 92, 246, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid rgba(139, 92, 246, 0.15);
    font-weight: 600;
}

.chat-message-count i {
    font-size: 0.6rem;
    opacity: 0.8;
}

/* ========================================
   CHAT MAIN AREA
   From: modern-sidebar.css
   ======================================== */

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
}

/* Chat Header */
.chat-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--sidebar-border, rgba(0, 242, 254, 0.15));
    background: var(--blur-bg, rgba(15, 20, 45, 0.9));
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    flex: 1;
}

.chat-title-main {
    color: var(--text-primary, #ffffff);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.chat-subtitle {
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
    font-size: 0.8rem;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-btn {
    background: none;
    border: none;
    color: var(--text-secondary, rgba(255, 255, 255, 0.85));
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: var(--transition-fast, 150ms ease);
    font-size: 1.1rem;
}

.header-btn:hover {
    color: var(--accent-cyan, #00f2fe);
    background: rgba(0, 242, 254, 0.1);
}

/* ========================================
   CHAT MESSAGES & INPUT STYLES
   NOTE: Base styles now in workspace/chat-messages.css
   and workspace/chat-input.css
   ======================================== */

/* ========================================
   CONVERSATION STARTERS & FOLLOW-UP QUESTIONS
   From: modern-sidebar.css
   ======================================== */

/* Conversation Starters and Follow-up Questions */
.conversation-starters,
.follow-up-questions {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--sidebar-border);
    border-radius: 1rem;
    backdrop-filter: blur(10px);
}

.starters-title,
.follow-up-title {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}

.conversation-starters-list,
.follow-up-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ========================================
   TYPING INDICATOR
   From: modern-sidebar.css
   ======================================== */

/* Typing indicator already defined above (line 1131) - removed duplicate */

/* ========================================
   LOADING & ERROR STATES
   From: modern-sidebar.css
   ======================================== */

/* Loading and Error States */
.loading-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
}

.loading-state i,
.error-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.loading-state p,
.error-state p {
    font-size: 1rem;
    margin: 0;
}

.error-state {
    color: var(--color-error, #ef4444);
}

.error-state i {
    color: var(--color-error, #ef4444);
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 242, 254, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-cyan, #00f2fe);
    animation: spin 1s ease-in-out infinite;
}

/* @keyframes spin - now centralized in design-system.css */

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text-secondary, rgba(255, 255, 255, 0.85));
}

.empty-state p {
    font-size: 0.9rem;
}

/* Sidebar-specific Empty State */
.chat-history .empty-state {
    padding: 1.5rem 1rem;
}

.chat-history .empty-state i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.chat-history .empty-state h3 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.chat-history .empty-state p {
    font-size: 0.8rem;
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   From: modern-sidebar.css
   ======================================== */

/* Hardware acceleration for all interactive elements */
button, 
.btn,
.nav-item,
.chat-item,
.hero-action-btn,
.search-btn,
.crypto-chip {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Inputs/textareas: keep text selection enabled, suppress tap highlight */
input,
textarea {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: text;
    user-select: text;
}

/* Optimize scrolling performance */
.chat-messages-container,
.content-section,
.chat-sidebar {
    -webkit-overflow-scrolling: touch;
    /* scroll-behavior: smooth removed — it interferes with natural touch
       scrolling. Programmatic smooth scrolling is handled via JS scrollTo(). */
}

/* Reduce animations on preference - accessibility.
   Targets specific animated elements rather than using a blanket * selector
   that would break loading spinners and state indicators. */
@media (prefers-reduced-motion: reduce) {
    .ambient-orb,
    .chat-message,
    .enhanced-thinking-container,
    .thinking-dot,
    .status-icon,
    .typing-dots span,
    .new-chat-btn::before,
    .sidebar-sessions-list .chat-item,
    .welcome-card-container,
    .conversation-starters-container,
    .session-delete-modal {
        animation: none;
    }

    .conversation-starter:hover,
    .chat-item:hover,
    .new-chat-btn:hover,
    .chat-send-btn:hover {
        transform: none;
    }
}

/* Optimize will-change for frequently animated elements */
.nav-item:hover,
.hero-action-btn:hover,
.search-btn:hover,
.crypto-chip:hover {
    will-change: transform;
}

/* Remove will-change after animation completes */
.nav-item:not(:hover),
.hero-action-btn:not(:hover),
.search-btn:not(:hover),
.crypto-chip:not(:hover) {
    will-change: auto;
}

/* Optimize button clicks for instant feedback */
button:active,
.btn:active,
.nav-item:active {
    transform: scale(0.98) translateZ(0);
    transition-duration: 0.05s;
}

/* NOTE: Scrollbar styling is defined in the "CUSTOM SCROLLBARS" section above
   for .chat-messages-container and .sidebar-sessions-list */

/* ========================================
   ANIMATIONS
   From: modern-sidebar.css
   ======================================== */

/* @keyframes messageSlideIn - now centralized in design-system.css */

/* ========================================
   MIRROR Ai CHAT HEADER - DESKTOP OVERRIDES
   From: modern-sidebar.css
   Scoped to chat view for specificity
   ======================================== */

/* Header Height Overrides */
.chat-view-wrapper .ai-chat-hero-header,
.chat-view-wrapper .chat-header,
.chat-view-wrapper .mirror-header,
.chat-view-wrapper [class*="hero-header"],
.chat-view-wrapper [class*="chat-header"] {
    max-height: 72px;
    min-height: 60px;
    padding: 0.85rem 1.25rem;
    overflow: visible;
    background: rgba(21, 26, 53, 0.95);
    border-bottom: 1px solid rgba(0, 242, 254, 0.15);
    backdrop-filter: blur(10px);
}

/* Main Title - Eye-catching but professional */
.chat-view-wrapper .hero-title,
.chat-view-wrapper .hero-content h1,
.chat-view-wrapper .hero-content h2,
.chat-view-wrapper .hero-content .title,
.chat-view-wrapper [class*="hero"] h1,
.chat-view-wrapper [class*="hero"] h2,
.chat-view-wrapper .ai-chat-hero-header h1,
.chat-view-wrapper .ai-chat-hero-header h2,
.chat-view-wrapper h1:has(+ .hero-subtitle),
.chat-view-wrapper h2:has(+ .hero-subtitle) {
    font-size: 1.4rem;
    line-height: 1.35;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ========================================
   CHAT VIEW VISIBILITY CONTROLS
   From: workspace_chat.css
   Uses higher specificity for display control
   ======================================== */

/* Chat view wrapper — CANONICAL definition is at line ~117 (position: fixed).
   This duplicate has been removed to prevent conflicting position/width values.
   See: .chat-view-wrapper in the CHAT LAYOUT section above. */

/*
 * Visibility controls - REMOVED DUPLICATES
 * =========================================
 * .is-hidden rules for these elements are defined in:
 * - design-system.css: canonical html body .is-hidden definition
 * - workspace/workspace.css: element-specific .is-hidden rules
 * Do not duplicate here.
 */

/* Chat History content - behaves like chat-main in flex layout */
#sessions-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 2rem;
    gap: 1.5rem;
    background: var(--bg-primary, #0a0e27);
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Chat mode body class adjustments - DESKTOP ONLY
   On mobile, visibility-system.css sets display: flex for proper column layout.
   These rules must not override that, so they are scoped to desktop. */
@media (min-width: 768px) {
    body.chat-mode .chat-view-wrapper {
        display: block;
    }

    body.chat-history-mode .chat-view-wrapper {
        display: block;
    }
}

/* Chat History Mode - Sessions content takes full remaining width */
body.chat-history-mode #sessions-content {
    flex: 1;
    min-width: 0;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 2rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 24px;
    background: transparent;
    overflow-y: auto;
}

/* Inner content centering - children get max-width instead of container */
body.chat-history-mode #sessions-content > * {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

/* ========================================
   CODE BLOCKS & MESSAGE CONTENT
   From: modern-sidebar.css
   ======================================== */

/* Code Blocks */
.message-content pre {
    background: #0c1024;
    color: var(--chat-text-secondary, rgba(255, 255, 255, 0.85));
    padding: 14px 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 14px 0;
    border: 1px solid rgba(255, 255, 255, 0.10);
}

.message-content code {
    background: rgba(0, 242, 254, 0.1);
    color: var(--accent-cyan, #00f2fe);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9em;
}

/* ========================================
   ========================================
   CHAT SESSIONS STYLES
   ========================================
   Canonical source: chat-sessions.css
   Duplicates removed — only unique skeleton loading rules remain here.
   ======================================== */

/* ============================================
   SKELETON LOADING STATE - Premium shimmer
   (Unique to chat.css — not in chat-sessions.css)
   ============================================ */
.session-skeleton {
    padding: 12px;
    margin: 8px 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg,
        rgba(255, 255, 255, 0.04) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0.04) 100%);
    background-size: 200% 100%;
    animation: chatSkeletonShimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}

.skeleton-title {
    width: 70%;
    margin-bottom: 10px;
}

.skeleton-preview {
    width: 90%;
    height: 10px;
}

/* Renamed from skeletonShimmer to avoid collision with shared-ui.css version (transform based) */
@keyframes chatSkeletonShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================================
   TABLET STYLES (768px - 1023px)
   ============================================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
    .chat-sidebar {
        width: 240px;
    }

    .messages-wrapper {
        padding: 0 24px;
        max-width: 760px;
    }

    .chat-messages-container .message-content {
        max-width: min(calc(100% - 60px), 600px);
    }

    .chat-messages-container .message-bubble {
        padding: 18px 22px;
    }

    .chat-input-area-enhanced {
        padding: 16px 24px;
    }
}

.delete-modal .warning-box {
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 8px;
    padding: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.75rem;
}

.delete-modal .warning-box i {
    color: #ef4444;
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.delete-modal .warning-box div {
    flex: 1;
}

.delete-modal .warning-box strong {
    display: block;
    color: #ef4444;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}

.delete-modal .warning-box p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    line-height: 1.4;
    margin: 0;
}

.delete-modal .session-info-box {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 0.875rem;
}

.delete-modal .session-info-box p {
    display: flex;
    justify-content: space-between;
    margin: 0.25rem 0;
    font-size: 0.8rem;
}

.delete-modal .session-info-box strong {
    color: rgba(255, 255, 255, 0.6);
}

.delete-modal .session-info-box span {
    color: rgba(255, 255, 255, 0.4);
}

.delete-modal .modal-footer {
    padding: 0.875rem 1.25rem;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.delete-modal .btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.delete-modal .btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
}

.delete-modal .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.delete-modal .btn-danger {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    border: none;
    color: white;
}

.delete-modal .btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.delete-modal .btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 767px) {
    .sidebar-session-item {
        padding: 0.5rem 0.625rem;
    }

    .sidebar-session-icon {
        width: 26px;
        height: 26px;
    }

    .sidebar-session-title {
        font-size: 0.75rem;
    }

    .sidebar-session-actions {
        opacity: 1;
    }

    .sidebar-notification {
        left: 16px;
        right: 16px;
        min-width: auto;
    }

    /* Mobile message sizing is handled by chat-mobile.css */
}

/* ============================================
   COMPACT HEADER
   ============================================ */
.sessions-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, 
        rgba(0, 242, 254, 0.06) 0%, 
        rgba(139, 92, 246, 0.06) 100%);
    border-radius: 16px;
    border: 1px solid rgba(0, 242, 254, 0.12);
    flex-shrink: 0;
}

.sessions-header-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #00d4ff, #8b5cf6);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sessions-header-icon i {
    font-size: 1.5rem;
    color: #ffffff;
}

.sessions-header-text {
    flex: 1;
}

.sessions-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    color: #ffffff;
}

.sessions-header p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875rem;
    margin: 0;
}

/* ============================================
   INLINE STATS - Horizontal Pills
   ============================================ */
.sessions-stats {
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.875rem 1.25rem;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 160px;
}

.stat-item:hover {
    border-color: rgba(0, 242, 254, 0.25);
    background: rgba(0, 242, 254, 0.05);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-item:nth-child(1) .stat-icon {
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.2), rgba(0, 242, 254, 0.1));
}

.stat-item:nth-child(1) .stat-icon i {
    color: #00d4ff;
}

.stat-item:nth-child(2) .stat-icon {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.1));
}

.stat-item:nth-child(2) .stat-icon i {
    color: #8b5cf6;
}

.stat-item:nth-child(3) .stat-icon {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.1));
}

.stat-item:nth-child(3) .stat-icon i {
    color: #10b981;
}

.stat-icon i {
    font-size: 1.125rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   CONVERSATIONS SECTION - CARD GRID
   ============================================ */
.sessions-all {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.sessions-all h4 {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 1.25rem 0;
    flex-shrink: 0;
}

.sessions-all h4 i {
    color: #00d4ff;
    font-size: 0.875rem;
}

/* ============================================
   SESSION LIST - 2-COLUMN CARD GRID
   ============================================ */
#session-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 242, 254, 0.3) transparent;
    padding-right: 0.25rem;
}

#session-list::-webkit-scrollbar {
    width: 5px;
}

#session-list::-webkit-scrollbar-track {
    background: transparent;
}

#session-list::-webkit-scrollbar-thumb {
    background: rgba(0, 242, 254, 0.3);
    border-radius: 3px;
}

/* ============================================
   SESSION CARD - NEW DESIGN
   ============================================ */
.session-item {
    background: linear-gradient(145deg, 
        rgba(30, 41, 59, 0.8) 0%, 
        rgba(15, 23, 42, 0.6) 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    min-height: 160px;
}

/* Top gradient accent */
.session-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #00d4ff, #8b5cf6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.session-item:hover {
    border-color: rgba(0, 242, 254, 0.2);
    transform: translateY(-4px);
    box-shadow: 
        0 16px 48px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(0, 242, 254, 0.1);
}

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

/* Card Header - Icon + Title */
.session-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
}

.session-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: linear-gradient(135deg, 
        rgba(0, 242, 254, 0.15) 0%, 
        rgba(139, 92, 246, 0.1) 100%);
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.session-icon i {
    font-size: 1.125rem;
    color: #00d4ff;
}

.session-item:hover .session-icon {
    background: linear-gradient(135deg, 
        rgba(0, 242, 254, 0.25) 0%, 
        rgba(139, 92, 246, 0.15) 100%);
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.2);
}

/* Session Info */
.session-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

/* Session Menu - Three Dots */
.session-menu {
    position: relative;
    flex-shrink: 0;
    margin-left: auto;
}

.session-menu-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.session-menu-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

.session-menu-btn.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.session-menu-btn i {
    font-size: 0.875rem;
}

.session-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: linear-gradient(135deg,
        rgba(30, 41, 59, 0.98) 0%,
        rgba(51, 65, 85, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.375rem;
    min-width: 140px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    z-index: var(--z-popover, 1200);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.session-menu-item {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    transition: all 0.15s ease;
}

.session-menu-item:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.session-menu-item i {
    font-size: 0.875rem;
    width: 16px;
}

.session-menu-item span {
    flex: 1;
}

.session-title {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-preview {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.375rem;
}

/* Card Footer - Date + Count + Actions */
.session-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.session-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.session-date {
    font-size: 0.8125rem;
    color: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.session-date i {
    font-size: 0.75rem;
    opacity: 0.7;
}

.session-count {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #00d4ff;
    background: rgba(0, 242, 254, 0.1);
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
}

.session-count i {
    font-size: 0.75rem;
}

/* Session Actions */
.session-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

.session-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.session-action-btn i {
    font-size: 0.8125rem;
}

.session-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.session-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.sessions-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: rgba(255, 255, 255, 0.5);
}

.sessions-empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed rgba(255, 255, 255, 0.15);
}

.sessions-empty-icon i {
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.25);
}

.sessions-empty h4 {
    font-size: 1.125rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 0.5rem 0;
}

.sessions-empty p {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

/* ============================================
   LOADING STATE
   ============================================ */
.sessions-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    gap: 1rem;
}

.sessions-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 242, 254, 0.2);
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: fullPageSpin 1s linear infinite;
}

/* @keyframes fullPageSpin — centralized in chat-sessions.css */

.sessions-loading-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.875rem;
}

/* ============================================
   DELETE MODAL
   ============================================ */
.session-delete-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-max, 10000);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeIn 0.3s ease-out forwards;
}

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

.session-delete-modal-content {
    background: linear-gradient(135deg, 
        rgba(30, 41, 59, 0.98) 0%, 
        rgba(51, 65, 85, 0.98) 100%);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 16px;
    padding: 2.5rem;
    max-width: 440px;
    width: 90%;
    text-align: center;
    transform: scale(0.95) translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

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

.session-delete-modal-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.1));
    border: 2px solid rgba(239, 68, 68, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: deleteIconPulse 2s ease-in-out infinite;
}

/* Renamed from iconPulse to avoid collision with workspace.css iconPulse (scale based) */
@keyframes deleteIconPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

.session-delete-modal-icon i {
    font-size: 1.75rem;
    color: #ef4444;
}

.session-delete-modal h4 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 1rem 0;
    letter-spacing: -0.02em;
}

.session-delete-modal p,
.session-delete-modal .delete-modal-message {
    font-size: 0.9375rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 2rem 0;
    line-height: 1.6;
}

.session-delete-modal .delete-modal-message strong {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
}

.session-delete-modal-actions {
    display: flex;
    gap: 0.875rem;
    justify-content: center;
}

.session-delete-modal-btn {
    padding: 0.875rem 2rem;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    min-width: 120px;
    position: relative;
    overflow: hidden;
}

.session-delete-modal-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.session-delete-modal-btn:active::before {
    width: 300px;
    height: 300px;
}

.session-delete-modal-btn.cancel {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.session-delete-modal-btn.cancel:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.session-delete-modal-btn.cancel:active {
    transform: translateY(0);
}

.session-delete-modal-btn.delete {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.session-delete-modal-btn.delete:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
    background: linear-gradient(135deg, #f87171, #ef4444);
}

.session-delete-modal-btn.delete:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet */
@media (max-width: 900px) {
    #session-list {
        grid-template-columns: 1fr;
    }
    
    .sessions-stats {
        flex-wrap: wrap;
    }
    
    .stat-item {
        min-width: calc(50% - 0.5rem);
    }
}

/* Mobile - NOTE: Primary mobile #sessions-content layout is in chat-mobile.css.
   These rules provide baseline component sizing only. */
@media (max-width: 767px) {
    .sessions-header {
        flex-direction: column;
        text-align: center;
        padding: 1.25rem;
        gap: 1rem;
    }
    
    .sessions-header h3 {
        font-size: 1.25rem;
    }
    
    .sessions-stats {
        flex-direction: column;
    }
    
    .stat-item {
        min-width: 100%;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .sessions-all h4 {
        font-size: 0.9375rem;
    }
    
    .session-item {
        padding: 1rem;
        min-height: 140px;
    }
    
    .session-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }
    
    .session-icon i {
        font-size: 1rem;
    }
    
    .session-title {
        font-size: 0.9375rem;
    }
    
    .session-preview {
        font-size: 0.75rem;
        -webkit-line-clamp: 1;
        line-clamp: 1;
    }
    
    .session-actions {
        opacity: 1;
    }
    
    .session-card-footer {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .session-meta {
        flex: 1;
        min-width: 100%;
        order: 2;
    }
    
    .session-actions {
        order: 1;
        margin-left: auto;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    #sessions-content {
        padding: 0.75rem;
    }
    
    .sessions-header {
        padding: 1rem;
    }
    
    .sessions-header-icon {
        width: 48px;
        height: 48px;
    }
    
    .sessions-header-icon i {
        font-size: 1.25rem;
    }
    
    .sessions-header h3 {
        font-size: 1.125rem;
    }
    
    .session-item {
        padding: 0.875rem;
        gap: 0.75rem;
    }
    
    .session-delete-modal-content {
        padding: 2rem;
        max-width: 340px;
        border-radius: 12px;
    }
    
    .session-delete-modal-icon {
        width: 64px;
        height: 64px;
        margin-bottom: 1.25rem;
    }
    
    .session-delete-modal-icon i {
        font-size: 1.5rem;
    }
    
    .session-delete-modal h4 {
        font-size: 1.25rem;
    }
    
    .session-delete-modal-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .session-delete-modal-btn {
        width: 100%;
        min-width: unset;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
/* REMOVED: Duplicate .session-item animation rules.
   Canonical definition is in chat-sessions.css.
   On mobile, chat-mobile.css overrides to animation:none + opacity:1
   to prevent items getting stuck at opacity:0 when fadeInUp doesn't fire. */

/* ============================================
   PRINT STYLES - higher specificity for print overrides
   ============================================ */
@media print {
    #sessions-content {
        padding: 0;
    }

    html body .sessions-header::before,
    html body .session-actions,
    html body .session-delete-modal {
        display: none;
    }

    html body .session-item {
        break-inside: avoid;
        border: 1px solid #ccc;
        background: #fff;
    }

    html body .session-title,
    html body .session-preview,
    html body .stat-value,
    html body .stat-label {
        color: #000;
    }
}

/* NOTE: Mobile CSS variables have been moved to chat-mobile.css for self-contained mobile styles.
   Mobile styles are in chat-mobile.css which defines its own variables at the top of the file. */

/* ==========================================================================
   IMMERSIVE MODE CHAT STYLES
   ===========================================================================
   Jawdropping, futuristic chat experience for immersive mode.
   Premium glassmorphism, animated gradients, and cinematic feel.

   Dependencies: design-system.css, immersive-mode.css
   Load order: After base chat styles
   ========================================================================== */

/* ==========================================================================
   CHAT CONTAINER - IMMERSIVE FULL-SCREEN
   ========================================================================== */

/* Remove floating nav padding in immersive mode (nav is hidden) */
body.immersive-mode .chat-view-wrapper {
    padding-top: 0;
}

body.immersive-mode .modern-chat-container {
    height: 100vh;
    background:
        radial-gradient(ellipse at top left, rgba(118, 75, 162, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(0, 242, 254, 0.1) 0%, transparent 50%),
        linear-gradient(180deg, #0a0e27 0%, #0d1230 50%, #0a0e27 100%);
    position: relative;
}

/* Desktop only: contain scrolling within immersive chat container
   NOTE: On mobile, overflow must be visible to allow fixed children (input, menu) to escape.
   Mobile overrides are in chat-mobile.css. */
@media (min-width: 768px) {
    body.immersive-mode .modern-chat-container {
        overflow: hidden;
    }
}

/* Animated background particles effect */
body.immersive-mode .modern-chat-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(0, 242, 254, 0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(118, 75, 162, 0.3), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(2px 2px at 130px 80px, rgba(0, 242, 254, 0.2), transparent),
        radial-gradient(1px 1px at 160px 120px, rgba(118, 75, 162, 0.2), transparent);
    background-size: 200px 200px;
    animation: particleFloat 20s linear infinite;
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

@keyframes particleFloat {
    0% { transform: translate(0, 0); }
    100% { transform: translate(-200px, -200px); }
}

/* ==========================================================================
   SIDEBAR - GLASS MORPHISM PREMIUM
   ========================================================================== */

body.immersive-mode .chat-sidebar {
    background: rgba(15, 20, 45, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0, 242, 254, 0.1);
    box-shadow:
        4px 0 30px rgba(0, 0, 0, 0.3),
        inset -1px 0 0 rgba(255, 255, 255, 0.03);
    position: relative;
    z-index: var(--z-sidebar, 300);
}

/* Sidebar glow accent line */
body.immersive-mode .chat-sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(0, 242, 254, 0.5) 20%,
        rgba(118, 75, 162, 0.5) 50%,
        rgba(0, 242, 254, 0.5) 80%,
        transparent 100%
    );
    animation: immersiveSidebarGlow 4s ease-in-out infinite;
}

@keyframes immersiveSidebarGlow {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

/* Sidebar Header */
body.immersive-mode .chat-sidebar .sidebar-header {
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(0, 242, 254, 0.1);
    padding: 1rem;
}

/* New Chat Button — clean cyan CTA (was an animated purple gradient that
   overrode the redesign because the chat is always in immersive-mode). */
body.immersive-mode .new-chat-btn {
    background: linear-gradient(135deg, #00f2fe, #58b9ff);
    animation: none;
    border: none;
    border-radius: 11px;
    color: #04121a;
    font-weight: 600;
    box-shadow: none;
    transition: filter 0.14s ease;
}

body.immersive-mode .new-chat-btn:hover {
    filter: brightness(1.06);
    transform: none;
    box-shadow: none;
}

@keyframes immersiveGradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Chat Items - Glass cards */
body.immersive-mode .chat-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin: 0.5rem 0.75rem;
    padding: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

body.immersive-mode .chat-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.1) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.immersive-mode .chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(0, 242, 254, 0.2);
    transform: translateX(4px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

body.immersive-mode .chat-item:hover::before {
    opacity: 1;
}

body.immersive-mode .chat-item.active {
    background: linear-gradient(135deg, rgba(118, 75, 162, 0.2) 0%, rgba(0, 242, 254, 0.1) 100%);
    border-color: rgba(0, 242, 254, 0.3);
    box-shadow:
        0 4px 20px rgba(0, 242, 254, 0.15),
        inset 0 0 20px rgba(0, 242, 254, 0.05);
}

/* ==========================================================================
   MAIN CHAT AREA - PREMIUM EXPERIENCE
   ========================================================================== */

body.immersive-mode .chat-main {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
}

/* Messages Container - padding from base rules; horizontal handled by .messages-wrapper */
body.immersive-mode .chat-messages-container,
body.immersive-mode #chat-messages-container {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 242, 254, 0.3) transparent;
}

body.immersive-mode .chat-messages-container::-webkit-scrollbar,
body.immersive-mode #chat-messages-container::-webkit-scrollbar {
    width: 6px;
}

body.immersive-mode .chat-messages-container::-webkit-scrollbar-track,
body.immersive-mode #chat-messages-container::-webkit-scrollbar-track {
    background: transparent;
}

body.immersive-mode .chat-messages-container::-webkit-scrollbar-thumb,
body.immersive-mode #chat-messages-container::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #764ba2, #00f2fe);
    border-radius: 3px;
}

/* ==========================================================================
   MESSAGE BUBBLES - STUNNING DESIGN
   ========================================================================== */

/* Message Container - layout handled by base rules (section 8-9) */
body.immersive-mode .chat-message {
    display: flex;
}

/* Desktop-only: entrance animation for messages (starts at opacity:0 in keyframe) */
@media (min-width: 768px) {
    body.immersive-mode .chat-message {
        animation: immersiveMessageSlideIn 0.3s ease-out;
    }
}

/* User Message Bubble - visual overrides only; layout (max-width) from base rules */
body.immersive-mode .user-message .message-bubble {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    border-radius: 20px 20px 4px 20px;
    padding: 1rem 1.25rem;
    max-width: min(58vw, 720px);
    box-shadow:
        0 4px 15px rgba(118, 75, 162, 0.3),
        0 0 30px rgba(118, 75, 162, 0.1);
    position: relative;
}

/* Phase 1 fix: the chat is ALWAYS in immersive mode, so the calm reading surface
   must hold here too. Neutralize the legacy glass bubble + left accent bar that
   were fighting the bubble-less assistant design (caused the cyan/purple vertical
   bar + a faint card behind AI replies). */
body.immersive-mode .assistant-message .message-bubble {
    /* Match the premium answer card in immersive mode (the chat is always immersive). */
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.018) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 16px;
    padding: 22px 26px;
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
}

/* A slim cyan→purple top accent for brand identity (replaces the old left bar) */
body.immersive-mode .assistant-message .message-bubble::before,
.chat-messages-container .chat-message.assistant-message .message-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #00f2fe, #764ba2);
    opacity: 0.55;
}

/* Message Text */
body.immersive-mode .message-text {
    color: var(--chat-text-secondary);
    line-height: 1.6;
}

body.immersive-mode .message-text p {
    margin: 0 0 0.75rem 0;
}

body.immersive-mode .message-text p:last-child {
    margin-bottom: 0;
}

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

/* Message avatars - visual overrides only; size (44px) from base rules */
body.immersive-mode .message-avatar {
    border-radius: 12px;
    background: linear-gradient(135deg, #764ba2, #00f2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 242, 254, 0.2);
    overflow: hidden;
}

body.immersive-mode .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

body.immersive-mode .message-avatar i {
    color: white;
    font-size: 1.1rem;
}

/* User avatar — branded purple, calm (no glow, to match the assistant avatar;
   the base .message-avatar box-shadow was leaking a cyan glow onto it). */
body.immersive-mode .user-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: none;
}

/* Assistant avatar — calm cyan-tint chip holding the logo (matches sidebar/empty-state) */
body.immersive-mode .assistant-avatar {
    background: rgba(0, 242, 254, 0.08);
    box-shadow: none;
}

/* ==========================================================================
   INPUT AREA - PREMIUM GLASS DESIGN
   ========================================================================== */

body.immersive-mode .chat-input-container {
    background: rgba(15, 20, 45, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 242, 254, 0.1);
    padding: 1.5rem 0; /* Vertical padding only */
    position: relative;
}

/* Input glow effect at top */
body.immersive-mode .chat-input-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 242, 254, 0.5), transparent);
}

/* Input wrapper with flex layout */
body.immersive-mode .chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 0.5rem 0.75rem;
    transition: all 0.3s ease;
}

body.immersive-mode .chat-input-wrapper:focus-within {
    border-color: rgba(0, 242, 254, 0.4);
    background: rgba(255, 255, 255, 0.05);
    box-shadow:
        0 0 0 3px rgba(0, 242, 254, 0.1),
        0 4px 20px rgba(0, 242, 254, 0.1);
}

/* Text Input */
body.immersive-mode .chat-input-field,
body.immersive-mode #chat-input-field {
    background: transparent;
    border: none;
    padding: 6px 0;
    color: white;
    font-size: 1rem;
    resize: none;
    flex: 1;
    min-height: 24px;
    max-height: 200px;
    line-height: 1.5;
}

body.immersive-mode .chat-input-field:focus,
body.immersive-mode #chat-input-field:focus {
    outline: none;
}

body.immersive-mode .chat-input-field::placeholder,
body.immersive-mode #chat-input-field::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Send Button — clean cyan→blue rounded square (matches .send-button-enhanced;
   the #id rule was overriding the redesign in immersive mode). */
body.immersive-mode .chat-send-btn,
body.immersive-mode #chat-send-btn {
    background: linear-gradient(135deg, #00f2fe, #58b9ff);
    border: none;
    border-radius: 11px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    color: #04121a;
    cursor: pointer;
    transition: filter 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
    box-shadow: 0 2px 10px rgba(0, 242, 254, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
}

body.immersive-mode .chat-send-btn:hover:not(:disabled),
body.immersive-mode #chat-send-btn:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 242, 254, 0.32);
}

body.immersive-mode .chat-send-btn:active:not(:disabled),
body.immersive-mode #chat-send-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.96);
}

body.immersive-mode .chat-send-btn:disabled,
body.immersive-mode #chat-send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

body.immersive-mode .chat-send-btn i,
body.immersive-mode #chat-send-btn i {
    font-size: 0.95rem;
}

/* ==========================================================================
   FOLLOW-UP QUESTIONS - FLOATING CARDS
   ========================================================================== */

body.immersive-mode .follow-up-questions,
body.immersive-mode .suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem;
    margin-top: 1rem;
}

body.immersive-mode .follow-up-btn,
body.immersive-mode .suggested-question {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(0, 242, 254, 0.15);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

body.immersive-mode .follow-up-btn:hover,
body.immersive-mode .suggested-question:hover {
    background: rgba(0, 242, 254, 0.1);
    border-color: rgba(0, 242, 254, 0.4);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.2);
}

/* ==========================================================================
   CONVERSATION STARTERS - PREMIUM BUTTONS
   ========================================================================== */

body.immersive-mode .conversation-starters {
    padding: 0.5rem 0;
}

body.immersive-mode .starters-title {
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.6));
    font-size: 0.78rem;
    margin-bottom: 0;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

body.immersive-mode .conversation-starters-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

body.immersive-mode .conversation-starter {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(0, 242, 254, 0.15);
    border-radius: 12px;
    padding: 0.875rem 1rem;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

body.immersive-mode .conversation-starter:hover {
    background: rgba(0, 242, 254, 0.08);
    border-color: rgba(0, 242, 254, 0.4);
    color: white;
    transform: translateX(8px);
    box-shadow: 0 4px 20px rgba(0, 242, 254, 0.15);
}

body.immersive-mode .conversation-starter:active {
    transform: translateX(4px);
}

/* ==========================================================================
   WELCOME MESSAGE - CINEMATIC INTRO
   ========================================================================== */

body.immersive-mode .welcome-message,
body.immersive-mode .chat-welcome {
    text-align: center;
    padding: 3rem 2rem;
}

/* Desktop-only: entrance animation (starts at opacity:0 in keyframe) */
@media (min-width: 768px) {
    body.immersive-mode .welcome-message,
    body.immersive-mode .chat-welcome {
        animation: immersiveWelcomeFadeIn 0.6s ease-out;
    }
}

body.immersive-mode .welcome-message h2,
body.immersive-mode .chat-welcome h2 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffffff 0%, #00f2fe 50%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

body.immersive-mode .welcome-message p,
body.immersive-mode .chat-welcome p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto;
}

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

/* ==========================================================================
   LOADING STATES - PREMIUM ANIMATIONS
   ========================================================================== */

body.immersive-mode .typing-indicator,
body.immersive-mode .loading-dots {
    display: flex;
    gap: 6px;
    padding: 1rem;
}

body.immersive-mode .typing-indicator span,
body.immersive-mode .loading-dots span {
    width: 7px;
    height: 7px;
    background: rgba(0, 242, 254, 0.7);
    border-radius: 50%;
    animation: immersiveTypingBounce 1.4s ease-in-out infinite;
}

body.immersive-mode .typing-indicator span:nth-child(2),
body.immersive-mode .loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

body.immersive-mode .typing-indicator span:nth-child(3),
body.immersive-mode .loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes immersiveTypingBounce {
    0%, 80%, 100% {
        transform: scale(0.9);
        opacity: 0.35;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   IMMERSIVE MODE - MOBILE RESPONSIVE
   ========================================================================== */

@media (max-width: 767px) {
    body.immersive-mode .modern-chat-container::before {
        animation: none; /* Reduce animation on mobile for performance */
    }

    body.immersive-mode .user-message .message-bubble {
        max-width: min(85vw, 720px);
    }

    body.immersive-mode .assistant-message .message-bubble {
        max-width: min(90vw, 880px);
    }

    body.immersive-mode .chat-input-container {
        padding: 1rem;
    }

    /* NOTE: Mobile padding for .chat-messages-container is handled by
       chat-mobile.css which uses CSS variables to clear the floating nav.
       Do NOT override padding here - it conflicts with mobile layout. */

    body.immersive-mode .conversation-starter {
        font-size: 0.9rem;
        padding: 0.75rem;
    }
}

/* ==========================================================================
   IMMERSIVE MODE - ACCESSIBILITY (REDUCED MOTION)
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    body.immersive-mode .modern-chat-container::before,
    body.immersive-mode .chat-sidebar::after,
    body.immersive-mode .new-chat-btn,
    body.immersive-mode .typing-indicator span,
    body.immersive-mode .loading-dots span {
        animation: none;
    }

    body.immersive-mode .chat-message,
    body.immersive-mode .welcome-message {
        animation: none;
    }

    body.immersive-mode .conversation-starter:hover,
    body.immersive-mode .chat-item:hover {
        transform: none;
    }
}

/* ============================================================================
   JAW-DROPPING CHAT REDESIGN - ENHANCED COMPONENTS
   ============================================================================
   Premium welcome card, conversation starters, message bubbles, sources,
   and input area with stunning animations and glass morphism effects.
   Version: 4.0 - Complete Premium Redesign
   ============================================================================ */

/* ============================================================================
   ENHANCED WELCOME CARD - JAW-DROPPING DESIGN
   ============================================================================ */

.welcome-card-container {
    padding: 40px 20px 30px;
    display: flex;
    justify-content: center;
    animation: fadeInUpLarge 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 1; /* Ensure base visibility - prevents flash of invisible content */
}

.welcome-card {
    max-width: 760px;
    width: 100%;
    background: linear-gradient(165deg,
        rgba(18, 24, 46, 0.72) 0%,
        rgba(12, 16, 34, 0.82) 100%);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 20px;
    padding: 38px 40px 34px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Slim brand accent line at the top — the one signature flourish (no shimmer) */
.welcome-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0, 242, 254, 0.7) 30%,
        rgba(118, 75, 162, 0.7) 70%,
        transparent 100%);
    z-index: 1;
}

.welcome-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% -20%,
        rgba(0, 180, 220, 0.05) 0%,
        transparent 60%);
    pointer-events: none;
}

/* Avatar Section — single clean mark, one soft static glow (no rotating rings) */
.welcome-avatar-container {
    position: relative;
    width: 76px;
    height: 76px;
    margin: 0 auto 18px;
}

/* Rotating dashed + gradient rings removed for a calm, premium look */
.welcome-avatar-container::after { display: none; }
.avatar-glow-ring { display: none; }

.welcome-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    z-index: 2;
    box-shadow:
        0 6px 22px rgba(0, 180, 220, 0.18),
        0 0 0 1px rgba(255, 255, 255, 0.07);
}

/* Content Section */
.welcome-content {
    text-align: center;
}

.welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 12px;
    color: #ffffff;
    -webkit-text-fill-color: #ffffff;
    letter-spacing: -0.01em;
}

.welcome-description {
    font-size: 1rem;
    line-height: 1.65;
    color: var(--chat-text-secondary);
    margin: 0 auto 22px;
    max-width: 560px;
}

/* Badges */
.welcome-badges {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--chat-text-secondary);
    transition: background 0.15s ease, border-color 0.15s ease;
}

.welcome-badge:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(0, 242, 254, 0.25);
}

.welcome-badge i {
    font-size: 0.85rem;
    color: var(--chat-accent-primary);
}

/* ============================================================================
   ENHANCED CONVERSATION STARTERS - BEAUTIFUL CARDS
   ============================================================================ */

.conversation-starters-container {
    padding: 6px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 760px;
    margin: 0 auto;
    animation: fadeInUpLarge 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.15s both;
    opacity: 1; /* Ensure base visibility - 'both' fill-mode now applies forwards state after animation */
}

.starters-header {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 4px;
}

.starters-icon {
    font-size: 1.05rem;
}

.starters-title {
    font-size: 0.78rem;
    font-weight: 600;
    margin: 0;
    color: var(--chat-text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

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

.starter-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
    text-align: left;
    overflow: hidden;
}

/* Staggered fade-in (subtle) */
.starter-card[data-delay="0"] { animation: scalePop 0.45s ease 0.1s both; }
.starter-card[data-delay="100"] { animation: scalePop 0.45s ease 0.18s both; }
.starter-card[data-delay="200"] { animation: scalePop 0.45s ease 0.26s both; }

.starter-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(0, 242, 254, 0.28);
    transform: translateY(-1px);
}

.starter-card:active {
    transform: translateY(0);
}

/* Emoji in a calm tinted chip (no heavy cyan drop-shadow) */
.starter-icon {
    font-size: 1.05rem;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 242, 254, 0.08);
    border-radius: 9px;
    filter: none;
}

.starter-text {
    flex: 1;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--chat-text-secondary);
    font-weight: 500;
}

/* Quiet chevron affordance that slides in on hover */
.starter-card::after {
    content: '\f054';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 0.68rem;
    color: var(--chat-text-subtle);
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.starter-card:hover::after {
    opacity: 0.75;
    transform: translateX(0);
}

/* Ripple removed for a calmer feel */
.starter-ripple { display: none; }

/* Mobile: Stack in single column */
@media (max-width: 767px) {
    .conversation-starters-container {
        padding: 16px;
    }

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

    .starter-text {
        font-size: 0.9rem;
    }
}

/* ============================================================================
   FOLLOW-UP QUESTIONS - Same Premium Design as Starters
   ============================================================================ */

/* Follow-up questions use same .starter-card class for unified styling */
.follow-up-questions-container {
    margin-top: 24px; /* Spacing after assistant message */
}

/* Cards inherit all .starter-card premium styles automatically */

/* User bubble - Stunning gradient */
.user-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 20px 20px 4px 20px;
    padding: 16px 20px;
    max-width: 70%;
    position: relative;
    box-shadow:
        0 8px 24px rgba(102, 126, 234, 0.3),
        0 0 40px rgba(118, 75, 162, 0.2);
    overflow: hidden;
}

.user-bubble::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.2) 0%,
        transparent 100%);
    pointer-events: none;
}

.user-bubble .message-text {
    color: white;
    font-size: 1rem;
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

.user-bubble .message-time {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 8px;
    text-align: right;
}

/* AI bubble - Glass morphism */
.ai-bubble {
    background: linear-gradient(135deg,
        rgba(20, 26, 50, 0.9) 0%,
        rgba(15, 21, 41, 0.95) 100%);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 20px 20px 20px 4px;
    padding: 20px 24px;
    max-width: 80%;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

.ai-bubble .message-text {
    color: var(--chat-text-primary);
    font-size: 1rem;
    line-height: 1.75;
}

/* Avatar enhancements */
.message-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    position: relative;
}

.ai-avatar {
    position: relative;
}

.ai-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 16px rgba(0, 242, 254, 0.4);
}

.avatar-pulse-ring {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(0, 242, 254, 0.5);
    animation: glowPulse 2s ease-in-out infinite;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    box-shadow: none;
}

/* ============================================================================
   ENHANCED SOURCES SECTION - BEAUTIFUL PILLS
   ============================================================================ */

.message-sources {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sources-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--chat-text-muted);
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.sources-label i {
    color: var(--chat-accent-primary);
    font-size: 0.9rem;
}

.sources-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.source-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Color-coded pills */
.source-pill.orange {
    background: rgba(255, 152, 0, 0.12);
    border: 1px solid rgba(255, 152, 0, 0.3);
    color: #ffab40;
}

.source-pill.blue {
    background: rgba(33, 150, 243, 0.12);
    border: 1px solid rgba(33, 150, 243, 0.3);
    color: #42a5f5;
}

.source-pill.green {
    background: rgba(76, 175, 80, 0.12);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: #66bb6a;
}

.source-pill:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 16px currentColor;
}

.source-pill.orange:hover {
    background: rgba(255, 152, 0, 0.2);
    border-color: rgba(255, 152, 0, 0.5);
    box-shadow: 0 4px 16px rgba(255, 152, 0, 0.4);
}

.source-pill.blue:hover {
    background: rgba(33, 150, 243, 0.2);
    border-color: rgba(33, 150, 243, 0.5);
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.4);
}

.source-pill.green:hover {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.5);
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.4);
}

.source-pill i {
    font-size: 0.9rem;
}

/* ============================================================================
   ENHANCED INPUT AREA - PREMIUM GLASS DESIGN
   ============================================================================ */

.chat-input-area-enhanced {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(to top,
        rgba(5, 6, 15, 0.98) 0%,
        rgba(5, 6, 15, 0.95) 50%,
        transparent 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: var(--z-input-area, 650);
}

.input-container-glass {
    max-width: min(1280px, 92%);  /* Match the conversation column so input + messages align */
    margin: 0 auto;
    position: relative;
}

.input-wrapper-enhanced {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 11px 11px 11px 18px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 16px;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

/* Clean single focus ring (no multi-layer bloom) */
.input-wrapper-enhanced:focus-within {
    border-color: rgba(0, 242, 254, 0.45);
    background: rgba(255, 255, 255, 0.05);
    box-shadow:
        0 0 0 3px rgba(0, 242, 254, 0.12),
        0 8px 28px rgba(0, 0, 0, 0.35);
}

.chat-input-enhanced {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--chat-text-primary);
    font-size: 1rem;
    line-height: 1.6;
    font-family: inherit;
    resize: none;
    max-height: 160px;
    min-height: 24px;
    padding: 6px 0;
}

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

.send-button-enhanced {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: linear-gradient(135deg, #00f2fe, #58b9ff);
    border: none;
    border-radius: 11px;
    color: #04121a;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 242, 254, 0.22);
}

.send-button-enhanced:not(:disabled):hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 242, 254, 0.32);
}

.send-button-enhanced:not(:disabled):active {
    transform: translateY(0) scale(0.96);
}

/* Ripple overlay + always-spinning conic glow removed for a calm, premium button */
.send-button-enhanced::before { display: none; }

.send-button-enhanced:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.send-button-glow { display: none; }

.input-hint {
    margin-top: 12px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--chat-text-subtle);
}

.input-hint kbd {
    display: inline-block;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--chat-text-secondary);
    margin: 0 2px;
}

/* Mobile adjustments */
@media (max-width: 767px) {
    .chat-input-area-enhanced {
        padding: 12px;
    }

    .input-wrapper-enhanced {
        padding: 12px 16px;
        border-radius: 20px;
    }

    .send-button-enhanced {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .input-hint {
        display: none; /* Hide on mobile for space */
    }
}

/* ============================================================================
   RESPONSIVE OVERRIDES - Full-width layout at all breakpoints
   AI messages LEFT, User messages RIGHT with appropriate constraints
   ============================================================================ */

/* Mobile portrait: Full width with minimal padding */
@media (max-width: 479px) {
    .messages-wrapper {
        padding: 0 12px;
    }

    /* AI messages - nearly full width on mobile */
    .chat-messages-container .assistant-message .message-bubble {
        max-width: min(90vw, 880px);
        padding: 16px 18px;
    }

    /* User messages - slightly narrower */
    .chat-messages-container .user-message .message-bubble {
        max-width: min(85vw, 720px);
        padding: 14px 16px;
    }

    /* Welcome card mobile overflow fix */
    .welcome-card-container {
        padding: 24px 12px 20px;
    }

    .welcome-card {
        padding: 24px 20px;
        border-radius: 20px;
    }

    .welcome-avatar-container {
        width: 80px;
        height: 80px;
        margin-bottom: 20px;
    }

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

    .welcome-description {
        font-size: 0.95rem;
    }
}

/* Mobile landscape / Small tablet */
@media (min-width: 480px) and (max-width: 767px) {
    .messages-wrapper {
        padding: 0 16px;
    }

    .chat-messages-container .assistant-message .message-bubble {
        max-width: min(88vw, 880px);
        padding: 18px 20px;
    }

    .chat-messages-container .user-message .message-bubble {
        max-width: min(80vw, 720px);
        padding: 16px 18px;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .messages-wrapper {
        padding: 0 24px;
    }

    .chat-messages-container .assistant-message .message-bubble {
        max-width: clamp(400px, 75vw, 700px);
        padding: 20px 24px;
    }

    .chat-messages-container .user-message .message-bubble {
        max-width: clamp(300px, 65vw, 600px);
        padding: 18px 22px;
    }
}

/* Desktop - use clamp for smooth scaling */
@media (min-width: 1024px) {
    .messages-wrapper {
        padding: 0 clamp(32px, 4vw, 60px);
    }

    .chat-messages-container .assistant-message .message-bubble {
        max-width: clamp(450px, 68vw, 850px);
    }

    .chat-messages-container .user-message .message-bubble {
        max-width: clamp(350px, 58vw, 700px);
    }
}

/* Large desktop - generous widths */
@media (min-width: 1400px) {
    .messages-wrapper {
        padding: 0 clamp(48px, 5vw, 80px);
    }

    .chat-messages-container .assistant-message .message-bubble {
        max-width: clamp(500px, 65vw, 900px);
    }

    .chat-messages-container .user-message .message-bubble {
        max-width: clamp(400px, 55vw, 750px);
    }
}

/* Ultra-wide screens */
@media (min-width: 1920px) {
    .messages-wrapper {
        padding: 0 100px;
    }

    .chat-messages-container .assistant-message .message-bubble {
        max-width: 950px;
    }

    .chat-messages-container .user-message .message-bubble {
        max-width: 800px;
    }
}

/* ============================================================================
   ANIMATIONS - SMOOTH & PROFESSIONAL
   ============================================================================ */

/* Renamed from fadeInUp to avoid collision with the 12px version in chat-sessions.css */
@keyframes fadeInUpLarge {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scalePop {
    0% {
        opacity: 0;
        transform: scale(0.9);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px currentColor;
        opacity: 0.6;
    }
    50% {
        box-shadow: 0 0 40px currentColor;
        opacity: 1;
    }
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(20);
        opacity: 0;
    }
}

/* Brief notification (non-intrusive) */
.chat-brief-notification {
    padding: 1rem 1.5rem;
    margin: 1rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    animation: chatSlideDown 0.3s ease-out;
    transition: opacity 0.3s ease;
}

.chat-brief-notification.info {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
    color: #3b82f6;
}

.chat-brief-notification.warning {
    background: rgba(251, 146, 60, 0.1);
    border-left: 3px solid #fb923c;
    color: #fb923c;
}

.chat-brief-notification.fade-out {
    opacity: 0;
}

/* Named chatSlideDown to avoid collision with any other slideDown keyframes */
@keyframes chatSlideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

/* ============================================================================
   BACKDROP-FILTER FALLBACK
   Fallback styles for browsers that don't support backdrop-filter
   (Safari < 15, older Firefox, etc.)
   ============================================================================ */
@supports not (backdrop-filter: blur(1px)) {
    .chat-sidebar {
        background: rgba(10, 14, 31, 0.98);
    }

    .chat-mobile-menu-toggle {
        background: rgba(10, 14, 31, 0.98);
    }

    .chat-messages-container .assistant-message .message-bubble {
        background: rgba(20, 26, 50, 0.98);
    }

    .input-container-glass {
        background: rgba(15, 21, 41, 0.98);
    }

    .input-wrapper-enhanced {
        background: rgba(21, 26, 53, 0.98);
    }

    .sidebar-notification {
        background: rgba(17, 24, 39, 0.98);
    }

    .session-menu-dropdown {
        background: rgba(30, 41, 59, 0.98);
    }
}

/* ============================================================================
   SCROLL-TO-BOTTOM FAB - DESKTOP (always available, positioned differently)
   ============================================================================ */
.scroll-to-bottom-fab {
    position: fixed;
    bottom: 100px;
    right: 32px;
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(0, 242, 254, 0.2);
    background: linear-gradient(135deg, rgba(15, 21, 41, 0.95) 0%, rgba(10, 14, 31, 0.98) 100%);
    color: var(--chat-accent-primary, #00f2fe);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(0, 242, 254, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(80px);
    opacity: 0;
    pointer-events: none;
}

.scroll-to-bottom-fab.visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.scroll-to-bottom-fab:hover {
    border-color: rgba(0, 242, 254, 0.5);
    box-shadow:
        0 6px 24px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(0, 242, 254, 0.2);
    transform: translateY(-2px);
}

.scroll-to-bottom-fab:active {
    transform: scale(0.92);
}

.scroll-to-bottom-fab .fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s ease;
}

.scroll-to-bottom-fab .fab-badge.has-count {
    opacity: 1;
    transform: scale(1);
}

/* ============================================================================
   COPY BUTTON — AI MESSAGE BUBBLES
   ============================================================================ */
.message-bubble {
    position: relative;
}

.message-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(15, 21, 41, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 5;
    padding: 0;
}

.message-bubble:hover .message-copy-btn,
.message-copy-btn:focus-visible {
    opacity: 1;
}

.message-copy-btn:hover {
    background: rgba(0, 242, 254, 0.15);
    border-color: rgba(0, 242, 254, 0.3);
    color: #00f2fe;
}

.message-copy-btn.copied {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
    opacity: 1;
}

/* Touch devices: always show copy button */
@media (hover: none) and (pointer: coarse) {
    .message-copy-btn {
        opacity: 0.7;
    }
}

/* ============================================================================
   COPY BUTTON — CODE BLOCKS
   ============================================================================ */
.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: rgba(15, 21, 41, 0.8);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 5;
    padding: 0;
}

pre:hover .code-copy-btn,
.code-copy-btn:focus-visible {
    opacity: 1;
}

.code-copy-btn:hover {
    background: rgba(0, 242, 254, 0.15);
    border-color: rgba(0, 242, 254, 0.3);
    color: #00f2fe;
}

.code-copy-btn.copied {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
    opacity: 1;
}

@media (hover: none) and (pointer: coarse) {
    .code-copy-btn {
        opacity: 0.7;
    }
}

/* ============================================================================
   MESSAGE ACTION MENU (long-press context menu)
   ============================================================================ */
.message-action-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 8px;
    display: flex;
    gap: 4px;
    padding: 6px;
    background: rgba(15, 21, 41, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 242, 254, 0.08);
    z-index: 100;
    animation: menuFadeIn 0.15s ease-out;
}

@keyframes menuFadeIn {
    from { opacity: 0; transform: translateY(4px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.message-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.message-action-btn:hover {
    background: rgba(0, 242, 254, 0.1);
    color: #00f2fe;
}

.message-action-btn.copy-success {
    color: #22c55e;
}

.message-action-btn i {
    font-size: 14px;
}

/* ============================================================================
   PULL-TO-REFRESH INDICATOR
   ============================================================================ */
.pull-to-refresh {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(15, 21, 41, 0.9);
    border: 1px solid rgba(0, 242, 254, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #00f2fe;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 20;
    pointer-events: none;
}

.pull-to-refresh.active {
    opacity: 1;
}

.pull-to-refresh.active i {
    animation: refreshSpin 0.8s linear infinite;
}

@keyframes refreshSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ============================================================================
   STREAMING PROGRESS INDICATOR
   Real-time progress updates during AI response generation
   ============================================================================ 
*/

.ai-progress-indicator {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, 
        rgba(0, 242, 254, 0.05) 0%, 
        rgba(15, 21, 41, 0.8) 100%);
    border-radius: 16px;
    border: 1px solid rgba(0, 242, 254, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: progressFadeIn 0.3s ease-out;
}

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

.ai-progress-indicator .progress-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    padding: 2px;
}

.ai-progress-indicator .progress-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.ai-progress-indicator .progress-content {
    flex: 1;
    min-width: 0;
}

.ai-progress-indicator .progress-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    color: #e4e4e7;
    margin-bottom: 8px;
}

.ai-progress-indicator .progress-message {
    color: #00f2fe;
    font-weight: 500;
}

.ai-progress-indicator .progress-dots span {
    animation: dotPulse 1.4s infinite;
    opacity: 0.3;
}

.ai-progress-indicator .progress-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-progress-indicator .progress-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

.ai-progress-indicator .progress-agents {
    margin-bottom: 10px;
}

.ai-progress-indicator .agents-header {
    font-size: 11px;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.ai-progress-indicator .agents-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-progress-indicator .agent-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(0, 242, 254, 0.1);
    border: 1px solid rgba(0, 242, 254, 0.2);
    border-radius: 12px;
    font-size: 11px;
    color: #71717a;
    transition: all 0.3s ease;
}

.ai-progress-indicator .agent-badge.completed {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

.ai-progress-indicator .progress-bar-container {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.ai-progress-indicator .progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00f2fe 0%, #4facfe 50%, #00f2fe 100%);
    background-size: 200% 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: progressShimmer 2s linear infinite;
}

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

/* Mobile adjustments for progress indicator */
@media (max-width: 768px) {
    .ai-progress-indicator {
        padding: 12px 14px;
        margin: 0 4px 8px;
    }
    
    .ai-progress-indicator .progress-avatar {
        width: 32px;
        height: 32px;
    }
    
    .ai-progress-indicator .progress-status {
        font-size: 13px;
    }
    
    .ai-progress-indicator .agent-badge {
        padding: 3px 8px;
        font-size: 10px;
    }
}

/* ===== TOKEN STREAMING STYLES ===== */
/* Progressive response display with blinking cursor */

.streaming-response .content {
    position: relative;
}

.streaming-response .streaming-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
    color: var(--text-primary, #1a1a1a);
}

.streaming-response .streaming-cursor {
    display: inline;
    color: var(--chat-accent-primary, #00f2fe);
    animation: cursorBlink 1s ease-in-out infinite;
    margin-left: 2px;
    font-weight: bold;
}

@keyframes cursorBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .streaming-response .streaming-text {
        color: var(--text-primary-dark, #e5e5e5);
    }
}

/* Smooth fade-in for streaming response */
.streaming-response {
    animation: streamFadeIn 0.2s ease-out;
}

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

/* ============================================================================
   PHASE 2 — LIVE AGENT ORCHESTRATION (HERO)
   Replaces the decorative thinking animation with an honest, premium view of
   the real multi-agent pipeline the chat backend streams. Container class is
   `orch-indicator` (set in showTypingIndicator*); rows are data-driven.
   ============================================================================ */
.orch-indicator {
    width: 100%;
    animation: streamFadeIn 0.25s ease-out;
}

.orch-indicator.thinking-exit {
    opacity: 0;
    transition: opacity 0.25s ease;
}

.orch {
    max-width: 78ch;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.022);
    overflow: hidden;
}

.orch-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.orch-pulse {
    width: 9px;
    height: 9px;
    flex: none;
    border-radius: 50%;
    background: var(--chat-accent-primary, #00f2fe);
    box-shadow: 0 0 10px var(--chat-accent-primary, #00f2fe);
    animation: orchPulse 1.4s ease-in-out infinite;
}

.orch-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--chat-text-primary, #fff);
    transition: opacity 0.15s ease;
}

.orch-meta {
    margin-left: auto;
    font-size: 11.5px;
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.6));
    font-variant-numeric: tabular-nums;
}

.orch-list { padding: 6px; }

.orow {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: 10px;
}

.orow + .orow { margin-top: 1px; }

.orow-ic {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.6));
    transition: all 0.25s ease;
}

.orow-body { flex: 1; min-width: 0; }

.orow-name {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--chat-text-primary, #fff);
}

.orow-sub {
    font-size: 11.5px;
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.5));
    margin-top: 1px;
}

.orow-state {
    width: 22px;
    height: 22px;
    flex: none;
    display: grid;
    place-items: center;
    font-size: 12px;
}

.orow-spin {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--chat-accent-primary, #00f2fe);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.orow--pending .orow-ic { opacity: 0.45; }
.orow--pending .orow-name { color: var(--chat-text-muted, rgba(255, 255, 255, 0.55)); }

.orow--active .orow-ic {
    background: rgba(0, 242, 254, 0.12);
    color: var(--chat-accent-primary, #00f2fe);
    box-shadow: 0 0 0 1px rgba(0, 242, 254, 0.25);
}

.orow--done .orow-ic {
    background: rgba(52, 211, 153, 0.14);
    color: #34d399;
}
.orow--done .orow-state { color: #34d399; }
.orow--skipped { opacity: 0.4; }
.orow-found { color: #34d399; font-weight: 500; }

.orch-foot {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 13px;
    color: var(--chat-text-secondary, rgba(255, 255, 255, 0.85));
}
.orch-foot.is-on { display: flex; }

/* Attribution footer on completed assistant messages ("show your working") */
.message-attrib {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px 11px;
    border-radius: 9px;
    font-size: 11.5px;
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.55));
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.07);
}
.message-attrib i { color: var(--chat-accent-primary, #00f2fe); }
.message-attrib b { color: var(--chat-text-secondary, rgba(255, 255, 255, 0.85)); font-weight: 600; }

@keyframes orchPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

@media (prefers-reduced-motion: reduce) {
    .orch-pulse, .orow-spin { animation: none; }
}

/* ============================================================================
   PHASE 3 — MESSAGE ACTIONS + STREAMING CRAFT
   ============================================================================ */

/* Per-message hover action toolbar (sits below the message, collapses when idle) */
.message-actions {
    display: flex;
    gap: 2px;
    max-height: 0;
    margin-top: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.18s ease, opacity 0.15s ease, margin-top 0.18s ease;
}
.chat-message:hover .message-actions,
.chat-message:focus-within .message-actions {
    max-height: 40px;
    margin-top: 6px;
    opacity: 1;
}
.user-message .message-actions { justify-content: flex-end; }

.msg-act {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    min-width: 30px;
    padding: 0 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.5));
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.msg-act:hover {
    color: var(--chat-text-primary, #fff);
    background: rgba(255, 255, 255, 0.06);
}
.msg-act.copied { color: #34d399; }
.msg-act.act-on { color: var(--chat-accent-primary, #00f2fe); }

/* Composer Stop state (send button transforms into Stop while streaming) */
/* Stop state — scoped to immersive so it beats `body.immersive-mode #chat-send-btn` (1,1,1) */
body.immersive-mode #chat-send-btn.is-stop {
    background: rgba(239, 68, 68, 0.16);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ff8585;
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.18);
}

/* Honest streaming caret — hugs the last character, blinks while streaming only */
.streaming-text::after {
    content: '';
    display: inline-block;
    width: 8px;
    height: 1.05em;
    margin-left: 2px;
    vertical-align: text-bottom;
    border-radius: 1.5px;
    background: var(--chat-accent-primary, #00f2fe);
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.6);
    animation: caretBlink 1.05s steps(2, start) infinite;
}

/* "Stopped" affordance on an interrupted reply */
.stopped-note {
    margin-top: 6px;
    font-size: 11px;
    font-style: italic;
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.45));
}

@keyframes caretBlink {
    0%, 50% { opacity: 1; }
    50.01%, 100% { opacity: 0; }
}

/* Touch devices have no hover — keep the action toolbar visible */
@media (hover: none) {
    .message-actions {
        max-height: 40px;
        margin-top: 6px;
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .streaming-text::after { animation: none; }
    .message-actions { transition: opacity 0.15s ease; }
}

/* ============================================================================
   PHASE 4 — HISTORY SEARCH + RENAME/PIN
   ============================================================================ */
.sidebar-search { position: relative; margin: 4px 14px 10px; }
.sidebar-search-ic {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.5)); font-size: 12px; pointer-events: none;
}
.sidebar-search-input {
    width: 100%; padding: 9px 30px 9px 32px; border-radius: 11px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--chat-glass-border, rgba(255, 255, 255, 0.08));
    color: var(--chat-text-primary, #fff); font-family: inherit; font-size: 13px;
    outline: none; transition: border-color 0.15s ease, background 0.15s ease;
}
.sidebar-search-input::placeholder { color: var(--chat-text-muted, rgba(255, 255, 255, 0.45)); }
.sidebar-search-input:focus {
    border-color: var(--chat-glass-border-hover, rgba(0, 242, 254, 0.3));
    background: rgba(0, 242, 254, 0.05);
}
.sidebar-search-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    width: 22px; height: 22px; border: none; border-radius: 6px; background: transparent;
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.5)); cursor: pointer;
    display: grid; place-items: center; font-size: 11px;
}
.sidebar-search-clear:hover { color: var(--chat-text-primary, #fff); background: rgba(255, 255, 255, 0.08); }
.sidebar-search-empty {
    padding: 16px 14px; font-size: 12.5px; text-align: center;
    color: var(--chat-text-muted, rgba(255, 255, 255, 0.5));
}

/* Pin / rename affordances + pinned indicator */
.chat-pin-ic { color: var(--chat-accent-primary, #00f2fe); font-size: 10px; margin-right: 2px; }
.chat-item--pinned { border-left: 2px solid rgba(0, 242, 254, 0.4); }
.chat-pin-btn:hover, .chat-rename-btn:hover { color: var(--chat-accent-primary, #00f2fe); }
.chat-item--pinned .chat-pin-btn { color: var(--chat-accent-primary, #00f2fe); }

/* ============================================================================
   PHASE 5 — ARTIFACTS SIDE PANEL (in-flow flex child; never position:fixed on desktop)
   ============================================================================ */
.chat-artifacts {
    width: 0;
    flex: none;
    overflow: hidden;
    border-left: 1px solid var(--chat-glass-border, rgba(255, 255, 255, 0.08));
    background: linear-gradient(180deg, rgba(12, 16, 36, 0.6), rgba(8, 10, 26, 0.85));
    transition: width 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}
body.chat-artifacts-open .chat-artifacts { width: clamp(340px, 32vw, 540px); }
.chat-artifacts__inner {
    width: clamp(340px, 32vw, 540px);
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.chat-artifacts__head {
    display: flex; align-items: center; gap: 11px; padding: 14px 16px;
    border-bottom: 1px solid var(--chat-glass-border, rgba(255, 255, 255, 0.08));
}
.chat-artifacts__ic {
    width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center;
    background: rgba(0, 242, 254, 0.1); color: var(--chat-accent-primary, #00f2fe); font-size: 13px;
}
.chat-artifacts__meta { min-width: 0; flex: 1; }
.chat-artifacts__name {
    font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 500;
    color: var(--chat-text-primary, #fff); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-artifacts__sub { font-size: 11px; color: var(--chat-text-muted, rgba(255, 255, 255, 0.5)); margin-top: 1px; }
.chat-artifacts__btn {
    width: 30px; height: 30px; flex: none; border: none; border-radius: 8px; cursor: pointer;
    background: rgba(255, 255, 255, 0.05); color: var(--chat-text-secondary, rgba(255, 255, 255, 0.85));
    font-size: 13px; transition: all 0.15s ease;
}
.chat-artifacts__btn:hover { color: var(--chat-accent-primary, #00f2fe); background: rgba(0, 242, 254, 0.1); }
#artifact-close:hover { color: #ff8585; background: rgba(239, 68, 68, 0.14); }
.chat-artifacts__body { flex: 1; min-height: 0; overflow: auto; }

.artifact-tabs { display: flex; gap: 4px; padding: 10px 14px 0; }
.artifact-tab {
    padding: 7px 14px; border: 1px solid transparent; border-bottom: none; border-radius: 9px 9px 0 0;
    background: transparent; color: var(--chat-text-muted, rgba(255, 255, 255, 0.5)); font-family: inherit;
    font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.artifact-tab--active {
    color: var(--chat-accent-primary, #00f2fe); background: rgba(0, 242, 254, 0.07);
    border-color: var(--chat-glass-border, rgba(255, 255, 255, 0.08));
}
.artifact-code { padding: 14px 16px; }
.artifact-code pre {
    margin: 0; background: #0c1024; border: 1px solid var(--chat-glass-border, rgba(255, 255, 255, 0.08));
    border-radius: 10px; padding: 14px 16px; overflow-x: auto;
}
.artifact-code pre code { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; line-height: 1.6; text-shadow: none; }
.artifact-preview { padding: 14px 16px; height: calc(100% - 44px); }
.artifact-preview iframe {
    width: 100%; height: 100%; min-height: 320px; border-radius: 10px; background: #fff;
    border: 1px solid var(--chat-glass-border, rgba(255, 255, 255, 0.08));
}

/* "Open in panel" button inside a code-block header */
.code-open-btn {
    margin-left: auto;
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px;
    font-family: inherit; font-size: 11.5px; font-weight: 500; cursor: pointer;
    color: var(--chat-accent-primary, #00f2fe);
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid var(--chat-glass-border-hover, rgba(0, 242, 254, 0.25));
    transition: all 0.15s ease;
}
.code-open-btn:hover { background: rgba(0, 242, 254, 0.16); }

/* Mobile: full-screen overlay (chat wrapper transform is disabled on mobile, so fixed is safe) */
@media (max-width: 1023px) {
    body.chat-artifacts-open .chat-artifacts {
        position: fixed; inset: 0; width: 100vw; z-index: var(--z-modal, 1050);
    }
    .chat-artifacts__inner { width: 100%; }
}

/* ============================================================================
   AI RESPONSE POLISH — proportionate markdown headings + tidy sources
   (markdown headings had no size cap, so h1/h2 rendered at browser-default huge)
   ============================================================================ */
.message-text h1 {
    font-size: 1.4rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.3px;
    margin: 20px 0 10px; color: #fff;
}
.message-text h2 {
    font-size: 1.18rem; font-weight: 650; line-height: 1.35;
    margin: 20px 0 8px; color: #fff;
}
.message-text h3 {
    font-size: 1.04rem; font-weight: 650; line-height: 1.4;
    margin: 16px 0 8px; color: #fff;
}
.message-text h4 {
    font-size: 0.95rem; font-weight: 600; line-height: 1.4;
    margin: 14px 0 6px; color: rgba(255, 255, 255, 0.92);
}
.message-text h1:first-child,
.message-text h2:first-child,
.message-text h3:first-child { margin-top: 0; }

/* Quiet divider + compact, muted Sources list (verbose backend citation text) */
.message-text hr {
    border: none; border-top: 1px solid rgba(255, 255, 255, 0.08); margin: 18px 0;
}
.message-text h2 + ol,
.message-text h2 + ul,
.message-text ol:last-child {
    font-size: 0.85rem; color: var(--chat-text-muted, rgba(255, 255, 255, 0.55)); line-height: 1.5;
}
.message-text h2 + ol a,
.message-text ol:last-child a { word-break: break-word; }

/* ============================================================================
   PREMIUM RESPONSE — clear tables, heading accent, sources card + panel
   ============================================================================ */

/* Tables — clear and premium whether or not wrapped in .table-responsive */
.message-text table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 16px 0;
    font-size: 0.9rem;
    background: rgba(8, 11, 26, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    overflow: hidden;
}
.message-text .table-responsive { overflow-x: auto; margin: 16px 0; border-radius: 12px; }
.message-text .table-responsive table { margin: 0; }
.message-text thead th {
    text-align: left;
    padding: 11px 16px;
    font-weight: 650;
    color: #fff;
    background: rgba(0, 242, 254, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    white-space: nowrap;
}
.message-text tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.88);
    vertical-align: top;
}
.message-text tbody tr:last-child td { border-bottom: none; }
.message-text tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.022); }
.message-text tbody tr:hover td { background: rgba(0, 242, 254, 0.05); }
.message-text th + th, .message-text td + td { border-left: 1px solid rgba(255, 255, 255, 0.06); }

/* Section-heading accent (subtle divider under h2) */
.message-text h2 { padding-bottom: 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }

/* Clickable Sources card (replaces the inline chips; opens the right panel) */
.sources-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin: 0 0 16px;
    padding: 13px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.06), rgba(118, 75, 162, 0.06));
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.18s ease;
    text-align: left;
    font-family: inherit;
}
.sources-card:hover {
    border-color: rgba(0, 242, 254, 0.35);
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.1), rgba(118, 75, 162, 0.1));
    transform: translateY(-1px);
}
.sources-card__ic {
    width: 34px; height: 34px; flex: none; border-radius: 9px; display: grid; place-items: center;
    background: rgba(0, 242, 254, 0.12); color: #00f2fe; font-size: 14px;
}
.sources-card__body { flex: 1; min-width: 0; }
.sources-card__title { font-size: 13.5px; font-weight: 600; color: #fff; }
.sources-card__sub { font-size: 11.5px; color: var(--chat-text-muted, rgba(255, 255, 255, 0.55)); margin-top: 1px; }
.sources-card__avatars { display: flex; align-items: center; padding-left: 6px; }
.sources-card__avatars .src-dot {
    width: 22px; height: 22px; border-radius: 50%; margin-left: -6px;
    background: rgba(20, 26, 50, 0.95); border: 1px solid rgba(0, 242, 254, 0.4);
    display: grid; place-items: center; font-size: 9px; font-weight: 700; color: #00f2fe;
}
.sources-card__chev { color: var(--chat-text-muted, rgba(255, 255, 255, 0.5)); font-size: 13px; }

/* Source cards inside the right panel — premium, clickable */
.artifact-sources { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.artifact-source {
    display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: 12px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
    border: 1px solid rgba(255, 255, 255, 0.09);
    text-decoration: none; transition: all 0.18s ease; position: relative;
}
.artifact-source:hover {
    border-color: rgba(0, 242, 254, 0.4);
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.08), rgba(118, 75, 162, 0.06));
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}
.artifact-source__num {
    width: 24px; height: 24px; flex: none; border-radius: 8px; display: grid; place-items: center;
    background: linear-gradient(135deg, rgba(0, 242, 254, 0.2), rgba(118, 75, 162, 0.2));
    color: #00f2fe; font-size: 11px; font-weight: 700; border: 1px solid rgba(0, 242, 254, 0.3);
}
.artifact-source__body { min-width: 0; flex: 1; padding-right: 16px; }
.artifact-source__title { font-size: 13px; font-weight: 600; color: #fff; line-height: 1.42; margin-bottom: 5px; }
.artifact-source__domain { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--chat-accent-primary, #00f2fe); }
.artifact-source__domain i { font-size: 10px; opacity: 0.85; }
.artifact-source__open { position: absolute; top: 13px; right: 13px; font-size: 11px; color: var(--chat-text-muted, rgba(255, 255, 255, 0.4)); transition: all 0.15s ease; }
.artifact-source:hover .artifact-source__open { color: #00f2fe; }
.artifact-source.is-internal { cursor: default; }

/* ============================================================================
   SIDEBAR REDESIGN — clean, premium, restrained (overrides the legacy sidebar)
   ============================================================================ */

/* Shell */
.chat-sidebar {
    background: #0b0f1f;
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    flex-direction: column;
}
/* Remove the legacy animated glow accent line on the sidebar edge */
.chat-sidebar::before,
.chat-sidebar::after { display: none; content: none; }
/* Overflow safety — keep all children within the sidebar width */
.chat-sidebar,
.chat-sidebar * { box-sizing: border-box; }

/* Brand — larger logo mark for stronger branding */
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 18px 16px 16px; }
.sidebar-brand-logo {
    width: 42px; height: 42px; flex: none; border-radius: 11px; display: grid; place-items: center;
    overflow: hidden; background: rgba(255, 255, 255, 0.05);
}
.sidebar-brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 1px; }
.sidebar-brand-name { font-weight: 700; font-size: 16px; color: rgba(255, 255, 255, 0.94); letter-spacing: 0.2px; }
/* Brand (logo + name) is clickable → returns to chat home */
.sidebar-brand-logo, .sidebar-brand-name { cursor: pointer; transition: opacity 0.14s ease; }
.sidebar-brand-logo:hover, .sidebar-brand-name:hover { opacity: 0.82; }

/* ============================================================================
   SETTINGS / PROFILE MODAL (opened from the sidebar user chip)
   ============================================================================ */
/* User chip is clickable → opens the settings modal */
.sidebar-foot-avatar, .sidebar-foot-user { cursor: pointer; }
.chat-sidebar .sidebar-foot-avatar { transition: filter 0.14s ease; }
.chat-sidebar .sidebar-foot:hover .sidebar-foot-avatar { filter: brightness(1.08); }

/* The popover LAYER — a transparent full-viewport click-catcher (closes on
   outside-click); NO backdrop dim, so the chat stays fully visible behind it. */
#settings-modal.settings-pop {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 1050);
    background: transparent;
}

/* The account CARD — a compact popover anchored just above the user chip.
   Default coords here (expanded sidebar); JS overrides left/bottom per the
   chip's measured position so it also works collapsed / on mobile. */
.settings-modal {
    position: fixed;
    left: 12px;
    bottom: 64px;
    width: 264px;
    max-width: calc(100vw - 24px);
    padding: 0;
    overflow: hidden;
    background: linear-gradient(165deg, rgba(18, 24, 46, 0.99) 0%, rgba(12, 16, 34, 0.995) 100%);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03);
    transform-origin: bottom left;
    animation: settingsPopIn 0.16s cubic-bezier(0.2, 0, 0.2, 1);
}
@keyframes settingsPopIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.settings-modal-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 16px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.settings-modal-avatar {
    width: 44px;
    height: 44px;
    flex: none;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-weight: 700;
    font-size: 1.15rem;
}
.settings-modal-id { min-width: 0; }
.settings-modal-name { font-size: 0.98rem; font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-modal-email {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.settings-modal-tier {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 3px 10px;
    border-radius: 8px;
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.18);
    font-size: 0.74rem;
    font-weight: 600;
    color: #9fe8f2;
}
.settings-modal-tier i { font-size: 0.7rem; color: #00f2fe; }

.settings-modal-rows {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.settings-row {
    display: flex;
    align-items: center;
    gap: 13px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    background: transparent;
    border: none;
    text-align: left;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.9);
    font-family: inherit;
    cursor: pointer;
    transition: background 0.14s ease;
}
.settings-row:hover { background: rgba(255, 255, 255, 0.05); }
.settings-row-ic {
    width: 36px;
    height: 36px;
    flex: none;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: rgba(0, 242, 254, 0.08);
    border: 1px solid rgba(0, 242, 254, 0.16);
    color: #00f2fe;
    font-size: 0.85rem;
}
.settings-row-txt {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.settings-row-txt b { font-size: 0.9rem; font-weight: 600; color: #fff; }
.settings-row-txt small { font-size: 0.76rem; color: rgba(255, 255, 255, 0.5); margin-top: 1px; }
.settings-row-chev { color: rgba(255, 255, 255, 0.3); font-size: 0.72rem; flex: none; }

.settings-modal-foot {
    padding: 12px 14px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.settings-logout-form { margin: 0; }
.settings-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 11px 14px;
    border-radius: 11px;
    background: rgba(239, 68, 68, 0.10);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #ff8585;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease;
}
.settings-logout-btn:hover { background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.4); }

/* Collapse button (clean) */
.chat-sidebar .sidebar-collapse-btn {
    margin-left: auto; width: 30px; height: 30px; border-radius: 8px; border: none; cursor: pointer;
    background: transparent; color: rgba(255, 255, 255, 0.38); font-size: 13px; display: grid; place-items: center;
    transition: all 0.14s ease;
}
.chat-sidebar .sidebar-collapse-btn:hover { background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.6); }

/* Top elements must NOT grow in the flex column (legacy .new-chat-btn had flex:1,
   which made it balloon vertically). Only the recent list grows. */
.chat-sidebar .sidebar-brand,
.chat-sidebar .new-chat-btn,
.chat-sidebar .sidebar-search,
.chat-sidebar .sidebar-foot { flex: none; }

/* New chat — single branded CTA */
.chat-sidebar .new-chat-btn {
    flex: none;
    display: flex; align-items: center; justify-content: center; gap: 9px;
    margin: 0 12px 16px; padding: 12px 14px; border-radius: 11px; cursor: pointer;
    font-family: inherit; font-size: 14px; font-weight: 600; color: #04121a; border: none;
    background: linear-gradient(135deg, #00f2fe, #58b9ff); box-shadow: none;
    transition: filter 0.14s ease; overflow: visible;
}
.chat-sidebar .new-chat-btn:hover { filter: brightness(1.06); transform: none; box-shadow: none; }
.chat-sidebar .new-chat-btn::before,
.chat-sidebar .new-chat-btn::after { display: none; }
.chat-sidebar .new-chat-btn i { font-size: 12px; }
/* GEOMETRY PIN (expanded): the #id (1,0,0) beats workspace.css's
   `.new-chat-btn { width: 100% }` (0,1,0), which was making the button 280px +
   24px margins = 304px → overflow. width:auto lets the flex column stretch it to
   fill the sidebar MINUS the 12px margins (= 256px), aligned with the search box.
   The collapsed/hover #new-chat-btn rules below override this per state. */
#new-chat-btn {
    width: auto;
    flex: none;
    margin: 0 12px 16px;
    padding: 12px 14px;
}

/* Search */
.chat-sidebar .sidebar-search { position: relative; margin: 0 12px 18px; }
.chat-sidebar .sidebar-search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: rgba(255, 255, 255, 0.38); font-size: 12px; }
.chat-sidebar .sidebar-search-input {
    width: 100%; padding: 9px 30px 9px 33px; border-radius: 10px; outline: none;
    background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.92); font-family: inherit; font-size: 13px;
    transition: border-color 0.14s ease, background 0.14s ease;
}
.chat-sidebar .sidebar-search-input::placeholder { color: rgba(255, 255, 255, 0.38); }
.chat-sidebar .sidebar-search-input:focus { border-color: rgba(0, 242, 254, 0.35); background: rgba(0, 242, 254, 0.04); }
.chat-sidebar .sidebar-search-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    width: 22px; height: 22px; border: none; border-radius: 6px; background: transparent;
    color: rgba(255, 255, 255, 0.4); cursor: pointer;
}
.chat-sidebar .sidebar-search-clear:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* Segmented service switcher */
.chat-sidebar .service-tabs {
    display: flex; gap: 2px; margin: 0 12px 16px; padding: 3px; border-radius: 11px;
    background: rgba(255, 255, 255, 0.035); border: 1px solid rgba(255, 255, 255, 0.07);
}
.chat-sidebar .service-tab {
    flex: 1; padding: 7px 6px; border: none; border-radius: 8px; cursor: pointer;
    font-family: inherit; font-size: 12.5px; font-weight: 500; color: rgba(255, 255, 255, 0.55);
    background: transparent; display: flex; align-items: center; justify-content: center; gap: 7px;
    transition: color 0.14s ease, background 0.14s ease; box-shadow: none;
}
.chat-sidebar .service-tab i { font-size: 12px; }
.chat-sidebar .service-tab:hover { color: rgba(255, 255, 255, 0.92); background: transparent; }
.chat-sidebar .service-tab.active { color: #fff; background: rgba(255, 255, 255, 0.08); font-weight: 600; box-shadow: none; }

/* Recent section */
.chat-sidebar .sidebar-sessions { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 12px 8px; }
.chat-sidebar .sidebar-sessions-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 10px; }
.chat-sidebar .sidebar-sessions-title { font-size: 11px; font-weight: 600; letter-spacing: 0.7px; text-transform: uppercase; color: rgba(255, 255, 255, 0.38); }
.chat-sidebar .sidebar-sessions-refresh { background: none; border: none; color: rgba(255, 255, 255, 0.38); cursor: pointer; font-size: 12px; padding: 4px; }
.chat-sidebar .sidebar-sessions-refresh:hover { color: rgba(255, 255, 255, 0.6); }
/* Content-height (≤5 items) so "View all history" sits right under the list and
   the empty space falls once, above the footer — not stretched through the middle. */
.chat-sidebar .sidebar-sessions-list { flex: 0 1 auto; min-height: 0; overflow-y: auto; }

/* Recent rows — calm: no lift, no glow, no heavy borders */
.chat-sidebar .chat-item {
    display: block; padding: 10px 12px 10px 14px; border-radius: 9px; margin-bottom: 6px;
    border: 1px solid transparent; background: transparent; box-shadow: none;
    cursor: pointer; transition: background 0.12s ease; overflow: hidden; position: relative;
}
.chat-sidebar .chat-item:hover { background: rgba(255, 255, 255, 0.045); border-color: transparent; transform: none; box-shadow: none; }
.chat-sidebar .chat-item.active { background: rgba(0, 242, 254, 0.09); border-color: transparent; box-shadow: none; }
.chat-sidebar .chat-item.active::before {
    content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2.5px; height: auto;
    border-radius: 0 3px 3px 0; background: #00f2fe; transform: none; opacity: 1;
}
.chat-sidebar .chat-item-header { display: flex; align-items: center; }
.chat-sidebar .chat-title { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 500; color: rgba(255, 255, 255, 0.92); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sidebar .chat-item.active .chat-title { color: #fff; }
.chat-sidebar .chat-pin-ic { color: #00f2fe; font-size: 10px; margin-right: 5px; }
.chat-sidebar .chat-preview { display: none; }
.chat-sidebar .chat-item-footer { display: flex; align-items: center; gap: 8px; margin-top: 3px; transition: opacity 0.12s ease; }
.chat-sidebar .chat-time,
.chat-sidebar .chat-message-count { font-size: 11.5px; color: rgba(255, 255, 255, 0.38); display: flex; align-items: center; gap: 4px; }
.chat-sidebar .chat-item:hover .chat-item-footer { opacity: 0; }

/* Hover actions — quiet ghost icons */
.chat-sidebar .chat-actions { position: absolute; top: 7px; right: 8px; display: flex; gap: 1px; opacity: 0; transition: opacity 0.12s ease; }
.chat-sidebar .chat-item:hover .chat-actions { opacity: 1; }
.chat-sidebar .chat-action-btn {
    width: 24px; height: 24px; border: none; border-radius: 7px; cursor: pointer;
    background: rgba(255, 255, 255, 0.06); color: rgba(255, 255, 255, 0.55); font-size: 10px;
    display: grid; place-items: center; transition: all 0.12s ease;
}
.chat-sidebar .chat-action-btn:hover { background: rgba(0, 242, 254, 0.14); color: #00f2fe; }
.chat-sidebar .chat-delete-btn:hover { background: rgba(239, 68, 68, 0.16); color: #ff6b6b; }

/* View all history */
.chat-sidebar .sidebar-viewall {
    display: flex; align-items: center; gap: 9px; width: 100%; padding: 10px 12px; margin: 8px 0 4px;
    border: none; background: transparent; border-radius: 9px; cursor: pointer;
    color: rgba(255, 255, 255, 0.55); font-family: inherit; font-size: 13px; transition: all 0.12s ease;
}
.chat-sidebar .sidebar-viewall:hover { background: rgba(255, 255, 255, 0.045); color: rgba(255, 255, 255, 0.92); }
.chat-sidebar .sidebar-viewall i { color: rgba(255, 255, 255, 0.38); font-size: 12px; }

/* Footer */
.chat-sidebar .sidebar-foot { display: flex; align-items: center; gap: 11px; padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, 0.07); flex: none; }
.chat-sidebar .sidebar-foot-avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #667eea, #764ba2); }
.chat-sidebar .sidebar-foot-user { min-width: 0; flex: 1; }
.chat-sidebar .sidebar-foot-user b { display: block; font-size: 13px; font-weight: 600; color: rgba(255, 255, 255, 0.92); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sidebar .sidebar-foot-user small { font-size: 11px; color: rgba(255, 255, 255, 0.38); }
.chat-sidebar .sidebar-foot-dash {
    width: 32px; height: 32px; flex: none; border: none; border-radius: 8px; cursor: pointer;
    background: rgba(255, 255, 255, 0.05); color: rgba(255, 255, 255, 0.5); font-size: 13px;
    display: grid; place-items: center; transition: all 0.14s ease;
}
.chat-sidebar .sidebar-foot-dash:hover { background: rgba(0, 242, 254, 0.12); color: #00f2fe; }

/* ============================================================================
   COLLAPSE + HOVER-EXPAND — chat.css is the SINGLE SOURCE OF TRUTH.
   This overrides the duplicate sidebar-collapse system in workspace.css
   (~1455-1840), which loads earlier so we win at equal specificity. The
   New-chat button is pinned with its #id (specificity 1,1,x) to definitively
   beat workspace.css's `:hover .new-chat-btn { flex:1 }` rule that ballooned it.
   ============================================================================ */

/* --- Collapsed (72px): clean vertical icon rail --- */
body.sidebar-collapsed .sidebar-brand-name,
body.sidebar-collapsed .sidebar-search,
body.sidebar-collapsed .sidebar-sessions,
body.sidebar-collapsed .sidebar-foot-user,
body.sidebar-collapsed .new-chat-btn span {
    display: none;
}
body.sidebar-collapsed .sidebar-brand {
    flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 16px 0 12px;
}
body.sidebar-collapsed .chat-sidebar .sidebar-collapse-btn { margin: 0; }
body.sidebar-collapsed .chat-sidebar .sidebar-collapse-btn i { transform: rotate(180deg); }
/* New chat = fixed 40px square — #id beats workspace.css's :hover flex:1 */
body.sidebar-collapsed #new-chat-btn {
    width: 40px; height: 40px; min-height: 0; padding: 0; margin: 0 auto 12px; flex: none;
    justify-content: center;
}
body.sidebar-collapsed .sidebar-foot {
    flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px 0;
}

/* --- Hover-expand → restore the FULL, normal 280px sidebar (no balloon) --- */
body.sidebar-collapsed .chat-sidebar:hover {
    width: var(--chat-sidebar-width, 280px);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.5);
}
body.sidebar-collapsed .chat-sidebar:hover .sidebar-brand-name { display: block; }
body.sidebar-collapsed .chat-sidebar:hover .sidebar-search { display: block; }
body.sidebar-collapsed .chat-sidebar:hover .sidebar-sessions { display: flex; }
body.sidebar-collapsed .chat-sidebar:hover .sidebar-foot-user { display: block; }
body.sidebar-collapsed .chat-sidebar:hover .new-chat-btn span { display: inline; }
body.sidebar-collapsed .chat-sidebar:hover .sidebar-brand {
    flex-direction: row; align-items: center; justify-content: flex-start; gap: 11px; padding: 18px 16px 14px;
}
body.sidebar-collapsed .chat-sidebar:hover .sidebar-collapse-btn { margin-left: auto; }
/* New chat back to the normal full button (#id beats workspace.css :hover flex:1) */
body.sidebar-collapsed .chat-sidebar:hover #new-chat-btn {
    width: auto; height: auto; flex: none; padding: 11px 14px; margin: 0 12px 12px; justify-content: center;
}
body.sidebar-collapsed .chat-sidebar:hover .sidebar-foot {
    flex-direction: row; align-items: center; justify-content: flex-start; gap: 11px; padding: 12px 16px;
}
/* Keep the calm row look on hover (workspace.css tries to re-pad + show preview/icons) */
body.sidebar-collapsed .chat-sidebar:hover .chat-preview { display: none; }
body.sidebar-collapsed .chat-sidebar:hover .chat-item { padding: 9px 11px 9px 13px; justify-content: flex-start; }
body.sidebar-collapsed .chat-sidebar:hover .chat-item::before { display: none; content: none; }

/* ============================================================================
   AUTHORITATIVE — recent sidebar rows (single source of truth)
   ----------------------------------------------------------------------------
   The chat is ALWAYS in immersive-mode, so `body.immersive-mode .chat-item`
   (0,2,1) out-specified the `.chat-sidebar` redesign (0,2,0) → the recent items
   rendered as chunky glass cards with cyan/purple pills and a stray "?" before
   the date. Scope every selector as `body.immersive-mode .chat-sidebar …`
   (≥ 0,3,1) so it definitively beats that + the legacy `.chat-item`/pill rules
   (606-711, 1462-1582) + my earlier redesign. Clean, airy, ChatGPT/Claude rows.
   ============================================================================ */
body.immersive-mode .chat-sidebar .chat-item {
    display: block;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9px;
    margin: 0 0 8px;
    padding: 10px 12px 10px 14px;
    box-shadow: none;
    transform: none;
    overflow: hidden;
}
body.immersive-mode .chat-sidebar .chat-item::before { display: none; content: none; }
body.immersive-mode .chat-sidebar .chat-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: transparent;
    transform: none;
    box-shadow: none;
}
body.immersive-mode .chat-sidebar .chat-item:hover::before { display: none; content: none; }
body.immersive-mode .chat-sidebar .chat-item.active {
    background: rgba(0, 242, 254, 0.09);
    border-color: transparent;
    box-shadow: none;
}
/* thin left accent on the active row */
body.immersive-mode .chat-sidebar .chat-item.active::before {
    display: block; content: '';
    position: absolute; left: 0; top: 10px; bottom: 10px; width: 2.5px;
    background: #00f2fe; border-radius: 0 3px 3px 0; opacity: 1;
}
/* active title: solid white (drop the gradient-clip) */
body.immersive-mode .chat-sidebar .chat-item.active .chat-title {
    background: none; -webkit-text-fill-color: #fff; color: #fff;
}
/* footer = plain muted text — NO pills, NO "?" */
body.immersive-mode .chat-sidebar .chat-item-footer {
    display: flex; align-items: center; justify-content: flex-start; gap: 10px; margin-top: 4px;
}
body.immersive-mode .chat-sidebar .chat-time,
body.immersive-mode .chat-sidebar .chat-message-count {
    background: none; border: none; padding: 0; border-radius: 0; font-weight: 400;
    font-size: 11px; color: rgba(255, 255, 255, 0.42);
    display: inline-flex; align-items: center; gap: 4px;
}
body.immersive-mode .chat-sidebar .chat-time::before { content: none; display: none; }
body.immersive-mode .chat-sidebar .chat-time i,
body.immersive-mode .chat-sidebar .chat-message-count i { font-size: 10px; opacity: 0.8; }
body.immersive-mode .chat-sidebar .chat-preview { display: none; }
/* Hover: keep the meta line visible (was hidden → chunky empty box); the title
   just makes a little room for the delete action that fades in at the right. */
body.immersive-mode .chat-sidebar .chat-item:hover .chat-item-footer { opacity: 1; }
body.immersive-mode .chat-sidebar .chat-item:hover .chat-title { padding-right: 24px; }
body.immersive-mode .chat-sidebar .chat-actions { top: 9px; right: 9px; }
