/**
 * 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
   ============================================================================ */
/**
 * The `--chat-*` names below are now ALIASES onto the shared workspace palette in
 * `css/workspace/workspace-tokens.css`. Values are unchanged — chat is the premium
 * reference the other tools are being brought onto, so it does not move.
 *
 * Do NOT add new `--chat-*` colours here. Add `--ws-*` to workspace-tokens.css instead.
 */
:root {
    /* Deep Luxury Background Colors */
    --chat-bg-deepest: var(--ws-bg-deepest);
    --chat-bg-deep: var(--ws-bg-deep);
    --chat-bg-primary: var(--ws-bg-primary);
    --chat-bg-secondary: var(--ws-bg-secondary);
    --chat-bg-tertiary: var(--ws-bg-tertiary);
    --chat-bg-elevated: var(--ws-bg-elevated);

    /* Premium Accent Colors */
    --chat-accent-primary: var(--ws-accent);
    --chat-accent-secondary: var(--ws-accent-purple);
    --chat-accent-tertiary: var(--ws-accent-indigo);
    --chat-accent-pink: var(--ws-accent-pink);

    /* Text Hierarchy */
    --chat-text-primary: var(--ws-text);
    --chat-text-secondary: var(--ws-text-secondary);
    --chat-text-muted: var(--ws-text-muted);
    --chat-text-subtle: var(--ws-text-subtle);

    /* Premium Gradients */
    --chat-gradient-glow: var(--ws-gradient-glow);
    --chat-gradient-user: var(--ws-gradient-user);
    --chat-gradient-ai: var(--ws-gradient-surface);
    --chat-gradient-sidebar: var(--ws-gradient-rail);

    /* Glass Effects */
    --chat-glass-bg: var(--ws-glass-bg);
    --chat-glass-border: var(--ws-glass-border);
    --chat-glass-border-hover: var(--ws-glass-border-hover);

    /* Premium Shadows */
    --chat-shadow-sm: var(--ws-shadow-sm);
    --chat-shadow-md: var(--ws-shadow-md);
    --chat-shadow-lg: var(--ws-shadow-lg);
    --chat-shadow-glow-cyan: var(--ws-glow-cyan);
    --chat-shadow-glow-purple: var(--ws-glow-purple);

    /* Layout Dimensions */
    --chat-sidebar-width: var(--ws-rail-w);
    --chat-sidebar-collapsed: var(--ws-rail-collapsed);
    --chat-message-max-width: var(--ws-content-max);
    --chat-input-max-width: var(--ws-content-max);

    /* Transitions */
    --chat-transition-fast: var(--ws-t-fast);
    --chat-transition-base: var(--ws-t-base);
    --chat-transition-slow: var(--ws-t-slow);
}

/* -------------------------------------------------------------------------
   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 */
    /* The 74px band the floating-nav pill used to occupy is reclaimed: the pill
       is gone (its job — service switching, back-to-dashboard — is done by the
       shell's nav spine, the footer home button and Esc). This is +74px of
       vertical reading space on every deep view, for free. */
    padding-top: 0;
}

/* 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: 100%;   /* was calc(100% - 74px) for the floating-nav pill */
        overflow: hidden;
    }
}

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

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

@keyframes buttonBorderSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
body.sidebar-collapsed .nav-item span{
    display: none;
}

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

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

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

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

/* ============================================================================
   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, var(--ws-accent-indigo) 0%, var(--ws-accent-purple) 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;
}

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

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

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

.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: var(--ws-danger); }
.code-block-dots span:nth-child(2) { background: var(--ws-warning); }
.code-block-dots span:nth-child(3) { background: var(--ws-success); }

.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, var(--ws-accent));
    border-color: rgba(0, 242, 254, 0.3);
    background: rgba(0, 242, 254, 0.08);
}

.code-block .code-copy-btn.copied {
    color: var(--ws-success);
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.12);
}

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

/* Error state */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    text-align: center;
    color: var(--ws-danger);
}

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

/* ========================================
   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, var(--ws-text));
    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, var(--ws-accent));
    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, var(--ws-danger));
}

.error-state i {
    color: var(--color-error, var(--ws-danger));
}

/* 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, var(--ws-accent));
    animation: spin 1s ease-in-out infinite;
}

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

/* Hardware acceleration for all interactive elements */
button, 
.btn,
.nav-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{
    -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,
    .welcome-card-container,
    .conversation-starters-container,
    .session-delete-modal {
        animation: none;
    }

    .conversation-starter: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: var(--ws-text);
    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, var(--ws-bg-deep));
    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

   `.message-content pre` and `.message-content code` used to live here — a THIRD
   carrier for the same prose (after .message-text and .message-bubble), inherited
   from modern-sidebar.css. It was invisible on desktop because it happened to
   agree with the others, but it carried no media query, so on a phone it beat
   the mobile rule and chat's code blocks kept desktop padding while the two
   editors shrank. Prose is styled in exactly one place now: .pm-prose.
   ======================================== */

/* 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) {

    .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: var(--ws-danger);
    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: var(--ws-danger);
    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, var(--ws-danger), var(--ws-danger));
    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, var(--ws-accent), var(--ws-accent-purple));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sessions-header-icon i {
    font-size: 1.5rem;
    color: var(--ws-text);
}

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

.sessions-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
    color: var(--ws-text);
}

.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: var(--ws-bg-secondary);
    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: var(--ws-accent);
}

.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: var(--ws-accent-purple);
}

.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: var(--ws-success);
}

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

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

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ws-text);
    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: var(--ws-accent);
    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(20, 26, 53, 0.8) 0%, 
        var(--ws-bg-secondary) 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, var(--ws-accent), var(--ws-accent-purple));
    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: var(--ws-accent);
}

.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: var(--ws-text);
}

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

.session-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: linear-gradient(135deg,
        rgba(20, 26, 53, 0.98) 0%,
        rgba(26, 31, 58, 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: var(--ws-danger);
}

.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: var(--ws-text);
    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: var(--ws-accent);
    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: var(--ws-text);
}

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

/* ============================================
   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: var(--ws-accent);
    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(20, 26, 53, 0.98) 0%, 
        rgba(26, 31, 58, 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: var(--ws-danger);
}

.session-delete-modal h4 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ws-text);
    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, var(--ws-danger), var(--ws-danger));
    color: var(--ws-text);
    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, var(--ws-danger-text), var(--ws-danger));
}

.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: var(--ws-text);
    }

    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;
    /* THE ONE AMBIENT (premium-components.css) — identical to documents and the Hub. */
    background-color: var(--ws-bg-primary);
    background-image: var(--ws-ambient);
    background-attachment: fixed;
    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;
    }
}

/* Starfield REMOVED. `particleFloat` drifted a 5-layer dot field across the chat
   canvas forever. Documents and the Hub never had it — one more reason the three
   views felt like different products. The ambient is now shared, and still. */

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

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

/* ==========================================================================
   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, var(--ws-accent-purple), var(--ws-accent));
    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, var(--ws-accent-purple) 0%, var(--ws-accent-indigo) 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, var(--ws-accent), var(--ws-accent-purple));
    opacity: 0.55;
}

@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, var(--ws-accent-purple), var(--ws-accent));
    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, var(--ws-accent-indigo), var(--ws-accent-purple));
    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, var(--ws-accent), var(--ws-accent-blue));
    border: none;
    border-radius: 11px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    color: var(--ws-cta-ink);
    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, var(--ws-text) 0%, var(--ws-accent) 50%, var(--ws-accent-purple) 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 .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{
        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, 242, 254, 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, 242, 254, 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: var(--ws-text);
    -webkit-text-fill-color: var(--ws-text);
    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, var(--ws-accent-indigo) 0%, var(--ws-accent-purple) 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-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);
}

/* 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, var(--ws-accent-indigo), var(--ws-accent-purple));
    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: var(--ws-warning);
}

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

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

.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, var(--ws-accent), var(--ws-accent-blue));
    border: none;
    border-radius: 11px;
    color: var(--ws-cta-ink);
    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 var(--ws-accent-indigo);
    color: var(--ws-accent-indigo);
}

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

.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-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(20, 26, 53, 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, var(--ws-accent));
    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, var(--ws-accent-indigo) 0%, var(--ws-accent-purple) 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: var(--ws-accent);
}

.message-copy-btn.copied {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--ws-success);
    opacity: 1;
}

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

.code-copy-btn.copied {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--ws-success);
    opacity: 1;
}

@media (hover: none) and (pointer: coarse) {
}

/* ============================================================================
   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: var(--ws-accent);
}

.message-action-btn.copy-success {
    color: var(--ws-success);
}

.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: var(--ws-accent);
    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, var(--ws-accent) 0%, var(--ws-accent-blue) 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: var(--ws-accent);
    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(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--ws-success);
}

.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, var(--ws-accent) 0%, var(--ws-accent-blue) 50%, var(--ws-accent) 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, var(--ws-accent));
    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); }
}

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

.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, var(--ws-accent));
    box-shadow: 0 0 0 1px rgba(0, 242, 254, 0.25);
}

.orow--done .orow-ic {
    background: rgba(52, 211, 153, 0.14);
    color: var(--ws-success-text);
}
.orow--done .orow-state { color: var(--ws-success-text); }
.orow--skipped { opacity: 0.4; }
.orch-foot.is-on { display: flex; }

@media (prefers-reduced-motion: reduce) {
}

/* ============================================================================
   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, var(--ws-text));
    background: rgba(255, 255, 255, 0.06);
}
.msg-act.copied { color: var(--ws-success-text); }
.msg-act.act-on { color: var(--chat-accent-primary, var(--ws-accent)); }

/* 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: var(--ws-danger-text);
    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, var(--ws-accent));
    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; }
}
.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, var(--ws-accent)); 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, var(--ws-accent)); }
.chat-item--pinned .chat-pin-btn { color: var(--chat-accent-primary, var(--ws-accent)); }

/* ============================================================================
   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, var(--ws-accent)); 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, var(--ws-text)); 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, var(--ws-accent)); background: rgba(0, 242, 254, 0.1); }
#artifact-close:hover { color: var(--ws-danger-text); 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, var(--ws-accent)); 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: var(--ws-text);
    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, var(--ws-accent));
    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%; }
}

/* The Sources list at the foot of a researched answer — quieter than the answer.
   ----------------------------------------------------------------------------
   This used to be `.message-text h2 + ol, h2 + ul, ol:last-child { font-size:
   .85rem; color: grey }`. That is not a Sources selector; it is an ANY-LIST-
   AFTER-ANY-HEADING selector, so every ordinary list that happened to follow an
   h2 silently shrank and greyed — in chat only, and nowhere else in the product.

   chat.js `_markSourcesList()` now finds the real list (by its "Sources" /
   "References" heading) and tags it. Only that list is quieted. */
.message-text .msg-sources {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--ws-text-muted);
}

.message-text .msg-sources a { overflow-wrap: anywhere; }

/* 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: var(--ws-accent); font-size: 14px;
}
.sources-card__body { flex: 1; min-width: 0; }
.sources-card__title { font-size: 13.5px; font-weight: 600; color: var(--ws-text); }
.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: var(--ws-accent);
}
.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: var(--ws-accent); 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: var(--ws-text); 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, var(--ws-accent)); }
.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: var(--ws-accent); }
.artifact-source.is-internal { cursor: default; }
.ws-sidebar * { box-sizing: border-box; }

/* 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, var(--ws-accent-indigo), var(--ws-accent-purple));
    color: var(--ws-text);
    font-weight: 700;
    font-size: 1.15rem;
}
.settings-modal-id { min-width: 0; }
.settings-modal-name { font-size: 0.98rem; font-weight: 700; color: var(--ws-text); 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: var(--ws-accent);
}
.settings-modal-tier i { font-size: 0.7rem; color: var(--ws-accent); }

.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: var(--ws-accent);
    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: var(--ws-text); }
.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: var(--ws-danger-text);
    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); }
/* 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;
}
/* 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. */
.ws-sidebar .sidebar-sessions-list { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
.ws-sidebar .chat-pin-ic { color: var(--ws-accent); font-size: 10px; margin-right: 5px; }

/* View all history */
.ws-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;
}
.ws-sidebar .sidebar-viewall:hover { background: rgba(255, 255, 255, 0.045); color: rgba(255, 255, 255, 0.92); }
.ws-sidebar .sidebar-viewall i { color: rgba(255, 255, 255, 0.38); font-size: 12px; }
/* 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;
}
/* New chat back to the normal full button (#id beats workspace.css :hover flex:1) */
body.sidebar-collapsed .ws-sidebar:hover #new-chat-btn {
    width: auto; height: auto; flex: none; padding: 11px 14px; margin: 0 12px 12px; justify-content: center;
}
