        /* ===== THEME SYSTEM (Week 1, Day 4) ===== */

        /* Skip-to-content link — accessibility */
        .skip-link {
            position: absolute;
            top: -100%;
            left: 16px;
            z-index: 9999;
            padding: 8px 16px;
            background: var(--accent-primary, #3b82f6);
            color: #fff;
            border-radius: 4px;
            text-decoration: none;
            font-weight: 600;
            font-size: 14px;
        }

        .skip-link:focus {
            top: 16px;
        }

        /* Screen-reader only utility */
        .sr-only {
            position: absolute;
            width: 1px; height: 1px;
            padding: 0; margin: -1px;
            overflow: hidden;
            clip: rect(0,0,0,0);
            white-space: nowrap;
            border: 0;
        }

        /* Dark Theme (Default) - Zinc-950 with Teal accent */
        :root[data-theme="dark"],
        :root {
            --bg-primary: #000000;
            --bg-secondary: #050505;
            --bg-tertiary: #111111;
            --text-primary: #ffffff;
            --text-secondary: #e0e0e0;
            --text-tertiary: #a0a0a0;
            --accent-primary: #3b82f6;
            --accent-hover: #2563eb;
            --accent-rgb: 59, 130, 246;
            --overlay-rgb: 255, 255, 255;
            --success: #10b981;
            --success-rgb: 16, 185, 129;
            --warning: #f59e0b;
            --warning-rgb: 245, 158, 11;
            --error: #ef4444;
            --error-rgb: 239, 68, 68;
            --code-bg: #111111;
            --border-color: #333333;
            --shadow: rgba(0, 0, 0, 0.8);
        }

        /* Light Theme - Clean white with Blue accent */
        :root[data-theme="light"] {
            --bg-primary: #ffffff;
            --bg-secondary: #f8fafc;
            --bg-tertiary: #f1f5f9;
            --text-primary: #0f172a;
            --text-secondary: #475569;
            --text-tertiary: #94a3b8;
            --accent-primary: #0284c7;
            --accent-hover: #0369a1;
            --accent-rgb: 2, 132, 199;
            --overlay-rgb: 15, 23, 42;
            --success: #22c55e;
            --success-rgb: 34, 197, 94;
            --warning: #f59e0b;
            --warning-rgb: 245, 158, 11;
            --error: #ef4444;
            --error-rgb: 239, 68, 68;
            --code-bg: #f8fafc;
            --border-color: #e2e8f0;
            --shadow: rgba(15, 23, 42, 0.1);
            /* Light theme syntax highlighting (GitHub-style) */
            --hljs-base: #24292e;
            --hljs-comment: #6a737d;
            --hljs-keyword: #d73a49;
            --hljs-function: #6f42c1;
            --hljs-string: #032f62;
            --hljs-number: #005cc5;
            --hljs-variable: #e36209;
            --hljs-meta: #735c0f;
        }

        /* Nord Theme - Arctic blues with frost accent */
        :root[data-theme="nord"] {
            --bg-primary: #2e3440;
            --bg-secondary: #3b4252;
            --bg-tertiary: #434c5e;
            --text-primary: #eceff4;
            --text-secondary: #d8dee9;
            --text-tertiary: #4c566a;
            --accent-primary: #88c0d0;
            --accent-hover: #81a1c1;
            --accent-rgb: 136, 192, 208;
            --overlay-rgb: 236, 239, 244;
            --success: #a3be8c;
            --success-rgb: 163, 190, 140;
            --warning: #ebcb8b;
            --warning-rgb: 235, 203, 139;
            --error: #bf616a;
            --error-rgb: 191, 97, 106;
            --code-bg: #3b4252;
            --border-color: #4c566a;
            --shadow: rgba(46, 52, 64, 0.5);
        }

        /* Dracula Theme - High contrast with teal accent */
        :root[data-theme="dracula"] {
            --bg-primary: #282a36;
            --bg-secondary: #2f3241;
            --bg-tertiary: #3a3c4e;
            --text-primary: #f8f8f2;
            --text-secondary: #f1f1eb;
            --text-tertiary: #6272a4;
            --accent-primary: #06b6d4;
            --accent-hover: #22d3ee;
            --accent-rgb: 6, 182, 212;
            --overlay-rgb: 248, 248, 242;
            --success: #10b981;
            --success-rgb: 16, 185, 129;
            --warning: #f59e0b;
            --warning-rgb: 245, 158, 11;
            --error: #ef4444;
            --error-rgb: 239, 68, 68;
            --code-bg: #2f3241;
            --border-color: #44475a;
            --shadow: rgba(40, 42, 54, 0.6);
        }

        /* Tokyo Night Theme - Deep blue cyberpunk with sky blue accent */
        :root[data-theme="tokyo-night"] {
            --bg-primary: #1a1b26;
            --bg-secondary: #24283b;
            --bg-tertiary: #2f3549;
            --text-primary: #c0caf5;
            --text-secondary: #a9b1d6;
            --text-tertiary: #565f89;
            --accent-primary: #7aa2f7;
            --accent-hover: #89b4fa;
            --accent-rgb: 122, 162, 247;
            --overlay-rgb: 192, 202, 245;
            --success: #10b981;
            --success-rgb: 16, 185, 129;
            --warning: #f59e0b;
            --warning-rgb: 245, 158, 11;
            --error: #ef4444;
            --error-rgb: 239, 68, 68;
            --code-bg: #24283b;
            --border-color: #3b4261;
            --shadow: rgba(26, 27, 38, 0.6);
        }

        /* Catppuccin Mocha Theme - Warm cozy with blue accent */
        :root[data-theme="catppuccin"] {
            --bg-primary: #1e1e2e;
            --bg-secondary: #313244;
            --bg-tertiary: #45475a;
            --text-primary: #cdd6f4;
            --text-secondary: #bac2de;
            --text-tertiary: #6c7086;
            --accent-primary: #89b4fa;
            --accent-hover: #74c7ec;
            --accent-rgb: 137, 180, 250;
            --overlay-rgb: 205, 214, 244;
            --success: #10b981;
            --success-rgb: 16, 185, 129;
            --warning: #f59e0b;
            --warning-rgb: 245, 158, 11;
            --error: #ef4444;
            --error-rgb: 239, 68, 68;
            --code-bg: #313244;
            --border-color: #45475a;
            --shadow: rgba(30, 30, 46, 0.5);
        }

        /* Theme transition animation */
        body,
        .app-container,
        .sidebar,
        .main-content,
        .message,
        .code-block-wrapper,
        button,
        input,
        textarea,
        select {
            transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: var(--bg-primary);
            color: var(--text-primary);
            line-height: 1.6;
            /* 100dvh = dynamic viewport height — adjusts as mobile browser UI shows/hides.
               100vh fallback for browsers that don't support dvh yet. */
            height: 100vh;
            height: 100dvh;
            overflow: hidden;
        }

        /* ===== LAYOUT ===== */
        .app-container {
            display: flex;
            height: 100vh;
            height: 100dvh;
            width: 100%;
            margin: 0 auto;
        }

        /* ===== BRAND ICON — always fixed, never moves ===== */
        .brand-icon-fixed {
            position: fixed;
            top: 0;
            left: 0;
            width: 44px;
            height: 70px;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 100;
            cursor: pointer;
            flex-shrink: 0;
            transition: opacity 0.2s;
        }

        .brand-icon-fixed img {
            width: 36px;
            height: 36px;
            object-fit: contain;
            border-radius: 10px;
        }

        /* ===== FLOATING CONTROLS (action buttons only, shown when sidebar collapsed) ===== */
        .floating-controls {
            position: fixed;
            top: 0;
            left: 48px;
            /* Pulled slightly left so they hug the logo tighter */
            width: auto;
            height: 70px;
            display: flex;
            align-items: center;
            gap: 12px;
            z-index: 60;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.25s ease;
        }

        .floating-controls.visible {
            opacity: 1;
            pointer-events: auto;
        }

        .floating-btn {
            width: 28px;
            height: 28px;
            border: none;
            background: transparent;
            color: var(--text-secondary);
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.2s ease;
            flex-shrink: 0;
            padding: 0;
        }

        .floating-btn:hover {
            background: rgba(var(--overlay-rgb), 0.08);
            color: var(--text-primary);
        }

        /* ===== SIDEBAR ===== */
        .sidebar {
            width: 280px;
            background: var(--bg-primary);
            border-right: 1px solid rgba(var(--overlay-rgb), 0.06);
            display: flex;
            flex-direction: column;
            transition: width 0.25s ease, opacity 0.25s ease;
            flex-shrink: 0;
            position: relative;
            z-index: 30;
        }

        .sidebar.hidden {
            width: 0;
            overflow: hidden;
            opacity: 0;
            pointer-events: none;
        }

        /* Pre-init closed state to prevent open->close flicker on refresh/navigation */
        html.chat-sidebar-pref-closed .sidebar {
            width: 0;
            overflow: hidden;
            opacity: 0;
            pointer-events: none;
        }

        html.chat-sidebar-pref-closed .floating-controls {
            opacity: 1;
            pointer-events: auto;
        }

        html.chat-sidebar-pref-closed .chat-header {
            padding-left: 144px;
            /* 44 (logo) + 12 (gap) + 76 (btns) + 12 (gap) */
        }

        /* Sidebar Brand Header — left padding reserves space for the always-fixed brand icon */
        .sidebar-brand-header {
            height: 70px;
            padding: 0 12px 0 42px;
            /* Adjusted padding to increase gap slightly */
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .sidebar-brand-wordmark {
            height: 22px;
            width: auto;
            max-width: 156px;
            object-fit: contain;
            display: block;
            margin-top: 4px;
            margin-left: 0px;
        }

        .sidebar-collapse-btn {
            width: 32px;
            /* Increased from 28px */
            height: 32px;
            /* Increased from 28px */
            background: transparent;
            border: none;
            border-radius: 6px;
            color: var(--text-tertiary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.15s;
            flex-shrink: 0;
        }

        .sidebar-collapse-btn:hover {
            background: rgba(var(--overlay-rgb), 0.06);
            color: var(--text-primary);
        }

        /* New Chat Button — full width, pill shape like DeepSeek */
        .sidebar-actions {
            padding: 4px 12px 6px;
        }

        .sidebar-new-chat-btn {
            width: 100%;
            height: 38px;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            background: transparent;
            border: 1px solid rgba(var(--overlay-rgb), 0.12);
            border-radius: 20px;
            color: var(--text-primary);
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            font-family: inherit;
        }

        .sidebar-new-chat-btn:hover {
            background: rgba(var(--overlay-rgb), 0.04);
            border-color: rgba(var(--overlay-rgb), 0.2);
        }

        /* Sidebar Search */
        .sidebar-search-wrap {
            padding: 0 12px 12px;
        }

        .sidebar-search-field {
            height: 38px;
            border: 1px solid rgba(var(--overlay-rgb), 0.12);
            border-radius: 20px;
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 0 14px;
            background: transparent;
            transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
        }

        .sidebar-search-field:focus-within {
            border-color: rgba(124, 58, 237, 0.55);
            background: rgba(var(--overlay-rgb), 0.04);
            box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.18);
        }

        .sidebar-search-icon {
            width: 15px;
            height: 15px;
            color: var(--text-tertiary);
            flex-shrink: 0;
            opacity: 0.9;
        }

        .sidebar-search-input {
            flex: 1;
            min-width: 0;
            height: 100%;
            background: transparent;
            border: none;
            outline: none;
            color: var(--text-primary);
            font-size: 13px;
            font-family: inherit;
        }

        .sidebar-search-input::placeholder {
            color: var(--text-tertiary);
        }

        .sidebar-search-clear {
            width: 20px;
            height: 20px;
            border: none;
            border-radius: 999px;
            background: rgba(var(--overlay-rgb), 0.08);
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
            transform: scale(0.92);
            flex-shrink: 0;
        }

        .sidebar-search-clear.visible {
            opacity: 1;
            pointer-events: auto;
            transform: scale(1);
        }

        .sidebar-search-clear:hover {
            background: rgba(var(--overlay-rgb), 0.14);
            color: var(--text-primary);
        }

        .sidebar-search-meta {
            min-height: 16px;
            padding: 4px 6px 0;
            font-size: 11px;
            color: var(--text-tertiary);
            line-height: 1.4;
            display: none;
            /* Hidden by default until active search */
            align-items: center;
            gap: 6px;
        }

        .sidebar-search-loading-dot {
            width: 7px;
            height: 7px;
            border-radius: 999px;
            background: var(--accent-primary);
            display: inline-block;
            animation: sidebarSearchPulse 1.2s ease-in-out infinite;
            box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.3);
        }

        @keyframes sidebarSearchPulse {
            0% {
                transform: scale(0.85);
                opacity: 0.7;
            }

            50% {
                transform: scale(1);
                opacity: 1;
            }

            100% {
                transform: scale(0.85);
                opacity: 0.7;
            }
        }

        /* Chat History */
        .chat-history {
            flex: 1;
            overflow-y: auto;
            padding: 8px 8px;
        }

        /* Firefox scrollbar for chat history */
        .chat-history {
            scrollbar-width: thin;
            scrollbar-color: rgba(255,255,255,0.08) transparent;
        }

        /* Scrollbar for chat history */
        .chat-history::-webkit-scrollbar {
            width: 4px;
        }

        .chat-history::-webkit-scrollbar-track {
            background: transparent;
        }

        .chat-history::-webkit-scrollbar-thumb {
            background: rgba(var(--overlay-rgb), 0.08);
            border-radius: 4px;
        }

        .chat-history::-webkit-scrollbar-thumb:hover {
            background: rgba(var(--overlay-rgb), 0.15);
        }

        /* Group Headers */
        .history-group-title {
            font-size: 11px;
            text-transform: none;
            letter-spacing: 0;
            color: var(--text-tertiary);
            margin: 16px 8px 4px 8px;
            font-weight: 500;
            user-select: none;
        }

        .history-group-title:first-child {
            margin-top: 4px;
        }

        .chat-history-item {
            padding: 8px 12px;
            margin-bottom: 0;
            background: transparent;
            border-radius: 8px;
            cursor: pointer;
            font-size: 14px;
            color: var(--text-secondary);
            transition: all 0.12s;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border: none;
            line-height: 1.4;
        }

        .chat-history-item:hover {
            background: rgba(var(--overlay-rgb), 0.04);
            color: var(--text-primary);
        }

        .chat-history-item.active {
            background: rgba(var(--overlay-rgb), 0.06);
            color: var(--text-primary);
        }

        /* Sidebar Footer — user profile like DeepSeek */
        .sidebar-footer {
            padding: 12px 8px;
            background: transparent;
            border-top: none;
        }

        .sidebar-plan-badge {
            font-size: 11px;
            font-weight: 400;
            color: var(--text-tertiary);
            background: transparent;
            border: none;
            line-height: 1;
            padding: 0;
            white-space: nowrap;
        }

        .sidebar-upgrade-btn {
            display: none; /* shown via JS for free tier */
            align-items: center;
            font-size: 10px;
            font-weight: 500;
            letter-spacing: 0.3px;
            color: var(--accent-primary);
            background: rgba(var(--accent-rgb), 0.1);
            border: 1px solid rgba(var(--accent-rgb), 0.3);
            border-radius: 20px;
            padding: 2px 7px;
            cursor: pointer;
            white-space: nowrap;
            line-height: 1.4;
            transition: background 0.18s ease, border-color 0.18s ease;
        }

        .sidebar-upgrade-btn:hover {
            background: rgba(var(--accent-rgb), 0.18);
            border-color: rgba(var(--accent-rgb), 0.55);
        }

        .sidebar-user-profile {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 8px;
            border-radius: 8px;
            cursor: pointer;
            transition: background 0.15s ease;
            color: var(--text-primary);
            background: transparent;
            border: none;
        }

        .sidebar-user-profile:hover {
            background: rgba(var(--overlay-rgb), 0.05);
        }

        .sidebar-user-profile:focus-visible {
            outline: 2px solid rgba(var(--overlay-rgb), 0.2);
            outline-offset: -2px;
            border-radius: 8px;
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: #6a4a3a;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: 500;
            color: white;
            flex-shrink: 0;
            box-shadow: none;
            border: none;
            overflow: hidden;
        }

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

        .user-meta {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .user-name {
            font-size: 14px;
            font-weight: 400;
            letter-spacing: 0;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            line-height: 1.2;
            color: var(--text-secondary);
        }

        .user-plan-row {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .user-menu-btn {
            width: 26px;
            height: 26px;
            border: none;
            background: transparent;
            color: var(--text-tertiary);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: color 0.15s ease;
            font-size: 15px;
        }

        .user-menu-btn:hover {
            color: var(--text-primary);
        }

        .chat-title-text {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 180px;
        }

        .chat-item-menu {
            opacity: 0;
            color: var(--text-tertiary);
            padding: 4px;
            border-radius: 4px;
            transition: all 0.1s;
        }

        .chat-history-item:hover .chat-item-menu {
            opacity: 1;
        }

        .chat-item-menu:hover {
            background: rgba(var(--overlay-rgb), 0.1);
            color: var(--text-primary);
        }

        /* Context Menu */
        .chat-context-menu {
            position: fixed;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 4px;
            min-width: 200px;
            max-width: calc(100vw - 60px);
            box-shadow: 0 4px 12px var(--shadow);
            z-index: 1000;
            display: none;
            color: var(--text-primary);
            font-size: 13px;
        }

        .context-menu-item {
            padding: 8px 12px;
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            border-radius: 4px;
            color: var(--text-secondary);
            transition: background 0.1s;
        }

        .context-menu-item:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .context-menu-item.danger {
            color: var(--error);
        }

        .context-menu-item.danger:hover {
            background: rgba(248, 113, 113, 0.1);
        }

        .context-divider {
            height: 1px;
            background: var(--border-color);
            margin: 4px 0;
        }

        .context-menu-item.upgrade {
            color: var(--accent-primary);
            font-weight: 500;
        }

        .context-menu-item.upgrade:hover {
            background: rgba(var(--accent-rgb), 0.08);
            color: var(--accent-primary);
        }

        .context-menu-item.locked {
            opacity: 0.45;
            cursor: default !important;
        }

        .context-menu-item.locked:hover {
            background: transparent;
        }

        .cmenu-icon {
            display: flex;
            align-items: center;
            flex-shrink: 0;
            opacity: 0.7;
        }

        .cmenu-text {
            display: flex;
            flex-direction: column;
            gap: 1px;
        }

        .cmenu-sublabel {
            font-size: 11px;
            color: var(--text-tertiary);
            opacity: 0.7;
        }


        /* ===== MAIN CHAT AREA ===== */
        .main-content {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: var(--bg-primary);
            /* Changed from secondary to primary so the whole screen shares the black background */
            margin: 0;
            border-radius: 0;
            border: none;
            z-index: 5;
            overflow: hidden;
            position: relative;
            transition: margin-left 0.3s ease;
        }

        /* ===== HEADER WITH MODEL SELECTOR ===== */
        .chat-header {
            padding: 16px 24px;
            background: transparent;
            display: flex;
            justify-content: flex-end;
            align-items: center;
            height: 70px;
            transition: padding-left 0.25s ease;
            gap: 16px;
            min-width: 0;
            position: relative;
        }

        /* When sidebar is collapsed, shift header right to avoid floating buttons */
        .main-content.sidebar-collapsed .chat-header {
            padding-left: 148px;
        }

        .chat-header-main {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            text-align: center;
            width: auto;
            max-width: 40%;
            pointer-events: none;
            /* Let clicks pass through if needed, though title might be for tooltip */
        }

        .chat-header-title {
            font-size: 16px;
            font-weight: 600;
            color: var(--text-primary);
            line-height: 1.25;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            letter-spacing: -0.01em;
            pointer-events: auto;
        }

        /* Custom Model Selector */
        .custom-model-selector {
            position: relative;
            z-index: 100;
            display: flex;
            align-items: center;
            flex-shrink: 0;
        }

        .model-trigger {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            color: rgba(var(--overlay-rgb), 0.75);
            font-size: 13.5px;
            font-weight: 500;
            cursor: pointer;
            border-radius: 20px;
            transition: all 0.2s;
            user-select: none;
        }

        .model-trigger:hover {
            background: rgba(var(--overlay-rgb), 0.1);
            color: var(--text-primary);
        }

        .model-trigger svg.smt-icon {
            opacity: 0.8;
        }

        .model-trigger svg.model-chevron {
            opacity: 0.6;
            transition: transform 0.2s;
        }

        .custom-model-selector.active .model-chevron {
            transform: rotate(180deg);
        }

        .model-menu {
            position: absolute;
            bottom: calc(100% + 14px);
            right: 0;
            margin: 0;
            background: var(--bg-secondary);
            backdrop-filter: blur(16px) saturate(180%);
            -webkit-backdrop-filter: blur(16px) saturate(180%);
            border: 1px solid rgba(var(--overlay-rgb), 0.08);
            border-radius: 14px;
            box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(var(--overlay-rgb), 0.03);
            width: 250px;
            max-height: 420px;
            overflow-y: auto;
            display: none;
            padding: 6px;
            z-index: 1001;
            transform-origin: bottom right;
            scrollbar-width: thin;
            scrollbar-color: rgba(var(--overlay-rgb), 0.1) transparent;
        }

        .custom-model-selector.active .model-menu {
            display: block;
            animation: menuAppearUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        }

        @keyframes menuAppearUp {
            from {
                opacity: 0;
                transform: translateY(8px) scale(0.98);
            }

            to {
                opacity: 1;
                transform: translateY(0) scale(1);
            }
        }

        .model-option {
            padding: 10px 12px;
            cursor: pointer;
            border-radius: 10px;
            transition: all 0.15s;
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: transparent;
            margin-bottom: 2px;
        }

        .model-option:hover {
            background: rgba(var(--overlay-rgb), 0.06);
        }

        .model-option.selected {
            background: transparent;
        }

        .model-option.selected:hover {
            background: rgba(var(--overlay-rgb), 0.08);
            /* slight highlight on hover when selected */
        }

        .mo-info {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .mo-info svg {
            width: 16px;
            height: 16px;
            stroke-width: 2;
            color: rgba(var(--overlay-rgb), 0.8);
        }

        .mo-info svg.mo-openai-icon {
            color: #10a37f;
            opacity: 1;
            width: 15px;
            height: 15px;
        }

        .model-trigger svg.smt-icon.mo-openai-icon {
            color: #10a37f;
            opacity: 1;
            width: 15px;
            height: 15px;
        }

        .mo-text {
            display: flex;
            flex-direction: column;
            gap: 2px;
        }

        .mo-title {
            font-size: 13.5px;
            font-weight: 500;
            color: rgba(var(--overlay-rgb), 0.95);
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .mo-lock-icon {
            width: 14px;
            height: 14px;
            color: #c084fc;
            /* Vibrant purple matching Arivaan UI */
            flex-shrink: 0;
            opacity: 0.9;
        }

        .model-option.selected .mo-title {
            color: var(--text-primary);
            font-weight: 600;
        }

        .mo-desc {
            font-size: 11px;
            color: rgba(var(--overlay-rgb), 0.45);
        }

        .model-option.selected .mo-desc {
            color: rgba(var(--overlay-rgb), 0.55);
        }

        .mo-check {
            width: 16px;
            height: 16px;
            opacity: 0;
            color: var(--text-primary);
            transition: opacity 0.2s;
        }

        .model-option.selected .mo-check {
            opacity: 1;
        }

        .model-menu-upgrade {
            margin-top: 4px;
            padding: 11px 12px;
            font-size: 12px;
            font-weight: 600;
            color: var(--success);
            background: rgba(var(--success-rgb), 0.05);
            text-align: center;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.2s;
            border: 1px solid rgba(var(--success-rgb), 0.1);
        }

        .model-menu-upgrade:hover {
            background: rgba(var(--success-rgb), 0.15);
        }

        .model-menu-separator {
            padding: 8px 14px 4px 14px;
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            color: rgba(var(--overlay-rgb), 0.35);
            font-weight: 700;
            margin-top: 4px;
            border-top: 1px solid rgba(var(--overlay-rgb), 0.06);
        }

        .model-option.locked {
            cursor: pointer;
        }

        .model-option.locked .mo-title {
            color: rgba(var(--overlay-rgb), 0.4);
        }

        .model-option.locked .mo-lock-icon {
            color: rgba(192, 132, 252, 0.5);
            /* Dimmed purple */
        }

        .model-option.locked .mo-desc {
            color: rgba(var(--overlay-rgb), 0.2);
        }

        .model-group-label {
            padding: 12px 14px 6px 14px;
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.12em;
            color: rgba(var(--overlay-rgb), 0.35);
            font-weight: 700;
            margin-top: 4px;
        }

        .model-group-label:first-child {
            margin-top: 0;
        }

        .header-actions {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .header-actions>.credits-wrapper {
            position: relative;
            display: flex;
            align-items: center;
        }

        /* Tier Badge */
        .tier-badge {
            padding: 6px 12px;
            background: rgba(33, 150, 243, 0.1);
            border: 1px solid var(--tier-color, rgba(33, 150, 243, 0.3));
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
            color: var(--tier-color, #2196F3);
            display: flex;
            align-items: center;
            gap: 4px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .tier-badge:hover {
            transform: scale(1.05);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }

        /* Credits Display */
        .credits-display {
            background: transparent;
            border: none;
            font-size: 14px;
            font-weight: 700;
            color: var(--text-primary);
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
            transition: all 0.15s ease;
            letter-spacing: -0.01em;
            line-height: 1;
        }

        .credits-display:hover {
            opacity: 0.7;
            transform: translateY(-0.5px);
        }

        .credits-icon {
            display: flex;
            align-items: center;
            color: #d1b3ff;
            opacity: 1;
            filter: drop-shadow(0 0 6px rgba(179, 136, 255, 0.4));
        }

        .credits-icon svg {
            width: 15px;
            height: 15px;
        }

        .credits-wrapper {
            position: relative;
            display: inline-flex;
        }

        .cost-display {
            background: transparent;
            border: none;
            font-size: 14px;
            font-weight: 700;
            color: rgba(var(--overlay-rgb), 0.9);
            display: flex;
            align-items: center;
            gap: 8px;
            white-space: nowrap;
            letter-spacing: -0.01em;
            line-height: 1;
            position: relative;
            cursor: default;
            padding-left: 16px;
            border-left: 1px solid rgba(var(--overlay-rgb), 0.1);
        }

        .cost-display .cost-icon {
            display: flex;
            align-items: center;
            color: var(--success);
            opacity: 0.8;
        }

        /* Hide session cost on new/empty chat — it's always 0.000 and meaningless */
        .main-content.chat-empty .cost-display {
            display: none;
        }

        .cost-display .cost-icon svg {
            width: 15px;
            height: 15px;
        }

        /* Session stats hover popout */
        .session-stats-popout {
            display: none;
            position: absolute;
            top: calc(100% + 10px);
            right: 0;
            min-width: 200px;
            background: var(--bg-primary);
            border: 1px solid rgba(var(--success-rgb), 0.16);
            border-radius: 12px;
            padding: 12px 14px;
            box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(var(--overlay-rgb), 0.04);
            z-index: 1200;
            pointer-events: none;
        }

        .cost-display:hover .session-stats-popout {
            display: block;
        }

        .session-stats-popout::before {
            content: '';
            position: absolute;
            top: -5px;
            right: 14px;
            width: 9px;
            height: 9px;
            background: var(--bg-primary);
            border-left: 1px solid rgba(var(--success-rgb), 0.16);
            border-top: 1px solid rgba(var(--success-rgb), 0.16);
            transform: rotate(45deg);
        }

        .session-stats-popout .ssp-title {
            font-size: 10px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.09em;
            color: rgba(var(--success-rgb), 0.6);
            margin-bottom: 10px;
        }

        .session-stats-popout .ssp-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 5px 0;
            border-bottom: 1px solid rgba(var(--overlay-rgb), 0.055);
        }

        .session-stats-popout .ssp-row:last-child {
            border-bottom: none;
            padding-bottom: 0;
        }

        .session-stats-popout .ssp-label {
            font-size: 11.5px;
            color: rgba(var(--overlay-rgb), 0.45);
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .session-stats-popout .ssp-val {
            font-size: 12px;
            font-weight: 600;
            color: rgba(var(--overlay-rgb), 0.82);
        }

        .session-stats-popout .ssp-val.teal {
            color: var(--success);
        }

        /* .theme-toggle-btn removed — unused (floating-theme-switch-btn is used instead) */

        /* ===== THEME SELECTOR MODAL (Week 1, Day 4) ===== */
        .theme-modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(4px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10000;
            animation: fadeIn 0.3s ease;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
            }

            to {
                opacity: 1;
            }
        }

        .theme-modal {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 16px;
            padding: 32px;
            max-width: 900px;
            width: 90%;
            max-height: 80vh;
            overflow-y: auto;
            box-shadow: 0 20px 60px var(--shadow);
            animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }

        @keyframes slideUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .theme-modal-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 24px;
        }

        .theme-modal-title {
            font-size: 24px;
            font-weight: 700;
            color: var(--text-primary);
        }

        .theme-modal-close {
            width: 36px;
            height: 36px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            font-size: 20px;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .theme-modal-close:hover {
            background: var(--error);
            border-color: var(--error);
            color: white;
        }

        .theme-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
        }

        .theme-card {
            background: var(--bg-tertiary);
            border: 2px solid var(--border-color);
            border-radius: 12px;
            padding: 20px;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }

        .theme-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 8px 24px var(--shadow);
            border-color: var(--accent-primary);
        }

        .theme-card.active {
            border-color: var(--accent-primary);
            background: rgba(139, 92, 246, 0.1);
        }

        .theme-card-name {
            font-size: 18px;
            font-weight: 600;
            margin-bottom: 8px;
            color: var(--text-primary);
        }

        .theme-card-description {
            font-size: 13px;
            color: var(--text-secondary);
            margin-bottom: 16px;
        }

        .theme-preview {
            display: flex;
            gap: 8px;
            height: 60px;
            border-radius: 8px;
            overflow: hidden;
            border: 1px solid var(--border-color);
        }

        .theme-preview-color {
            flex: 1;
            transition: transform 0.2s;
        }

        .theme-card:hover .theme-preview-color {
            transform: scale(1.1);
        }

        .theme-keyboard-hint {
            margin-top: 20px;
            padding: 16px;
            background: var(--bg-tertiary);
            border-radius: 8px;
            text-align: center;
            font-size: 13px;
            color: var(--text-secondary);
        }

        .theme-keyboard-hint kbd {
            padding: 4px 8px;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: 4px;
            font-family: monospace;
            font-size: 12px;
            color: var(--accent-primary);
        }

        /* ===== THEME TOAST NOTIFICATION (Week 1, Day 4) ===== */
        .theme-toast {
            position: fixed;
            bottom: 84px;
            right: 24px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 16px 24px;
            box-shadow: 0 8px 24px var(--shadow);
            display: flex;
            align-items: center;
            gap: 12px;
            z-index: 10001;
            animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        }

        @keyframes slideInRight {
            from {
                opacity: 0;
                transform: translateX(100px);
            }

            to {
                opacity: 1;
                transform: translateX(0);
            }
        }

        .theme-toast-icon {
            font-size: 24px;
        }

        .theme-toast-text {
            font-size: 14px;
            font-weight: 600;
            color: var(--text-primary);
        }

        /* ===== APP TOAST NOTIFICATIONS ===== */
        .app-toast-container {
            position: fixed;
            bottom: 90px;
            right: 20px;
            display: flex;
            flex-direction: column-reverse;
            gap: 8px;
            z-index: 10003;
            pointer-events: none;
        }

        .app-toast {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 10px;
            padding: 11px 15px;
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 220px;
            max-width: 320px;
            box-shadow: 0 6px 24px var(--shadow);
            pointer-events: auto;
            animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
            font-size: 13px;
            color: var(--text-primary);
            transition: opacity 0.3s;
        }

        .app-toast.error   { border-left: 3px solid var(--error); }
        .app-toast.success { border-left: 3px solid var(--success); }
        .app-toast.info    { border-left: 3px solid var(--accent-primary); }

        .app-toast-icon { flex-shrink: 0; font-size: 15px; font-weight: 700; }
        .app-toast-msg  { flex: 1; line-height: 1.4; }

        @media (max-width: 480px) {
            .app-toast-container { bottom: 72px; right: 10px; left: 10px; }
            .app-toast { max-width: 100%; }
        }

        /* ===== APP MODALS (confirm / prompt) ===== */
        .app-modal-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.65);
            backdrop-filter: blur(3px);
            -webkit-backdrop-filter: blur(3px);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 10010;
            animation: fadeIn 0.2s ease;
        }

        .app-modal {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 14px;
            padding: 24px 24px 20px;
            width: min(380px, 92vw);
            box-shadow: 0 16px 48px var(--shadow);
            animation: slideUp 0.25s cubic-bezier(0.16,1,0.3,1);
        }

        .app-modal-title {
            font-size: 15px;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 16px;
            display: block;
        }

        .app-modal-input {
            width: 100%;
            padding: 9px 12px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            color: var(--text-primary);
            font-size: 14px;
            margin-bottom: 16px;
            outline: none;
            box-sizing: border-box;
        }

        .app-modal-input:focus { border-color: var(--accent-primary); }

        .app-modal-actions {
            display: flex;
            justify-content: flex-end;
            gap: 8px;
        }

        .app-modal-btn {
            padding: 8px 18px;
            border-radius: 8px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            border: 1px solid var(--border-color);
            transition: all 0.15s;
        }

        .app-modal-btn.secondary { background: var(--bg-tertiary); color: var(--text-secondary); }
        .app-modal-btn.secondary:hover { background: rgba(var(--overlay-rgb),0.08); }
        .app-modal-btn.primary { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }
        .app-modal-btn.primary:hover { background: var(--accent-hover); }
        .app-modal-btn.danger { background: var(--error); color: #fff; border-color: var(--error); }
        .app-modal-btn.danger:hover { opacity: 0.85; }

        /* ===== MESSAGES AREA ===== */
        .messages-container {
            flex: 1;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 40px 0 calc(var(--input-safe-offset, 188px) + env(safe-area-inset-bottom, 0px)) 0;
            display: flex;
            flex-direction: column;
            scroll-behavior: auto;
            background: var(--bg-primary);
            overflow-anchor: auto;
            /* Keeps scroll position stable during DOM updates */
        }

        /* Utility to force instant scroll during rapid streaming */
        .messages-container.no-smooth {
            scroll-behavior: auto !important;
        }

        @media (max-width: 768px) {
            .messages-container {
                padding: 16px 16px calc(var(--input-safe-offset, 188px) + env(safe-area-inset-bottom, 0px)) 16px;
            }
        }

        /* Firefox scrollbar for messages */
        .messages-container {
            scrollbar-width: thin;
            scrollbar-color: rgba(255,255,255,0.12) transparent;
        }

        /* Scrollbar styling for messages */
        .messages-container::-webkit-scrollbar {
            width: 8px;
        }

        .messages-container::-webkit-scrollbar-track {
            background: transparent;
        }

        .messages-container::-webkit-scrollbar-thumb {
            background: var(--text-tertiary);
            border-radius: 4px;
        }

        .messages-container::-webkit-scrollbar-thumb:hover {
            background: var(--text-secondary);
        }

        .message-index-panel {
            position: absolute;
            top: 50%;
            right: 10px;
            transform: translateY(-50%);
            width: 320px;
            max-width: min(36vw, 320px);
            overflow: visible;
            background: transparent;
            border: none;
            border-radius: 0;
            padding: 0 8px 0 0;
            box-shadow: none;
            backdrop-filter: none;
            z-index: 18;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease;
        }

        .main-content.show-message-index .message-index-panel {
            opacity: 1;
        }

        .message-index-scroll {
            max-height: min(70vh, 520px);
            overflow-y: auto;
            overflow-x: visible;
            scrollbar-width: none;
            pointer-events: none;
        }

        .message-index-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
            align-items: flex-end;
            padding: 2px 0;
            pointer-events: auto;
        }

        .message-index-item {
            position: relative;
            width: 36px;
            height: 22px;
            border: none;
            background: transparent;
            color: rgba(235, 239, 249, 0.72);
            border-radius: 8px;
            padding: 0;
            font-size: 14px;
            line-height: 1;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 0;
            text-align: left;
            transition: color 0.16s ease;
            pointer-events: auto;
        }

        .message-index-item:hover {
            color: var(--text-primary);
        }

        .message-index-item.active {
            color: var(--accent-primary);
        }

        .message-index-label {
            position: absolute;
            right: calc(100% + 10px);
            top: 50%;
            transform: translateY(-50%) translateX(6px);
            min-width: 120px;
            max-width: 260px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            background: rgba(34, 37, 45, 0.95);
            border: 1px solid rgba(var(--overlay-rgb), 0.1);
            border-radius: 10px;
            padding: 8px 10px;
            box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.14s ease, transform 0.14s ease;
            z-index: 32;
        }

        .message-index-marker {
            flex-shrink: 0;
            width: 12px;
            height: 3px;
            border-radius: 999px;
            background: rgba(var(--overlay-rgb), 0.34);
            color: transparent;
            font-size: 0;
            line-height: 0;
            transform: none;
            transition: width 0.16s ease, background 0.16s ease;
        }

        .message-index-item.active .message-index-marker {
            width: 18px;
            background: var(--accent-primary);
        }

        .message-index-item:hover .message-index-marker {
            background: var(--accent-hover);
        }

        .message-index-item:hover .message-index-label,
        .message-index-item:focus-visible .message-index-label {
            opacity: 1;
            transform: translateY(-50%) translateX(0);
        }

        .message-index-scroll::-webkit-scrollbar {
            width: 0;
            height: 0;
        }

        @media (max-width: 1200px) {
            .message-index-panel {
                right: 6px;
                width: auto;
            }
        }

        .message {
            display: flex;
            gap: 16px;
            margin-bottom: 14px;
            width: 100%;
            padding: 0;
            box-sizing: border-box;
            justify-content: flex-start;
        }

        /* Message wrapper to constrain width for cleaner reading */
        .message-inner {
            display: flex;
            flex-direction: column;
            width: 100%;
            max-width: 800px;
            margin: 0 auto;
            padding: 0 20px;
            position: relative;
        }

        /* AI messages */
        .message.assistant .message-inner {
            flex-direction: row;
        }

        /* User messages */

        .message-content {
            flex: 1;
            /* Take remaining space */
            max-width: 100%;
            /* controlled by container */
            min-width: 0;
            /* Allow shrinking for text overflow */
            background: transparent;
            padding: 0;
            border-radius: 0;
            font-size: 16px;
            line-height: 1.6;
            color: var(--text-primary);
            position: relative;
        }

        /* User bubbles - Distinct specific style */
        .message.user .message-content {
            background: transparent;
            padding: 0;
            width: 100%;
            display: flex;
            flex-direction: column;
            align-items: flex-end;
        }

        .message.user .message-text {
            background: var(--bg-tertiary);
            border: 1px solid rgba(var(--overlay-rgb), 0.05);
            padding: 10px 18px;
            border-radius: 20px;
            color: var(--text-primary);
            text-align: left;
            max-width: 85%;
            font-size: 15px;
            line-height: 1.5;
        }

        /* Assistant bubbles - clean text style */
        .message.assistant .message-content {
            background: transparent;
            padding-top: 0;
        }

        .message-header {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 8px;
        }

        /* Align header content based on message type */
        .message.user .message-header {
            justify-content: flex-end;
        }

        .message.assistant .message-header {
            justify-content: flex-start;
        }

        .message-role {
            font-weight: 600;
            font-size: 14px;
            color: var(--text-primary);
        }

        .message-model {
            padding: 2px 8px;
            background: var(--bg-tertiary);
            border-radius: 4px;
            font-size: 11px;
            color: var(--text-tertiary);
        }

        .message.user .message-model {
            background: rgba(var(--overlay-rgb), 0.1);
            color: var(--text-secondary);
        }

        .message-text {
            color: var(--text-secondary);
            font-size: 15px;
            line-height: 1.6;
            overflow-wrap: break-word;
            word-wrap: break-word;
            word-break: break-word;
            max-width: 100%;
            text-align: left;
        }

        /* Markdown elements within message text */
        .message-text h1,
        .message-text h2,
        .message-text h3,
        .message-text h4,
        .message-text h5,
        .message-text h6 {
            color: var(--text-primary);
            font-weight: 600;
            margin-top: 16px;
            margin-bottom: 8px;
            line-height: 1.3;
        }

        .message-text h1 {
            font-size: 24px;
        }

        .message-text h2 {
            font-size: 20px;
        }

        .message-text h3 {
            font-size: 18px;
        }

        .message-text h4 {
            font-size: 16px;
        }

        .message-text p {
            color: var(--text-secondary);
            margin-bottom: 12px;
        }

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

        .message-text ul,
        .message-text ol {
            color: var(--text-secondary);
            margin-left: 20px;
            margin-bottom: 12px;
        }

        .message-text li {
            color: var(--text-secondary);
            margin-bottom: 4px;
        }

        .message-text strong {
            color: var(--text-primary);
            font-weight: 600;
        }

        .message-text em {
            color: var(--text-secondary);
        }

        .message-text a {
            color: var(--accent-primary);
            text-decoration: underline;
        }

        .message-text blockquote {
            border-left: 3px solid var(--accent-primary);
            padding-left: 12px;
            margin: 12px 0;
            color: var(--text-secondary);
            font-style: italic;
        }

        /* ===== PROFESSIONAL TABLE STYLING ===== */
        .table-wrapper {
            position: relative;
            margin: 24px 0;
            border-radius: 12px;
            border: 1px solid rgba(var(--overlay-rgb), 0.08);
            background: var(--code-bg);
            overflow: hidden;
            width: 100%;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        }

        .table-toolbar {
            position: absolute;
            top: 10px;
            right: 10px;
            display: flex;
            align-items: center;
            gap: 6px;
            z-index: 10;
            opacity: 0;
            transition: opacity 0.2s ease, transform 0.2s ease;
            transform: translateY(-4px);
            pointer-events: none;
        }

        .table-wrapper:hover .table-toolbar {
            opacity: 1;
            transform: translateY(0);
            pointer-events: auto;
        }

        .table-action-btn {
            background: rgba(20, 20, 20, 0.85);
            backdrop-filter: blur(8px);
            border: 1px solid rgba(var(--overlay-rgb), 0.12);
            color: var(--text-secondary);
            width: 30px;
            height: 30px;
            border-radius: 8px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        }

        .table-action-btn:hover {
            background: rgba(var(--overlay-rgb), 0.08);
            color: var(--text-primary);
            border-color: rgba(var(--overlay-rgb), 0.2);
        }

        .table-action-btn.copied {
            color: var(--success);
            border-color: var(--success);
            background: rgba(var(--success-rgb), 0.1);
        }

        .table-action-btn svg {
            width: 14px;
            height: 14px;
        }

        .message-text table {
            border-collapse: collapse;
            width: 100%;
            margin: 0;
            color: var(--text-primary);
            font-size: 14px;
            border: none;
        }

        .message-text table th,
        .message-text table td {
            border-bottom: 1px solid rgba(var(--overlay-rgb), 0.05);
            border-right: 1px solid rgba(var(--overlay-rgb), 0.05);
            padding: 12px 16px;
            text-align: left;
        }

        .message-text table th:last-child,
        .message-text table td:last-child {
            border-right: none;
        }

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

        .message-text table th {
            background: rgba(var(--overlay-rgb), 0.05);
            font-weight: 600;
            color: var(--text-primary);
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 0.03em;
        }

        .message-text table tr:hover td {
            background: rgba(var(--overlay-rgb), 0.02);
        }

        .message-text hr {
            border: none;
            border-top: 1px solid var(--border-color);
            margin: 16px 0;
        }

        /* User message text uses theme colors with accent for links */
        .message.user .message-text h1,
        .message.user .message-text h2,
        .message.user .message-text h3,
        .message.user .message-text h4,
        .message.user .message-text h5,
        .message.user .message-text h6,
        .message.user .message-text p,
        .message.user .message-text ul,
        .message.user .message-text ol,
        .message.user .message-text li,
        .message.user .message-text strong,
        .message.user .message-text em {
            color: var(--text-primary);
        }

        .message.user .message-text a {
            color: var(--accent-primary);
        }

        /* ===== CODE BLOCKS (Refined) ===== */
        .code-block-wrapper {
            position: relative;
            margin: 24px 0;
            border-radius: 12px;
            background: var(--code-bg);
            /* Adjusted to match sleek dark code body */
            border: 1px solid rgba(var(--overlay-rgb), 0.08);
            /* Sleeker, softer border */
            overflow: hidden;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
            max-width: 100%;
            width: 100%;
            z-index: 0;
            isolation: isolate;
        }

        .code-toolbar {
            position: relative;
            z-index: 2;
            height: 44px;
            background: var(--bg-tertiary);
            /* Match the distinct header grey from reference */
            border-bottom: 1px solid rgba(var(--overlay-rgb), 0.04);
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 0 16px;
            border-top-left-radius: 12px;
            border-top-right-radius: 12px;
        }

        .code-language-badge {
            position: static;
            font-family: 'Inter', -apple-system, sans-serif;
            font-size: 13px;
            font-weight: 600;
            color: var(--text-secondary);
            text-transform: lowercase;
            /* match "rust" from design */
            letter-spacing: 0.3px;
            pointer-events: none;
        }

        .code-toolbar-actions {
            display: inline-flex;
            align-items: center;
            gap: 16px;
            /* Space out evenly like the reference */
        }

        .code-action-btn {
            height: 24px;
            padding: 0;
            background: transparent;
            border: none;
            border-radius: 0;
            color: var(--text-tertiary);
            /* Muted text color for buttons */
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            transition: color 0.15s ease, opacity 0.15s ease;
            font-size: 13px;
            font-weight: 500;
            font-family: 'Inter', -apple-system, sans-serif;
            white-space: nowrap;
        }

        .code-action-btn:hover:not(:disabled) {
            color: var(--text-primary);
            opacity: 1;
        }

        .code-action-btn:active:not(:disabled) {
            transform: scale(0.95);
        }

        .code-action-btn:disabled {
            opacity: 0.45;
            cursor: not-allowed;
        }

        .code-copy-btn.copied {
            color: var(--success);
            opacity: 1;
        }

        .code-action-btn svg {
            width: 14px;
            height: 14px;
        }

        .code-action-separator {
            color: rgba(var(--overlay-rgb), 0.38);
            font-size: 16px;
            line-height: 1;
            user-select: none;
            margin: 0 2px;
        }

        .code-action-btn[hidden],
        .code-action-separator[hidden] {
            display: none !important;
        }

        .code-block-wrapper pre {
            margin: 0;
            padding: 14px 16px 16px;
            overflow-x: auto;
            overflow-y: hidden;
            max-height: none;
            max-width: 100%;
            /* Force scroll */
            background: transparent;
            font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
            font-size: 13.5px;
            line-height: 1.6;
            color: var(--text-secondary);
            border-bottom-left-radius: 12px;
            border-bottom-right-radius: 12px;
            scrollbar-gutter: stable;
        }

        .code-block-wrapper pre.code-scrollable {
            overflow-y: auto;
        }

        .code-block-wrapper code.hljs {
            background: transparent !important;
            padding: 0;
        }

        .code-block-wrapper code {
            font-family: inherit;
        }

        .code-block-wrapper .hljs {
            color: var(--hljs-base, #d4d4d4) !important;
            background: transparent !important;
        }

        .code-block-wrapper .hljs-comment,
        .code-block-wrapper .hljs-quote {
            color: var(--hljs-comment, #6a737d) !important;
            font-style: italic;
        }

        .code-block-wrapper .hljs-keyword,
        .code-block-wrapper .hljs-selector-tag,
        .code-block-wrapper .hljs-literal,
        .code-block-wrapper .hljs-name {
            color: var(--hljs-keyword, #c586c0) !important;
        }

        .code-block-wrapper .hljs-built_in,
        .code-block-wrapper .hljs-type,
        .code-block-wrapper .hljs-title.class_,
        .code-block-wrapper .hljs-title.function_ {
            color: var(--hljs-function, #4ec9b0) !important;
        }

        .code-block-wrapper .hljs-string,
        .code-block-wrapper .hljs-template-string,
        .code-block-wrapper .hljs-regexp {
            color: var(--hljs-string, #ce9178) !important;
        }

        .code-block-wrapper .hljs-number,
        .code-block-wrapper .hljs-symbol,
        .code-block-wrapper .hljs-bullet {
            color: var(--hljs-number, #b5cea8) !important;
        }

        .code-block-wrapper .hljs-variable,
        .code-block-wrapper .hljs-variable.language_,
        .code-block-wrapper .hljs-attr,
        .code-block-wrapper .hljs-attribute,
        .code-block-wrapper .hljs-property {
            color: var(--hljs-variable, #9cdcfe) !important;
        }

        .code-block-wrapper .hljs-meta,
        .code-block-wrapper .hljs-doctag {
            color: var(--hljs-meta, #dcdcaa) !important;
        }

        .code-block-wrapper .hljs-params {
            color: var(--hljs-base, #d4d4d4) !important;
        }

        /* Inline code styling */
        .message-text code:not(pre code) {
            background: var(--code-bg);
            padding: 2px 6px;
            border-radius: 4px;
            font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
            font-size: 13px;
            color: var(--accent-primary);
            border: 1px solid var(--border-color);
        }

        /* KaTeX Math Rendering Styles */
        .katex-display {
            margin: 1em 0;
            padding: 12px 16px;
            background: rgba(var(--accent-rgb), 0.05);
            border-radius: 8px;
            border-left: 3px solid var(--accent-primary);
            overflow-x: auto;
        }

        .katex {
            font-size: 1.1em;
            color: var(--text-primary);
        }

        .message-text .katex-display {
            text-align: left;
        }

        .message-text .katex-display>.katex {
            text-align: left;
        }

        /* Inline math */
        .message-text .katex:not(.katex-display .katex) {
            padding: 2px 4px;
            background: rgba(var(--accent-rgb), 0.1);
            border-radius: 4px;
        }

        /* Math error styling */
        .katex-error {
            color: var(--error);
            font-size: 12px;
        }

        /* Better scrollbar for code blocks */
        .code-block-wrapper pre::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }

        .code-block-wrapper pre::-webkit-scrollbar-track {
            background: rgba(0, 0, 0, 0.2);
            border-radius: 4px;
        }

        .code-block-wrapper pre::-webkit-scrollbar-thumb {
            background: rgba(var(--overlay-rgb), 0.2);
            border-radius: 4px;
        }

        .code-block-wrapper pre::-webkit-scrollbar-thumb:hover {
            background: rgba(var(--overlay-rgb), 0.3);
        }

        /* ===== COST TRACKING UI (Week 1, Day 5) ===== */
        .message-metadata {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-top: 12px;
            flex-wrap: wrap;
        }

        .cost-badge,
        .tokens-badge,
        .latency-badge {
            padding: 4px 10px;
            border-radius: 6px;
            font-size: 11px;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
            gap: 4px;
            cursor: help;
            transition: all 0.2s;
        }

        .cost-badge {
            background: rgba(16, 185, 129, 0.15);
            color: var(--success);
            border: 1px solid rgba(16, 185, 129, 0.3);
        }

        .cost-badge:hover {
            background: rgba(16, 185, 129, 0.25);
            transform: translateY(-1px);
        }

        .tokens-badge {
            background: rgba(139, 92, 246, 0.15);
            color: var(--accent-primary);
            border: 1px solid rgba(var(--accent-rgb), 0.3);
        }

        .tokens-badge:hover {
            background: rgba(var(--accent-rgb), 0.25);
            transform: translateY(-1px);
        }

        /* Message Actions (Week 2, Day 9) */
        .message-actions {
            display: flex;
            align-items: center;
            gap: 2px;
            margin-top: 8px;
            opacity: 0;
            transition: opacity 0.2s;
        }

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

        .message.user .message-actions {
            justify-content: flex-end;
        }

        .action-btn {
            background: transparent;
            border: none;
            color: var(--text-tertiary);
            padding: 4px;
            border-radius: 4px;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }

        .action-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-secondary);
        }

        .action-btn svg {
            width: 14px;
            height: 14px;
        }

        .model-name-badge {
            font-size: 11px;
            color: var(--text-tertiary);
            padding-left: 6px;
            margin-left: 2px;
            display: inline-flex;
            align-items: center;
            user-select: none;
        }

        .latency-badge {
            background: rgba(245, 158, 11, 0.15);
            color: var(--warning);
            border: 1px solid rgba(245, 158, 11, 0.3);
        }

        .latency-badge:hover {
            background: rgba(245, 158, 11, 0.25);
            transform: translateY(-1px);
        }

        /* Cost estimator in input area */
        .cost-estimator {
            padding: 8px 12px;
            font-size: 12px;
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .cost-estimator-value {
            color: var(--success);
            font-weight: 600;
        }

        .cost-warning {
            color: var(--warning);
        }

        .cost-error {
            color: var(--error);
        }

        /* ===== INPUT AREA ===== */
        .input-area {
            background: linear-gradient(to bottom, transparent, var(--bg-primary) 30%);
            border-top: none;
            width: 100%;
            display: flex;
            justify-content: center;
            padding: 2rem 1rem 2rem 1rem;
            /* Bottom padding for floating look */
            box-sizing: border-box;
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 24;
            pointer-events: none;
        }

        .input-wrapper {
            width: 100%;
            max-width: 54rem;
            /* Match the wide, expansive look of the reference */
            margin: 0 auto;
            position: relative;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            align-items: center;
            transform-origin: bottom center;
            transition: transform 0.2s ease;
            background: transparent;
            pointer-events: auto;
        }

        .input-container {
            width: 100%;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            align-items: stretch;
            gap: 12px;
            background: var(--bg-secondary);
            border: 1px solid rgba(var(--overlay-rgb), 0.08);
            border-radius: 20px;
            padding: 12px 14px 14px 16px;
            transition: all 0.2s;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        .input-row {
            display: flex;
            gap: 10px;
            align-items: flex-end;
            width: 100%;
            position: relative;
        }

        .input-actions-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            width: 100%;
            padding-top: 2px;
        }

        .input-actions-left {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .input-actions-right {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .input-container:focus-within {
            border-color: rgba(var(--overlay-rgb), 0.1);
            background: var(--bg-tertiary);
            box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
        }

        textarea {
            flex-grow: 1;
            width: 100%;
            background: transparent;
            border: none;
            color: var(--text-primary);
            font-size: 15px;
            font-family: inherit;
            resize: none;
            outline: none;
            max-height: 200px;
            min-height: 24px;
            line-height: 1.5;
            padding: 6px 0;
            box-sizing: border-box;
            overflow-y: hidden;
            scrollbar-width: thin;
            scrollbar-color: rgba(var(--overlay-rgb), 0.28) transparent;
        }

        textarea::-webkit-scrollbar {
            width: 7px;
        }

        textarea::-webkit-scrollbar-track {
            background: transparent;
        }

        textarea::-webkit-scrollbar-thumb {
            background: rgba(var(--overlay-rgb), 0.2);
            border-radius: 999px;
        }

        textarea::-webkit-scrollbar-thumb:hover {
            background: rgba(var(--overlay-rgb), 0.35);
        }

        @media (max-width: 768px) {
            textarea {
                font-size: 16px;
                /* Prevent iOS zoom */
                min-height: 44px;
                /* Touch-friendly */
            }
        }

        textarea::placeholder {
            color: var(--text-tertiary);
        }

        .send-btn {
            width: 32px;
            height: 32px;
            background: rgba(var(--overlay-rgb), 0.1);
            border: none;
            border-radius: 50%;
            color: rgba(var(--overlay-rgb), 0.4);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            flex-shrink: 0;
        }

        .send-btn:not(:disabled) {
            background: var(--text-primary);
            color: var(--bg-primary);
            opacity: 1;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        .send-btn:hover:not(:disabled) {
            background: var(--text-primary);
            transform: translateY(-1px);
            box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
        }

        .send-btn:active:not(:disabled) {
            transform: translateY(0) scale(0.95);
        }

        @media (max-width: 768px) {
            .send-btn {
                width: 40px;
                height: 40px;
            }
        }

        .send-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
            background: rgba(var(--overlay-rgb), 0.05);
        }



        .send-btn.stop-btn {
            background: var(--error);
        }

        .send-btn.stop-btn:hover:not(:disabled) {
            background: var(--error);
        }

        .send-btn svg {
            width: 16px;
            height: 16px;
            stroke-width: 3;
        }

        /* ===== NEW CAPSULE BUTTONS (DeepThink / Search) ===== */
        .capsule-btn {
            height: 32px;
            background: rgba(var(--overlay-rgb), 0.04);
            border: 1px solid rgba(var(--overlay-rgb), 0.1);
            border-radius: 16px;
            color: var(--text-tertiary);
            /* Zinc-400 */
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 0 14px;
            font-size: 13px;
            font-weight: 500;
            transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
            flex-shrink: 0;
            user-select: none;
            outline: none;
            position: relative;
            overflow: hidden;
        }

        .capsule-btn svg {
            width: 15px;
            height: 15px;
            stroke-width: 1.6;
            display: block;
        }

        .capsule-btn:hover {
            background: rgba(var(--overlay-rgb), 0.05);
            color: var(--text-primary);
        }

        .capsule-btn.active-thinking {
            border-color: rgba(167, 139, 250, 0.7);
            /* Violet-400 */
            color: #ddd6fe;
            /* Violet-200 */
            background: rgba(167, 139, 250, 0.15);
            box-shadow: 0 0 12px rgba(167, 139, 250, 0.2), inset 0 0 4px rgba(167, 139, 250, 0.1);
        }

        .capsule-btn.active-thinking:hover {
            background: rgba(167, 139, 250, 0.2);
            border-color: rgba(167, 139, 250, 0.9);
            color: var(--text-primary);
        }

        .capsule-btn.active-search {
            border-color: rgba(96, 165, 250, 0.7);
            /* Blue-400 */
            color: #dbeafe;
            /* Blue-100 */
            background: rgba(96, 165, 250, 0.15);
            box-shadow: 0 0 12px rgba(96, 165, 250, 0.2), inset 0 0 4px rgba(96, 165, 250, 0.1);
        }

        .capsule-btn.active-search:hover {
            background: rgba(96, 165, 250, 0.2);
            border-color: rgba(96, 165, 250, 0.9);
            color: var(--text-primary);
        }

        /* Pro-locked capsule button (DeepThink for free users) */
        .capsule-btn.pro-locked {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .capsule-btn.pro-locked:hover {
            background: rgba(var(--overlay-rgb), 0.04);
            color: var(--text-tertiary);
        }

        .capsule-pro-badge {
            font-size: 9px;
            font-weight: 700;
            letter-spacing: 0.04em;
            padding: 1px 5px;
            border-radius: 4px;
            background: rgba(167, 139, 250, 0.2);
            color: #c4b5fd;
            border: 1px solid rgba(167, 139, 250, 0.35);
            line-height: 1.4;
        }

        /* Upgrade toast for locked features */
        .upgrade-feature-toast {
            position: fixed;
            bottom: 130px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 9999;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 11px 18px;
            background: var(--bg-secondary, #1a1a1a);
            border: 1px solid rgba(167, 139, 250, 0.4);
            border-left: 3px solid #a78bfa;
            border-radius: 10px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
            color: var(--text-secondary);
            font-size: 13px;
            font-weight: 500;
            white-space: nowrap;
            opacity: 1;
            transition: opacity 0.3s ease, transform 0.3s ease;
            pointer-events: auto;
        }

        .upgrade-feature-toast svg {
            color: #a78bfa;
            flex-shrink: 0;
        }

        .upgrade-toast-link {
            color: #a78bfa;
            font-weight: 700;
            text-decoration: none;
            margin-left: 4px;
            padding: 3px 10px;
            border: 1px solid rgba(167, 139, 250, 0.45);
            border-radius: 6px;
            transition: background 0.15s;
        }

        .upgrade-toast-link:hover {
            background: rgba(167, 139, 250, 0.15);
        }

        .attach-icon-btn {
            width: 36px;
            height: 36px;
            background: transparent;
            border: none;
            color: var(--text-tertiary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            transition: all 0.2s;
        }

        .attach-icon-btn svg {
            width: 18px;
            height: 18px;
            stroke-width: 2.5;
            transform: rotate(-45deg);
        }

        .attach-icon-btn:hover {
            color: var(--text-secondary);
            background: rgba(var(--overlay-rgb), 0.05);
        }

        /* Search results preview */
        .search-results-preview {
            display: none !important;
        }

        .search-results-header {
            font-size: 13px;
            font-weight: 600;
            color: var(--text-secondary);
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .search-result-item {
            padding: 12px;
            background: var(--bg-primary);
            border-radius: 8px;
            margin-bottom: 8px;
            transition: all 0.2s;
        }

        .search-result-item:hover {
            background: var(--bg-secondary);
            transform: translateY(-1px);
        }

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

        .search-result-title {
            font-size: 14px;
            font-weight: 600;
            color: var(--accent-primary);
            margin-bottom: 4px;
            text-decoration: none;
            display: block;
        }

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

        .search-result-url {
            font-size: 12px;
            color: var(--success);
            margin-bottom: 6px;
            word-break: break-all;
        }

        .search-result-snippet {
            font-size: 13px;
            color: var(--text-secondary);
            line-height: 1.5;
        }

        /* ===== SEARCH LOADING INDICATOR — icon only, no card ===== */

        .search-globe-indicator {
            display: inline-flex;
            align-items: center;
            gap: 10px;
            padding: 4px 0;
        }

        /* Globe icon container with ping rings */
        .search-globe-wrap {
            position: relative;
            width: 26px;
            height: 26px;
            flex-shrink: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* Radar ping rings */
        .search-globe-ping {
            position: absolute;
            inset: 0;
            border-radius: 50%;
            border: 1.5px solid rgba(96, 165, 250, 0.5);
            animation: search-ping 2s ease-out infinite;
        }

        .search-globe-ping:nth-child(2) {
            animation-delay: 0.9s;
        }

        @keyframes search-ping {
            0%   { transform: scale(0.7);  opacity: 0.75; }
            100% { transform: scale(1.9);  opacity: 0; }
        }

        /* Globe SVG */
        .search-globe-icon {
            width: 18px;
            height: 18px;
            color: #60a5fa;
            position: relative;
            z-index: 1;
            animation: search-globe-glow 2s ease-in-out infinite;
        }

        @keyframes search-globe-glow {
            0%, 100% { filter: drop-shadow(0 0 2px rgba(96, 165, 250, 0.4)); }
            50%       { filter: drop-shadow(0 0 7px rgba(96, 165, 250, 0.95)); }
        }

        /* Phase label */
        .search-globe-label {
            font-size: 13px;
            font-weight: 500;
            color: var(--text-tertiary);
            transition: opacity 0.2s ease;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        /* ===== FILE ATTACHMENTS IN MESSAGES (Week 2, Day 9) ===== */
        .message-attachments {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
            gap: 10px;
            margin-bottom: 8px;
            width: 100%;
            max-width: 760px;
        }

        .message.assistant .message-attachments {
            width: min(100%, 760px);
        }

        .message.user .message-attachments {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
            width: 100%;
            max-width: 85%;
            margin-left: auto;
        }

        .message.user .message-attachments .attachment-card {
            width: min(420px, 100%);
        }

        .message.user .message-attachments .attachment-card.attachment-card--image {
            width: auto;
            max-width: min(420px, 100%);
            /* justify-self is not needed in flex column */
        }

        .attachment-card {
            display: flex;
            align-items: center;
            gap: 12px;
            min-height: 56px;
            padding: 10px 12px;
            background: rgba(var(--overlay-rgb), 0.04);
            border: 1px solid rgba(var(--overlay-rgb), 0.08);
            border-radius: 12px;
            overflow: hidden;
            max-width: 100%;
            transition: background-color 0.2s ease, border-color 0.2s ease;
        }

        .attachment-card:hover {
            background: rgba(var(--overlay-rgb), 0.06);
            border-color: rgba(var(--overlay-rgb), 0.15);
        }

        .attachment-card--image {
            display: flex;
            flex-direction: column;
            padding: 0;
            background: transparent;
            border: none;
            box-shadow: none;
            gap: 0;
            cursor: zoom-in;
            border-radius: 12px;
            position: relative;
            overflow: hidden;
            width: auto;
            max-width: 100%;
        }

        .attachment-card--image:hover {
            background: transparent;
            border-color: rgba(var(--overlay-rgb), 0.2);
        }

        .attachment-card--image:focus-visible {
            outline: 2px solid rgba(99, 179, 237, 0.8);
            outline-offset: 4px;
            border-radius: 12px;
        }

        .attachment-image-wrap {
            display: flex;
            width: auto;
            height: auto;
            max-width: 100%;
            background: transparent;
            border-radius: 12px;
            border: none;
            overflow: hidden;
            justify-content: center;
            align-items: center;
            box-shadow: inset 0 0 0 1px rgba(113, 119, 144, 0.1); /* clean border line */
        }

        .attachment-card--image .attachment-image-footer {
            display: none;
        }

        .attachment-file-icon {
            --attachment-accent: #607d8b;
            width: 34px;
            height: 34px;
            border-radius: 10px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: var(--attachment-accent);
            background: color-mix(in srgb, var(--attachment-accent) 16%, rgba(9, 14, 24, 1) 84%);
            border: 1px solid color-mix(in srgb, var(--attachment-accent) 40%, rgba(132, 156, 196, 0.24) 60%);
            flex-shrink: 0;
            box-shadow: inset 0 0 0 1px rgba(var(--overlay-rgb), 0.08);
        }

        .attachment-file-icon svg {
            width: 18px;
            height: 18px;
            stroke: currentColor;
            stroke-width: 1.9;
            fill: none;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        .attachment-file-meta {
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 4px;
            flex: 1;
        }

        .attachment-file-name {
            font-size: 14px;
            line-height: 1.2;
            font-weight: 600;
            color: #ecf3ff;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .attachment-file-subtitle {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            width: fit-content;
            font-size: 12px;
            line-height: 1.2;
            color: #9bb0cf;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .attachment-file-type-pill {
            display: inline-flex;
            align-items: center;
            padding: 2px 7px;
            border-radius: 999px;
            background: rgba(146, 166, 201, 0.14);
            border: 1px solid rgba(146, 166, 201, 0.25);
            color: #c5d7f4;
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.35px;
            text-transform: uppercase;
            max-width: 84px;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .attachment-meta-dot {
            width: 3px;
            height: 3px;
            border-radius: 50%;
            background: rgba(146, 166, 201, 0.6);
            display: inline-block;
            flex-shrink: 0;
        }

        .attachment-card--image .attachment-file-icon {
            display: none;
        }

        .attachment-card--image .attachment-file-meta {
            flex-direction: row;
            align-items: center;
            gap: 6px;
        }

        .attachment-card--image .attachment-file-name {
            font-size: 12px;
            font-weight: 500;
            color: #ffffff;
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
        }

        .attachment-card--image .attachment-file-subtitle {
            font-size: 11px;
            color: rgba(var(--overlay-rgb), 0.8);
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
        }

        .attachment-card--image .attachment-file-type-pill {
            display: none;
            /* Removed the redundant JPEG/PNG pill */
        }

        .attachment-card--image .attachment-meta-dot {
            display: none;
            /* Also hide dot if pill is hidden */
        }

        .attachment-image {
            width: auto;
            height: auto;
            max-width: 100%;
            max-height: 360px;
            object-fit: contain;
            display: block;
            border-radius: 12px;
            transition: transform 0.2s ease, filter 0.2s ease;
        }

        .attachment-card--image:hover .attachment-image {
            transform: scale(1.02);
            filter: brightness(1.05);
        }

        @media (max-width: 768px) {
            .message-attachments {
                width: 100%;
                grid-template-columns: 1fr;
            }

            .message.user .message-attachments {
                width: 100%;
                max-width: 100%;
            }

            .message.user .message-attachments .attachment-card {
                width: 100%;
            }

            .message.user .message-attachments .attachment-card.attachment-card--image {
                width: auto;
                max-width: 100%;
            }
        }

        /* ===== MODEL RECOMMENDATION HINT (compact chip) ===== */
        .recommendation-banner {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 20px;
            padding: 6px 10px 6px 8px;
            margin: 0 auto 12px;
            max-width: fit-content;
            font-size: 13px;
            color: var(--text-secondary);
            animation: hintFadeIn 0.2s ease-out;
        }

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

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

        .recommendation-hint-icon {
            display: flex;
            align-items: center;
            color: var(--accent-primary);
            opacity: 0.8;
            flex-shrink: 0;
        }

        .recommendation-hint-icon svg {
            width: 14px;
            height: 14px;
        }

        .recommendation-hint-text {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .recommendation-hint-text strong {
            color: var(--text-primary);
            font-weight: 600;
        }

        .recommendation-hint-switch {
            background: var(--accent-primary);
            color: white;
            border: none;
            border-radius: 12px;
            padding: 3px 10px;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: opacity 0.15s;
            flex-shrink: 0;
        }

        .recommendation-hint-switch:hover {
            opacity: 0.85;
        }

        .recommendation-hint-dismiss {
            background: transparent;
            border: none;
            color: var(--text-tertiary);
            cursor: pointer;
            display: flex;
            align-items: center;
            padding: 2px;
            border-radius: 50%;
            flex-shrink: 0;
            transition: color 0.15s;
        }

        .recommendation-hint-dismiss:hover {
            color: var(--text-primary);
        }

        /* ===== THINKING VISUALIZATION (Week 2, Day 8) - ChatGPT Style ===== */
        .thinking-section {
            background: transparent;
            border: none;
            border-radius: 12px;
            /* ... */
            padding: 0;
            margin-bottom: 16px;
            overflow: hidden;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .thinking-section:hover {
            background: rgba(142, 142, 160, 0.05);
        }

        .thinking-section:not(.collapsed) {
            background: rgba(142, 142, 160, 0.08);
            border: 1px solid rgba(142, 142, 160, 0.16);
        }

        .thinking-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            cursor: pointer;
            user-select: none;
            transition: all 0.2s;
        }

        .thinking-header:hover {
            background: rgba(142, 142, 160, 0.06);
        }

        .thinking-label {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 14px;
            font-weight: 500;
            color: var(--text-secondary);
        }

        .thinking-icon {
            width: 20px;
            height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--accent-primary);
        }

        .thinking-icon.animated {
            animation: thinkingPulse 2s ease-in-out infinite;
        }

        @keyframes thinkingPulse {

            0%,
            100% {
                opacity: 1;
                transform: scale(1);
            }

            50% {
                opacity: 0.6;
                transform: scale(1.1);
            }
        }

        .thinking-duration {
            font-size: 13px;
            color: var(--text-tertiary);
            margin-left: 8px;
        }

        .thinking-toggle {
            width: 24px;
            height: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            color: var(--text-tertiary);
        }

        .thinking-toggle svg {
            width: 16px;
            height: 16px;
        }

        .thinking-section.collapsed .thinking-toggle {
            transform: rotate(-90deg);
        }

        .thinking-content {
            padding: 0 16px 16px 16px;
            font-size: 13px;
            color: var(--text-secondary);
            line-height: 1.7;
            max-height: 400px;
            overflow-y: auto;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .thinking-section.collapsed .thinking-content {
            max-height: 0;
            padding-top: 0;
            padding-bottom: 0;
            opacity: 0;
            overflow: hidden;
        }

        .thinking-content::-webkit-scrollbar {
            width: 6px;
        }

        .thinking-content::-webkit-scrollbar-track {
            background: transparent;
        }

        .thinking-content::-webkit-scrollbar-thumb {
            background: rgba(142, 142, 160, 0.3);
            border-radius: 3px;
        }

        .thinking-content::-webkit-scrollbar-thumb:hover {
            background: rgba(142, 142, 160, 0.5);
        }

        .thinking-steps {
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .thinking-step-title {
            font-weight: 600;
            color: var(--text-primary);
            margin-top: 12px;
            margin-bottom: 4px;
            font-size: 14px;
        }

        .thinking-step-item {
            margin-left: 20px;
            color: var(--text-secondary);
            list-style-type: disc;
            display: list-item;
            margin-bottom: 4px;
        }

        .thinking-step-text {
            color: var(--text-secondary);
            line-height: 1.6;
            margin-bottom: 8px;
        }

        .thinking-spinner {
            display: inline-block;
            width: 12px;
            height: 12px;
            border: 2px solid var(--text-secondary);
            border-top-color: transparent;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-left: 8px;
            vertical-align: middle;
        }

        /* @keyframes spin — already defined above */


        /* Thinking toggle in header */
        /* ===== FILE UPLOAD (Week 2, Day 9) ===== */
        .file-upload-area {
            position: relative;
            margin-bottom: 12px;
        }

        /* .file-upload-trigger removed — unused (.attach-icon-btn is used instead) */

        .file-input {
            display: none;
        }

        /* Removed old plus trigger styles as we swapped to direct capsule layout */

        .input-actions-trigger svg {
            width: 20px;
            height: 20px;
            transition: transform 0.2s;
        }

        .input-actions-menu {
            position: absolute;
            bottom: 100%;
            left: 0;
            margin-bottom: 8px;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 8px;
            min-width: 220px;
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
            z-index: 100;
            display: none;
            animation: slideUp 0.15s ease-out;
        }

        .input-actions-menu.show {
            display: block;
        }

        /* @keyframes slideUp — already defined above */

        .input-action-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 12px;
            border-radius: 8px;
            cursor: pointer;
            color: var(--text-secondary);
            transition: all 0.15s;
            font-size: 14px;
        }

        .input-action-item:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .input-action-item.active {
            background: rgba(139, 92, 246, 0.15);
            color: var(--accent-primary);
        }

        .input-action-item svg {
            width: 18px;
            height: 18px;
            flex-shrink: 0;
        }

        .input-action-item .action-icon {
            font-size: 18px;
            width: 18px;
            text-align: center;
        }

        .input-actions-divider {
            height: 1px;
            background: var(--border-color);
            margin: 6px 0;
        }

        .drag-drop-zone {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(139, 92, 246, 0.1);
            border: 3px dashed var(--accent-primary);
            border-radius: 12px;
            display: none;
            align-items: center;
            justify-content: center;
            pointer-events: none;
            z-index: 100;
            backdrop-filter: blur(4px);
            animation: pulseBorder 1.5s ease-in-out infinite;
        }

        @keyframes pulseBorder {

            0%,
            100% {
                border-color: var(--accent-primary);
                background: rgba(var(--accent-rgb), 0.1);
            }

            50% {
                border-color: var(--accent-hover);
                background: rgba(var(--accent-rgb), 0.15);
            }
        }

        .drag-drop-zone.active {
            display: flex;
        }

        .drag-drop-zone-content {
            text-align: center;
            color: var(--accent-primary);
        }

        .drag-drop-zone-content svg {
            width: 48px;
            height: 48px;
            margin-bottom: 8px;
        }

        .attached-files {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
            margin-bottom: 8px;
            /* Spacing from input row */
            padding-bottom: 8px;
            border-bottom: 1px solid var(--border-color);
            max-height: 150px;
            overflow-y: auto;
            width: 100%;
        }

        /* Scrollbar styling */
        .attached-files::-webkit-scrollbar {
            width: 6px;
        }

        .attached-files::-webkit-scrollbar-track {
            background: var(--bg-tertiary);
            border-radius: 3px;
        }

        .attached-files::-webkit-scrollbar-thumb {
            background: var(--text-tertiary);
            border-radius: 3px;
        }

        .attached-files::-webkit-scrollbar-thumb:hover {
            background: var(--text-secondary);
        }

        .attached-file {
            display: flex;
            align-items: center;
            gap: 9px;
            padding: 7px 10px 7px 8px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: 10px;
            transition: background 0.15s, border-color 0.15s;
            position: relative;
            max-width: 240px;
        }

        .attached-file.image-preview {
            padding: 0;
            width: 60px;
            height: 60px;
            overflow: hidden;
            border: none;
        }

        .file-remove-btn {
            position: absolute;
            top: 3px;
            right: 3px;
            width: 18px;
            height: 18px;
            background: rgba(0, 0, 0, 0.6);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            cursor: pointer;
            opacity: 0;
            transition: all 0.2s;
            z-index: 5;
        }

        .attached-file:hover .file-remove-btn {
            opacity: 1;
        }

        .file-remove-btn:hover {
            background: rgba(var(--error-rgb), 0.9);
            transform: scale(1.1);
        }

        .attached-file:hover {
            background: var(--bg-secondary);
        }

        /* File type badge — colored label pill */
        .file-type-badge {
            flex-shrink: 0;
            width: 38px;
            height: 38px;
            border-radius: 8px;
            background: color-mix(in srgb, var(--badge-color, #6b7280) 18%, transparent);
            border: 1px solid color-mix(in srgb, var(--badge-color, #6b7280) 35%, transparent);
            color: var(--badge-color, #9ca3af);
            font-size: 9px;
            font-weight: 700;
            letter-spacing: 0.3px;
            display: flex;
            align-items: center;
            justify-content: center;
            user-select: none;
            text-transform: uppercase;
        }

        .file-info {
            flex: 1;
            min-width: 0;
        }

        .file-name {
            font-size: 12.5px;
            font-weight: 500;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 160px;
        }

        .file-size {
            font-size: 11px;
            color: var(--text-tertiary);
            margin-top: 2px;
            display: flex;
            align-items: center;
            gap: 4px;
        }

        /* Tiny dot shown when file content was optimized/truncated */
        .file-optimized-dot {
            display: inline-block;
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background: var(--text-tertiary);
            opacity: 0.6;
            vertical-align: middle;
        }

        /* Error toast — fixed above the input area, always visible */
        /* ===== SCROLL TO BOTTOM BUTTON ===== */
        .scroll-to-bottom-btn {
            position: absolute;
            bottom: calc(var(--input-safe-offset, 188px) + 12px);
            right: 24px;
            z-index: 30;
            width: 34px;
            height: 34px;
            border-radius: 50%;
            background: var(--bg-secondary);
            border: 1px solid rgba(var(--overlay-rgb), 0.18);
            color: var(--text-secondary);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease, background 0.15s ease, color 0.15s ease;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
        }

        .scroll-to-bottom-btn.visible {
            opacity: 1;
            pointer-events: auto;
        }

        .scroll-to-bottom-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        @media (max-width: 768px) {
            .scroll-to-bottom-btn {
                right: 14px;
                bottom: calc(var(--input-safe-offset, 188px) + 8px);
            }
        }

        .file-error-banner {
            position: fixed;
            bottom: 130px;
            left: 50%;
            transform: translateX(-50%) translateY(0);
            z-index: 9999;
            max-width: 480px;
            width: calc(100% - 32px);
            display: flex;
            align-items: flex-start;
            gap: 9px;
            padding: 10px 16px;
            background: var(--bg-secondary, #1a1a1a);
            border: 1px solid rgba(var(--error-rgb, 248, 113, 113), 0.45);
            border-left: 3px solid var(--error, #f87171);
            border-radius: 10px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0,0,0,0.3);
            color: var(--error, #f87171);
            font-size: 13px;
            font-weight: 500;
            line-height: 1.4;
            opacity: 1;
            transition: opacity 0.3s ease, transform 0.3s ease;
            pointer-events: none;
        }

        .file-remove {
            width: 28px;
            height: 28px;
            background: transparent;
            border: none;
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--text-secondary);
            transition: all 0.2s;
            flex-shrink: 0;
        }

        .file-remove:hover {
            background: rgba(var(--error-rgb), 0.2);
            color: var(--error);
        }

        .file-remove svg {
            width: 16px;
            height: 16px;
        }

        .file-stats {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 8px 12px;
            background: rgba(var(--accent-rgb), 0.1);
            border: 1px solid rgba(var(--accent-rgb), 0.3);
            border-radius: 8px;
            font-size: 12px;
            color: var(--accent-primary);
            margin-bottom: 8px;
            flex-wrap: wrap;
        }

        .file-stats-item {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .file-stats-warning {
            background: rgba(var(--warning-rgb), 0.1);
            border-color: rgba(var(--warning-rgb), 0.3);
            color: var(--warning);
        }

        .file-stats-error {
            background: rgba(var(--error-rgb), 0.1);
            border-color: rgba(var(--error-rgb), 0.3);
            color: var(--error);
        }

        /* ===== FILE PREVIEW MODAL (Week 2, Day 10) ===== */
        .file-preview-modal {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 10002;
            display: flex;
            align-items: center;
            justify-content: center;
            animation: fadeIn 0.2s ease;
            padding: 20px;
        }

        /* @keyframes fadeIn — already defined above */

        .file-preview-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(4px);
        }

        .file-preview-content {
            position: relative;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 16px;
            width: 90%;
            max-width: 800px;
            max-height: 80vh;
            display: flex;
            flex-direction: column;
            box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
            animation: slideUp 0.3s ease;
        }

        .file-preview-modal.image-preview-modal {
            padding: 0;
        }

        .file-preview-overlay.image-preview-overlay {
            background: rgba(0, 0, 0, 0.85);
            backdrop-filter: blur(8px);
        }

        .file-preview-content.image-preview-mode {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            max-width: none;
            max-height: none;
            border: none;
            background: transparent;
            box-shadow: none;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            gap: 0;
        }

        @media (max-width: 768px) {
            .file-preview-content {
                width: 95%;
                max-height: 90vh;
                border-radius: 12px;
            }

            .file-preview-header,
            .file-preview-meta {
                padding: 16px;
            }

            .file-preview-body {
                padding: 16px;
            }
        }

        /* @keyframes slideUp — already defined above */

        .file-preview-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 20px 24px;
            border-bottom: 1px solid var(--border-color);
        }

        .file-preview-header.image-preview-header {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            padding: 20px 24px;
            background: linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
            border: none;
            border-radius: 0;
            backdrop-filter: none;
            box-shadow: none;
            width: 100%;
            max-width: 100%;
            display: flex;
            justify-content: space-between;
            align-items: center;
            z-index: 10;
        }

        .file-preview-header.image-preview-header .file-preview-title {
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
        }

        .file-preview-header.image-preview-header .preview-meta-badge {
            background: rgba(var(--overlay-rgb), 0.15);
            border: 1px solid rgba(var(--overlay-rgb), 0.2);
            color: #ffffff;
            text-shadow: none;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .file-preview-header.image-preview-header .preview-open-link {
            background: none;
            border: none;
            color: rgba(255, 255, 255, 0.75);
            text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
            padding: 4px 0;
            font-size: 13px;
        }

        .file-preview-header.image-preview-header .preview-open-link:hover {
            background: none;
            color: #ffffff;
            text-decoration: underline;
        }

        .file-preview-header.image-preview-header .file-preview-close {
            color: rgba(255, 255, 255, 0.75);
            background: none;
            border: none;
            box-shadow: none;
        }

        .file-preview-header.image-preview-header .file-preview-close:hover {
            background: none;
            color: #ffffff;
        }

        .file-preview-title {
            display: flex;
            align-items: center;
            font-size: 16px;
            font-weight: 600;
            color: var(--text-primary);
            min-width: 0;
            gap: 10px;
        }

        .file-preview-title .preview-title-text {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            max-width: min(48vw, 560px);
        }

        .file-preview-close {
            width: 36px;
            height: 36px;
            background: transparent;
            border: none;
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            color: var(--text-secondary);
            transition: all 0.2s;
        }

        .file-preview-close:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .file-preview-close svg {
            width: 20px;
            height: 20px;
        }

        .image-preview-actions {
            margin-left: auto;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            flex-shrink: 0;
        }

        .preview-meta-badge {
            display: inline-flex;
            align-items: center;
            padding: 3px 8px;
            border-radius: 999px;
            background: rgba(118, 152, 210, 0.16);
            border: 1px solid rgba(118, 152, 210, 0.32);
            color: #d3e4ff;
            font-size: 11px;
            line-height: 1;
            font-weight: 600;
            letter-spacing: 0.2px;
        }

        .file-preview-meta {
            padding: 12px 24px;
            font-size: 13px;
            color: var(--text-secondary);
            border-bottom: 1px solid var(--border-color);
            display: flex;
            gap: 12px;
        }

        .file-preview-body {
            flex: 1;
            overflow-y: auto;
            padding: 24px;
        }

        .file-preview-body.image-preview-body {
            position: absolute;
            inset: 0;
            padding: 80px 40px 40px;
            background: transparent;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: hidden;
            border: none;
        }

        .file-preview-body.image-preview-body img {
            max-width: 100%;
            max-height: 100%;
            width: auto;
            height: auto;
            object-fit: contain;
            border-radius: 8px;
            border: none;
            box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
        }

        .preview-open-link {
            font-size: 12px;
            color: #b7dcff;
            text-decoration: none;
            border: 1px solid rgba(143, 199, 255, 0.36);
            border-radius: 999px;
            padding: 6px 10px;
            transition: background-color 0.2s ease, border-color 0.2s ease;
        }

        .preview-open-link:hover {
            background: rgba(143, 199, 255, 0.16);
            border-color: rgba(143, 199, 255, 0.55);
        }

        @media (max-width: 768px) {
            .file-preview-header.image-preview-header {
                padding: 10px 10px 10px 12px;
                max-width: calc(94vw - 12px);
            }

            .file-preview-title .preview-title-text {
                max-width: 42vw;
                font-size: 14px;
            }

            .preview-meta-badge {
                display: none;
            }

            .image-preview-actions {
                gap: 6px;
            }

            .preview-open-link {
                padding: 5px 8px;
                font-size: 11px;
            }
        }

        .file-preview-body pre {
            margin: 0;
            font-size: 13px;
            line-height: 1.6;
            color: var(--text-primary);
            white-space: pre-wrap;
            word-wrap: break-word;
            font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
        }

        /* .thinking-mode-btn, .thinking-settings-toggle removed — unused dead CSS */

        /* ===== EMPTY STATE ===== */
        .empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100%;
            text-align: center;
            padding: 40px;
        }

        .empty-state-title {
            font-size: 24px;
            font-weight: 600;
            margin-bottom: 8px;
        }

        .empty-state-description {
            color: var(--text-secondary);
            font-size: 15px;
        }

        .chat-greeting-empty {
            display: none;
        }

        .main-content.chat-empty .chat-greeting-empty {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 8px;
            margin-bottom: 32px;
            position: relative;
            text-align: center;
            animation: greetingFadeIn 0.8s ease-out;
        }

        @keyframes greetingFadeIn {
            from {
                opacity: 0;
                transform: translateY(10px);
            }

            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .chat-greeting-empty::before {
            content: '';
            position: absolute;
            width: 180px;
            height: 80px;
            background: var(--accent-primary);
            filter: blur(45px);
            opacity: 0.15;
            z-index: -1;
            border-radius: 50%;
            animation: pulse-glow 4s ease-in-out infinite alternate;
        }

        @keyframes pulse-glow {
            from {
                opacity: 0.1;
                transform: scale(1);
            }

            to {
                opacity: 0.25;
                transform: scale(1.1);
            }
        }

        /* Always hide the brand logo image in greeting */
        .chat-greeting-empty img {
            display: none;
        }

        .greeting-name {
            font-size: 36px;
            font-weight: 700;
            letter-spacing: -0.03em;
            line-height: 1.1;
            background: linear-gradient(90deg,
                    var(--text-primary) 0%,
                    var(--accent-primary) 50%,
                    var(--text-primary) 100%);
            background-size: 200% auto;
            color: transparent;
            -webkit-background-clip: text;
            background-clip: text;
            animation: textShine 4s linear infinite;
        }

        .greeting-sub {
            font-size: 17px;
            font-weight: 400;
            color: var(--text-tertiary);
            letter-spacing: -0.005em;
            line-height: 1.5;
            margin-top: 4px;
        }

        @keyframes textShine {
            to {
                background-position: 200% center;
            }
        }

        /* Centered input when chat is empty */
        .main-content.chat-empty {
            position: relative;
        }

        .main-content.chat-empty .chat-header {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            z-index: 20;
        }

        .main-content.chat-empty .messages-container {
            flex: 0;
            display: none;
        }

        .main-content.chat-empty .input-area {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 90%;
            max-width: 48rem;
            padding: 0;
            background: transparent;
            /* Remove gradient in empty state */
            flex-direction: column;
            align-items: center;
        }

        .main-content.chat-empty .input-wrapper {
            width: 100%;
        }

        /* ===== LOADING STATE ===== */
        .typing-indicator {
            display: flex;
            gap: 4px;
            padding: 16px;
            align-items: center;
        }

        .typing-dot {
            width: 8px;
            height: 8px;
            background: var(--text-tertiary);
            border-radius: 50%;
            animation: typing 1.4s infinite;
        }

        .typing-dot:nth-child(2) {
            animation-delay: 0.2s;
        }

        .typing-dot:nth-child(3) {
            animation-delay: 0.4s;
        }

        @keyframes typing {

            0%,
            60%,
            100% {
                transform: translateY(0);
                opacity: 0.7;
            }

            30% {
                transform: translateY(-10px);
                opacity: 1;
            }
        }

        /* ===== SCROLLBAR ===== */
        ::-webkit-scrollbar {
            width: 8px;
            /* Slim and elegant */
            height: 8px;
            /* For horizontal scrollbars */
        }

        ::-webkit-scrollbar-track {
            background: transparent;
            border-radius: 10px;
        }

        ::-webkit-scrollbar-thumb {
            background-color: var(--border-color);
            /* More subtle inactive color */
            border-radius: 10px;
            border: 2px solid var(--bg-primary);
            /* Creates a 'floating' padding effect */
            background-clip: padding-box;
            transition: background-color 0.2s;
        }

        ::-webkit-scrollbar-thumb:hover {
            background-color: var(--text-tertiary);
        }

        /* Firefox scrollbar support */
        .messages-container,
        .chat-history,
        .thinking-content,
        .code-block-wrapper pre,
        .attached-files {
            scrollbar-width: thin;
            scrollbar-color: var(--border-color) transparent;
        }

        /* ===== HEADER THEME BUTTON ===== */
        .header-theme-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            background: transparent;
            border: none;
            padding: 0 0 0 16px;
            border-left: 1px solid rgba(var(--overlay-rgb), 0.1);
            color: #ffffff;
            cursor: pointer;
            opacity: 0.75;
            transition: opacity 0.2s ease, color 0.2s ease, transform 0.2s ease;
            flex-shrink: 0;
        }

        .header-theme-btn:hover {
            opacity: 1;
            color: var(--accent, #a78bfa);
            transform: rotate(20deg) scale(1.1);
        }

        /* ===== RESPONSIVE — Tablet / Small Screen (≤768px) ===== */
        @media (max-width: 768px) {

            /* ── SIDEBAR → fixed overlay ── */
            .sidebar {
                position: fixed;
                left: 0;
                top: 0;
                width: 280px;
                height: 100%;
                z-index: 100;
                transform: translateX(-100%);
                background: var(--bg-primary);
                transition: transform 0.25s ease;
            }

            .sidebar:not(.hidden) {
                transform: translateX(0);
            }

            .sidebar.hidden {
                transform: translateX(-100%);
            }

            /* ── BRAND ── */
            .brand-icon-fixed {
                width: 44px;
                padding-left: 12px;
            }

            .floating-controls {
                left: 44px;
            }

            .app-container {
                width: 100%;
            }

            /* ── HEADER ── */
            /* padding-left always accounts for fixed brand icon + floating controls */
            .chat-header {
                padding: 10px 12px 10px 104px;
                height: 56px;
                gap: 8px;
                /* flex-end so header-actions always anchors right
                   (when title is hidden on empty chat there's no irregular gap) */
                justify-content: flex-end;
            }

            /* Hide title area entirely on mobile — header-actions anchors right */
            .chat-header-main {
                display: none;
            }

            /* Model selector compact */
            .model-selector-trigger {
                padding: 5px 10px;
                font-size: 12px;
                gap: 6px;
            }

            /* ── MODEL MENU on mobile ── */
            .model-menu {
                /* Cap height so it never fills the full screen */
                max-height: min(52vh, 340px);
                /* Fit inside the viewport width with small margin */
                width: min(260px, calc(100vw - 24px));
                right: 0;
            }

            /* Compact rows — hide description text to reduce height */
            .model-menu .mo-desc {
                display: none;
            }

            .model-menu .model-option {
                padding: 9px 10px;
            }

            /* Header actions compact */
            .header-actions {
                gap: 4px;
                flex-shrink: 0;
            }

            /* ── MOBILE CREDITS SWAP ──
               Empty/new chat: show total credits, hide session cost.
               Active chat:    show session cost,    hide total credits.
               Desktop stays unchanged (both always visible). */
            .main-content:not(.chat-empty) .header-actions > .credits-wrapper {
                display: none;
            }

            /* session cost is already hidden on empty chat via the global rule:
               .main-content.chat-empty .cost-display { display: none } */

            .header-action-btn {
                width: 36px;
                height: 36px;
            }

            /* ── INPUT AREA ── */
            .input-area {
                padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px)) 1rem;
            }

            .input-wrapper {
                max-width: 100%;
            }

            .input-container {
                border-radius: 16px;
                padding: 10px 12px 12px 14px;
            }

            textarea {
                font-size: 15px;
                min-height: 24px;
                padding: 8px 0;
            }

            .send-btn {
                width: 40px;
                height: 40px;
            }

            /* Capsule buttons compact */
            .capsule-btn {
                height: 30px;
                font-size: 12px;
                padding: 0 10px;
                gap: 5px;
            }

            .capsule-btn svg {
                width: 13px;
                height: 13px;
            }

            .capsule-label {
                font-size: 12px;
            }

            /* Input actions row */
            .input-actions-left {
                gap: 4px;
            }

            .input-actions-right {
                gap: 6px;
            }

            /* Attachment button */
            .attachment-btn {
                width: 36px;
                height: 36px;
            }

            /* ── MESSAGES ── */
            .message-inner {
                padding: 0 16px;
            }

            .message {
                gap: 10px;
            }

            /* ── EMPTY STATE when chat is empty ── */
            .main-content.chat-empty .input-area {
                width: 95%;
                max-width: 100%;
            }

            .empty-state {
                padding: 20px;
            }

            .empty-state-title {
                font-size: 20px;
            }

            .empty-state-subtitle {
                font-size: 14px;
            }

            /* ── GREETING (empty state) ── */
            .main-content.chat-empty .chat-greeting-empty {
                gap: 6px;
                margin-bottom: 20px;
            }

            .greeting-name {
                font-size: 26px;
                letter-spacing: -0.02em;
            }

            .greeting-sub {
                font-size: 14px;
            }

            /* ── CODE BLOCKS ── */
            .code-action-btn {
                min-width: 44px;
                min-height: 44px;
            }

            .code-block-wrapper code {
                font-size: 12px;
            }

            .code-block-header {
                padding: 8px 10px;
                font-size: 11px;
            }

            /* ── CONTEXT MENU ── */
            .chat-context-menu {
                min-width: 180px;
            }

            /* ── FILE PREVIEW MODAL ── */
            .file-preview-content {
                width: 95%;
                max-height: 90vh;
                border-radius: 12px;
            }

            .file-preview-header,
            .file-preview-meta {
                padding: 12px 14px;
            }

            .file-preview-body {
                padding: 12px 14px;
            }

            /* ── SETTINGS MODAL ── */
            .settings-modal-content {
                width: 95vw;
                max-height: 85vh;
            }

            /* ── FLOATING THEME SWITCH ── */
            /* ── SIDEBAR BRAND ── */
            .sidebar-brand-header {
                height: 56px;
            }

            /* When sidebar is open on mobile, hide the fixed brand icon
               (sidebar has its own branding; icon would overlap) */
            .sidebar-open .brand-icon-fixed {
                opacity: 0;
                pointer-events: none;
            }

            /* Remove the left-pad that reserves space for the now-hidden brand icon */
            .sidebar-open .sidebar-brand-header {
                padding-left: 12px;
            }

            /* ── MESSAGE ATTACHMENTS ── */
            .message-attachments {
                width: 100%;
                grid-template-columns: 1fr;
            }

            .message.user .message-attachments {
                width: 100%;
                max-width: 100%;
            }

            .message.user .message-attachments .attachment-card {
                width: 100%;
            }

            /* ── FILE PREVIEW (IMAGE) ── */
            .file-preview-header.image-preview-header {
                padding: 10px 10px 10px 12px;
                max-width: calc(94vw - 12px);
            }

            .file-preview-title .preview-title-text {
                max-width: 42vw;
                font-size: 14px;
            }

            .preview-meta-badge {
                display: none;
            }

            .image-preview-actions {
                gap: 6px;
            }

            .preview-open-link {
                padding: 5px 8px;
                font-size: 11px;
            }

            /* ── RECOMMENDATION HINT ── */
            .recommendation-banner {
                max-width: 100%;
            }
        }

        /* ===== RESPONSIVE — Mobile Phone (≤480px) ===== */
        @media (max-width: 480px) {

            /* ── SIDEBAR ── */
            .sidebar {
                width: min(85vw, 280px);
            }

            .sidebar-brand-header {
                height: 48px;
                padding: 0 10px;
            }

            /* Re-assert correct padding when sidebar is overlaid */
            .sidebar-open .sidebar-brand-header {
                padding-left: 12px;
            }

            .sidebar-brand-wordmark {
                height: 16px;
            }

            .sidebar-actions {
                padding: 4px 8px 6px;
            }

            .sidebar-new-chat-btn {
                height: 36px;
                font-size: 13px;
            }

            .sidebar-search-wrap {
                padding: 0 8px 8px;
            }

            .chat-history {
                padding: 6px 6px;
            }

            .chat-history-item {
                padding: 7px 10px;
                font-size: 13px;
            }

            .chat-title-text {
                max-width: 150px;
            }

            .sidebar-footer {
                padding: 8px 6px;
                padding-bottom: calc(8px + env(safe-area-inset-bottom));
            }

            .sidebar-user-profile {
                padding: 6px;
                gap: 8px;
            }

            .user-avatar {
                width: 28px;
                height: 28px;
                font-size: 12px;
            }

            .user-name {
                font-size: 13px;
            }

            /* ── BRAND ICON ── */
            .brand-icon-fixed {
                width: 40px;
                height: 56px;
            }

            .brand-icon-fixed img {
                width: 26px;
                height: 26px;
            }

            /* ── HEADER ── */
            /* padding-left always accounts for fixed brand icon (40px) + floating controls (~48px) */
            .chat-header {
                padding: 8px 10px 8px 92px;
                height: 48px;
                gap: 6px;
            }

            /* ── HEADER ACTIONS compact (small phones) ── */
            /* Credits: show compact with icon, smaller font */
            .header-actions > .credits-wrapper {
                display: flex;
            }

            .credits-display {
                font-size: 12px;
                gap: 5px;
                letter-spacing: 0;
            }

            .credits-icon svg {
                width: 12px;
                height: 12px;
            }

            /* Strip border separator from cost display, keep icon visible */
            .cost-display {
                padding-left: 0;
                border-left: none;
                font-size: 12px;
                gap: 4px;
            }

            .cost-display .cost-icon svg {
                width: 12px;
                height: 12px;
            }

            /* Strip border separator from theme button */
            .header-theme-btn {
                padding-left: 6px;
                border-left: none;
            }

            .header-actions {
                flex-shrink: 0;
                gap: 6px;
            }

            /* ── FLOATING CONTROLS ── */
            .floating-controls {
                left: 40px;
                height: 56px;
                gap: 8px;
            }

            .floating-btn {
                width: 30px;
                height: 30px;
            }

            /* ── MODEL SELECTOR ── */
            .model-selector-trigger {
                padding: 4px 8px;
                font-size: 11px;
                gap: 4px;
            }

            .model-selector-trigger svg {
                width: 12px;
                height: 12px;
            }

            /* ── MODEL MENU on small phones ── */
            .model-menu {
                max-height: min(48vh, 300px);
                width: min(240px, calc(100vw - 20px));
            }

            .model-menu .model-option {
                padding: 8px 9px;
            }

            .model-menu .mo-title {
                font-size: 13px;
            }

            /* ── HEADER ACTIONS ── */
            .header-action-btn {
                width: 32px;
                height: 32px;
            }

            .header-action-btn svg {
                width: 15px;
                height: 15px;
            }

            /* ── INPUT AREA ── */
            .input-area {
                padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px)) 1rem;
            }

            .input-container {
                border-radius: 14px;
                padding: 8px 10px 10px 12px;
            }

            textarea {
                font-size: 15px;
                min-height: 24px;
                line-height: 1.5;
                padding: 8px 0;
            }

            .send-btn {
                width: 36px;
                height: 36px;
            }

            .send-btn svg {
                width: 14px;
                height: 14px;
            }

            /* ── CAPSULE BUTTONS ── */
            .capsule-btn {
                height: 28px;
                font-size: 11px;
                padding: 0 8px;
                gap: 4px;
                border-radius: 14px;
            }

            .capsule-btn svg {
                width: 12px;
                height: 12px;
            }

            .capsule-label {
                font-size: 11px;
            }

            /* Hide less critical capsule labels */
            .capsule-btn .capsule-label {
                max-width: 60px;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

            .input-actions-left {
                gap: 3px;
            }

            .input-actions-right {
                gap: 4px;
            }

            .attachment-btn {
                width: 32px;
                height: 32px;
            }

            /* ── MESSAGES ── */
            .message-inner {
                padding: 0 16px;
            }

            .message {
                gap: 8px;
                margin-bottom: 10px;
            }

            .message-content {
                font-size: 14px;
                line-height: 1.55;
            }

            /* ── EMPTY STATE ── */
            .main-content.chat-empty .input-area {
                width: 98%;
            }

            .empty-state {
                padding: 16px;
            }

            .empty-state-title {
                font-size: 18px;
            }

            .empty-state-subtitle {
                font-size: 13px;
            }

            /* ── GREETING (empty state) ── */
            .greeting-name {
                font-size: 22px;
                letter-spacing: -0.015em;
            }

            .greeting-sub {
                font-size: 13px;
            }

            /* ── CODE BLOCKS ── */
            .code-block-wrapper code {
                font-size: 11px;
            }

            .code-block-header {
                padding: 6px 8px;
                font-size: 10px;
            }

            .code-action-btn {
                min-width: 40px;
                min-height: 40px;
                font-size: 11px;
            }

            /* ── CONTEXT MENU ── */
            .chat-context-menu {
                min-width: 160px;
                font-size: 12px;
            }

            .context-menu-item {
                padding: 7px 10px;
                gap: 8px;
            }

            /* ── FILE PREVIEW ── */
            .file-preview-content {
                width: 98%;
                max-height: 95vh;
                border-radius: 10px;
            }

            .file-preview-header,
            .file-preview-meta {
                padding: 10px 12px;
            }

            .file-preview-body {
                padding: 10px 12px;
            }

            .file-preview-body pre {
                font-size: 12px;
            }

            /* ── SETTINGS MODAL ── */
            .settings-modal-content {
                width: 98vw;
                max-height: 92vh;
                border-radius: 14px;
            }

            /* ── FLOATING THEME SWITCH ── */

            /* ── TYPING INDICATOR ── */
            .typing-indicator {
                padding: 10px;
            }

            .typing-dot {
                width: 6px;
                height: 6px;
            }

            /* ── MESSAGE INDEX ── */
            .message-index-panel {
                right: 2px;
                width: auto;
            }
            
            .message-index-item {
                width: 24px;
                height: 20px;
                justify-content: flex-end;
            }
            
            .message-index-marker {
                width: 6px;
                height: 3px;
            }
            
            .message-index-item.active .message-index-marker {
                width: 12px;
            }
            
            .message-index-label {
                font-size: 11px;
                padding: 4px 8px;
                min-width: unset;
                max-width: 140px;
                right: calc(100% + 6px);
                white-space: pre-wrap;
                word-break: break-word;
            }
        }

        /* ===== SIDEBAR SCRIM (mobile overlay backdrop) ===== */
        .sidebar-scrim {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 99; /* below sidebar z-index:100, above main content */
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
            touch-action: none;
        }

        @media (max-width: 768px) {
            .sidebar-scrim.active {
                display: block;
                animation: scrimFadeIn 0.2s ease forwards;
            }

            @keyframes scrimFadeIn {
                from { opacity: 0; }
                to   { opacity: 1; }
            }
        }