        :root {
            /* Chrome Dark Theme - Unified */
            --bg-primary: #202124;
            --bg-secondary: #202124;
            --bg-tertiary: #292a2d;
            --bg-elevated: #252629;
            --bg-hover: #3c4043;
            --text-primary: #FFFFFF;
            --text-secondary: #A0A0A0;
            --text-muted: #666666;
            --border: rgba(255,255,255,0.06);
            --border-hover: rgba(255,255,255,0.12);
            --accent: #FFFFFF;
            --shadow: 0 0 0 1px rgba(255,255,255,0.05);
        }

        html.light {
            --bg-primary: #FFFFFF;
            --bg-secondary: #FFFFFF;
            --bg-tertiary: #F5F5F5;
            --bg-elevated: #FAFAFA;
            --bg-hover: #EEEEEE;
            --text-primary: #000000;
            --text-secondary: #666666;
            --text-muted: #999999;
            --border: rgba(0,0,0,0.06);
            --border-hover: rgba(0,0,0,0.12);
            --accent: #000000;
            --shadow: 0 0 0 1px rgba(0,0,0,0.05);
        }

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

        *::before, *::after {
            box-sizing: border-box;
        }

        html, body {
            height: 100%;
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background: var(--bg-primary);
            color: var(--text-primary);
            overflow: hidden;
            transition: background 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                        color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        }

        /* Scrollbar - minimal */
        ::-webkit-scrollbar {
            width: 4px;
            height: 4px;
        }

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

        ::-webkit-scrollbar-thumb {
            background: var(--border);
            border-radius: 2px;
        }

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

        /* App Layout */
        .app {
            display: flex;
            height: 100vh;
            height: 100dvh;
            overflow: hidden;
        }

        /* Sidebar */
        .sidebar {
            width: 260px;
            background: var(--bg-secondary);
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        }

        .sidebar-header {
            padding: 20px;
            border-bottom: 1px solid var(--border);
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }

        .logo-mark {
            width: 32px;
            height: 32px;
            position: relative;
        }

        .logo-mark::before,
        .logo-mark::after {
            content: '';
            position: absolute;
            border-radius: 50%;
            background: var(--text-primary);
        }

        .logo-mark::before {
            width: 8px;
            height: 8px;
            top: 4px;
            left: 4px;
            animation: nodePulse 2s ease-in-out infinite;
        }

        .logo-mark::after {
            width: 6px;
            height: 6px;
            top: 4px;
            right: 4px;
            animation: nodePulse 2s ease-in-out infinite 0.3s;
        }

        .logo-mark-inner {
            position: absolute;
            width: 5px;
            height: 5px;
            background: var(--text-primary);
            border-radius: 50%;
            bottom: 4px;
            left: 50%;
            margin-left: -2.5px;
            animation: nodePulse 2s ease-in-out infinite 0.6s;
        }

        .logo-mark-line {
            position: absolute;
            height: 1.5px;
            background: var(--text-primary);
            transform-origin: left center;
        }

        .logo-mark-line:first-of-type {
            width: 16px;
            top: 7px;
            left: 8px;
        }

        .logo-mark-line:last-of-type {
            width: 14px;
            top: 12px;
            left: 10px;
            transform: rotate(60deg);
        }

        @keyframes nodePulse {
            0%, 100% { transform: scale(1); opacity: 1; }
            50% { transform: scale(1.2); opacity: 1; }
        }

        .logo-text {
            font-size: 16px;
            font-weight: 300;
            letter-spacing: 4px;
            color: var(--text-primary);
            text-transform: uppercase;
        }

        .new-chat-btn {
            width: 100%;
            padding: 10px 14px;
            background: transparent;
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text-primary);
            font-size: 13px;
            font-weight: 450;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            transition: all 0.2s ease;
        }

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

        .new-chat-btn:active {
            transform: scale(0.98);
        }

        .sidebar-search {
            padding: 12px 16px;
            border-bottom: 1px solid var(--border);
        }

        .search-input {
            width: 100%;
            padding: 8px 12px;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            border-radius: 6px;
            color: var(--text-primary);
            font-size: 13px;
            outline: none;
            transition: all 0.2s ease;
        }

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

        .search-input:focus {
            border-color: var(--border-hover);
        }

        .sidebar-content {
            flex: 1;
            overflow-y: auto;
            padding: 0 8px 8px;
        }

        .section-title {
            padding: 16px 12px 8px;
            font-size: 11px;
            font-weight: 500;
            text-transform: uppercase;
            letter-spacing: 0.8px;
            color: var(--text-muted);
        }

        .chat-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 10px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.15s ease;
            margin-bottom: 2px;
            position: relative;
            animation: slideIn 0.3s ease-out;
        }

        @keyframes slideIn {
            from {
                opacity: 0;
                transform: translateX(-8px);
            }
            to {
                opacity: 1;
                transform: translateX(0);
            }
        }

        .chat-item:hover {
            background: var(--bg-tertiary);
        }

        .chat-item.active {
            background: var(--bg-elevated);
        }

        .chat-item.pinned {
            position: relative;
        }

        .chat-item.pinned::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 2px;
            height: 12px;
            background: var(--text-primary);
            border-radius: 0 1px 1px 0;
        }

        .chat-icon {
            width: 14px;
            height: 14px;
            color: var(--text-muted);
            flex-shrink: 0;
            opacity: 0.5;
        }

        .chat-title,
        .chat-item-name {
            flex: 1;
            min-width: 0;
            max-width: 180px;
            font-size: 13px;
            color: var(--text-secondary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            transition: color 0.15s ease;
        }

        .chat-item:hover .chat-title,
        .chat-item.active .chat-title {
            color: var(--text-primary);
        }

        .chat-actions {
            display: flex;
            gap: 2px;
            opacity: 0;
            transition: opacity 0.15s ease;
        }

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

        .chat-action-btn {
            width: 22px;
            height: 22px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 4px;
            transition: all 0.15s ease;
        }

        .chat-action-btn:hover {
            background: var(--border);
            color: var(--text-primary);
        }

        .chat-menu-btn {
            width: 22px;
            height: 22px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 4px;
            transition: all 0.15s ease;
            opacity: 0;
        }

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

        .chat-menu-btn:hover {
            background: var(--border);
            color: var(--text-primary);
        }

        .chat-menu-dropdown {
            position: absolute;
            right: 8px;
            top: 100%;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 4px;
            min-width: 140px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.4);
            opacity: 0;
            visibility: hidden;
            transform: translateY(-8px);
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 100;
        }

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

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

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

        .chat-menu-item svg {
            width: 14px;
            height: 14px;
        }

        /* Floating project context menu (right-click / long-press on a tab). */
        .project-menu {
            position: fixed;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 4px;
            min-width: 160px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.4);
            z-index: 10000;
            display: none;
        }
        .project-menu.open { display: block; }
        .project-menu .chat-menu-item { color: var(--text-primary); }

        .sidebar-footer {
            padding: 12px 16px;
            border-top: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .footer-btn {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 10px;
            border: none;
            background: transparent;
            color: var(--text-muted);
            font-size: 13px;
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.15s ease;
        }

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

        .theme-toggle {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid var(--border);
            background: transparent;
            color: var(--text-muted);
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .theme-toggle:hover {
            border-color: var(--text-secondary);
            color: var(--text-primary);
        }

        /* Main Content */
        .main {
            flex: 1;
            display: flex;
            flex-direction: column;
            min-width: 0;
            background: var(--bg-primary);
        }

        .main-header {
            height: 56px;
            padding: 0 20px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: var(--bg-secondary);
            border-bottom: 1px solid var(--border);
        }

        .header-nav {
            display: flex;
            gap: 4px;
            flex: 1 1 auto;
            min-width: 0;
            overflow-x: auto;
            overflow-y: hidden;
            scrollbar-width: thin;
            -ms-overflow-style: auto;
            -webkit-overflow-scrolling: touch;
            white-space: nowrap;
            align-items: center;
            max-width: calc(100vw - 350px);
            scroll-snap-type: x proximity;
        }
        .header-nav::-webkit-scrollbar {
            height: 4px;
        }
        .header-nav::-webkit-scrollbar-thumb {
            background: var(--border-hover);
            border-radius: 2px;
        }
        .header-nav::-webkit-scrollbar-track {
            background: transparent;
        }
        .header-nav .nav-item {
            scroll-snap-align: start;
        }

        .nav-item {
            padding: 6px 14px;
            border: none;
            background: transparent;
            color: var(--text-muted);
            font-size: 13px;
            font-weight: 450;
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.15s ease;
            position: relative;
            flex-shrink: 0;
            white-space: nowrap;
        }

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

        .nav-item.active {
            color: var(--text-primary);
            background: transparent;
        }

        .nav-item.active::after {
            content: '';
            position: absolute;
            left: 12px;
            right: 12px;
            bottom: -6px;
            height: 2px;
            background: var(--text-primary);
            border-radius: 2px;
        }

        .nav-item-add {
            width: 28px;
            height: 28px;
            padding: 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            border-radius: 6px;
            flex-shrink: 0;
            border: 1px dashed var(--border);
        }

        .nav-item-add:hover {
            color: var(--text-primary);
            border-color: var(--border-hover);
            background: var(--bg-tertiary);
        }

        .nav-item-add svg {
            width: 14px;
            height: 14px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
        }

        .nav-item-dot {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin-right: 6px;
            vertical-align: middle;
            background: #555;
        }

        /* Right Sidebar - Tools */
        .right-sidebar {
            width: 280px;
            background: var(--bg-secondary);
            border-left: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            transition: all 0.3s ease;
            overflow: hidden;
        }

        .right-sidebar.hidden {
            width: 0;
            border-left: none;
            opacity: 0;
            visibility: hidden;
        }

        /* Overlay behind the tools panel on mobile (click to close). */
        .right-sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999;
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        /* Mobile: slide in from the right as an overlay drawer. */
        @media (max-width: 768px) {
            .right-sidebar {
                position: fixed;
                top: 0;
                right: 0;
                height: 100vh;
                width: 280px;
                max-width: 85vw;
                background: var(--bg-primary);
                border-left: 1px solid var(--border);
                z-index: 1000;
                transform: translateX(0);
                transition: transform 0.3s ease;
                opacity: 1;
                visibility: visible;
                overflow-y: auto;
            }
            .right-sidebar.hidden {
                /* Keep visible in layout so transition animates out. */
                width: 280px;
                max-width: 85vw;
                transform: translateX(100%);
                opacity: 1;
                visibility: visible;
                border-left: 1px solid var(--border);
                pointer-events: none;
            }
            .right-sidebar-overlay.active {
                display: block;
                opacity: 1;
            }
        }

        .right-sidebar-header {
            padding: 16px;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .right-sidebar-title {
            font-size: 13px;
            font-weight: 500;
            color: var(--text-primary);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .right-sidebar-toggle {
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.15s ease;
        }

        .right-sidebar-toggle:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .tools-section {
            padding: 12px 0;
            border-bottom: 1px solid var(--border);
        }

        .tools-section-title {
            padding: 0 16px 8px;
            font-size: 11px;
            font-weight: 500;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .tool-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 16px;
            cursor: pointer;
            transition: all 0.15s ease;
            color: var(--text-secondary);
            font-size: 13px;
        }

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

        .tool-item.active {
            background: var(--bg-tertiary);
            color: var(--text-primary);
            border-left: 2px solid var(--text-primary);
        }

        .tool-icon {
            width: 18px;
            height: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* SSH panel */
        .ssh-section .tools-section-title {
            padding-bottom: 10px;
        }

        .ssh-list {
            display: flex;
            flex-direction: column;
            gap: 2px;
            padding: 0 8px;
        }

        .ssh-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 10px;
            border-radius: 8px;
            cursor: default;
            transition: background 0.15s ease;
        }

        .ssh-item:hover {
            background: var(--bg-tertiary);
        }

        .ssh-status {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #555;
            flex-shrink: 0;
        }

        .ssh-status.active {
            background: #22c55e;
            box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
        }

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

        .ssh-name {
            font-size: 13px;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            line-height: 1.3;
        }

        .ssh-host {
            font-size: 11px;
            color: var(--text-muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .ssh-remove,
        .ssh-edit {
            width: 24px;
            height: 24px;
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 5px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            opacity: 0;
            transition: all 0.15s ease;
        }
        .ssh-item:hover .ssh-edit { opacity: 1; }
        .ssh-edit:hover { background: var(--bg-tertiary); color: var(--text-primary); }
        .ssh-edit svg { width: 14px; height: 14px; }

        .ssh-item:hover .ssh-remove {
            opacity: 1;
        }

        .ssh-remove:hover {
            background: rgba(220, 38, 38, 0.15);
            color: #f87171;
        }

        .ssh-remove svg {
            width: 14px;
            height: 14px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
        }

        .ssh-empty {
            padding: 12px 10px;
            color: var(--text-muted);
            font-size: 12px;
        }

        .ssh-add-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 6px;
            width: calc(100% - 16px);
            margin: 10px 8px 0;
            padding: 9px 12px;
            background: transparent;
            border: 1px dashed var(--border);
            border-radius: 8px;
            color: var(--text-secondary);
            font-size: 12px;
            cursor: pointer;
            font-family: inherit;
            transition: all 0.15s ease;
        }

        .ssh-add-btn:hover {
            border-color: var(--border-hover);
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

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

        /* SSH modal buttons row */
        .ssh-modal-actions {
            display: flex;
            gap: 10px;
            margin-top: 16px;
        }

        .ssh-modal-actions .auth-btn {
            margin-top: 0;
        }

        .ssh-modal-actions .auth-btn.secondary {
            background: transparent;
            color: var(--text-primary);
            border: 1px solid var(--border);
        }

        .ssh-modal-actions .auth-btn.secondary:hover {
            background: var(--bg-tertiary);
            opacity: 1;
        }

        .ssh-modal-label {
            display: block;
            font-size: 11px;
            letter-spacing: 0.5px;
            color: var(--text-muted);
            margin: 4px 0 6px;
            text-transform: uppercase;
        }

        .move-to-list {
            display: flex;
            flex-direction: column;
            gap: 2px;
            max-height: 320px;
            overflow-y: auto;
            margin: 4px 0 0;
        }

        .move-to-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 8px;
            cursor: pointer;
            color: var(--text-primary);
            font-size: 14px;
            background: var(--bg-tertiary);
            border: 1px solid transparent;
            transition: border-color 0.15s ease;
        }

        .move-to-item:hover {
            border-color: var(--border-hover);
        }

        .move-to-item.current {
            opacity: 0.55;
            cursor: default;
        }

        .move-to-item.current:hover {
            border-color: transparent;
        }

        .move-to-item .dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            flex-shrink: 0;
        }

        .move-to-item .badge {
            margin-left: auto;
            font-size: 11px;
            color: var(--text-muted);
        }

        /* Storage Page */
        .storage-toolbar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 16px;
            padding: 16px 0;
            flex-wrap: wrap;
        }

        .storage-filter-group {
            display: inline-flex;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 3px;
            gap: 2px;
        }

        .storage-filter-btn {
            background: transparent;
            border: none;
            color: var(--text-muted);
            padding: 6px 14px;
            font-size: 12px;
            letter-spacing: 0.5px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.15s ease;
            font-family: inherit;
        }

        .storage-filter-btn:hover {
            color: var(--text-primary);
        }

        .storage-filter-btn.active {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .storage-toolbar-right {
            display: inline-flex;
            align-items: center;
            gap: 10px;
        }

        .storage-sort-select {
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text-primary);
            padding: 7px 30px 7px 12px;
            font-size: 12px;
            cursor: pointer;
            font-family: inherit;
            appearance: none;
            -webkit-appearance: none;
            background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
            background-repeat: no-repeat;
            background-position: right 10px center;
        }

        .storage-sort-select:hover {
            border-color: var(--border-hover);
        }

        .storage-view-toggle {
            display: inline-flex;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 3px;
            gap: 2px;
        }

        .storage-view-btn {
            background: transparent;
            border: none;
            width: 28px;
            height: 28px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 5px;
            transition: all 0.15s ease;
        }

        .storage-view-btn:hover {
            color: var(--text-primary);
        }

        .storage-view-btn.active {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .storage-view-btn svg {
            width: 14px;
            height: 14px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
        }

        /* Windows Explorer style storage grid */
        .storage-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(120px, 130px));
            gap: 8px;
            padding: 8px 0 20px;
            justify-content: start;
        }

        @media (max-width: 768px) {
            .storage-grid {
                grid-template-columns: repeat(auto-fill, minmax(100px, 110px));
                gap: 6px;
            }
        }

        .storage-grid.list-view {
            grid-template-columns: 1fr;
            gap: 0;
        }

        .storage-item {
            position: relative;
            width: auto;
            height: 140px;
            background: transparent;
            border: 1px solid transparent;
            border-radius: 6px;
            cursor: pointer;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 6px 4px;
            gap: 4px;
            transition: background 0.12s ease, border-color 0.12s ease;
            overflow: hidden;
        }

        .storage-item:hover {
            background: var(--bg-tertiary);
            border-color: var(--border);
        }

        /* Thumbnail box — 100x100 centered, applies to both image and doc */
        .storage-item .storage-thumb-box {
            width: 100px;
            height: 100px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 4px;
            background: var(--bg-secondary);
            overflow: hidden;
            flex-shrink: 0;
        }

        .storage-item .storage-thumb {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        /* Doc icon inside thumb-box */
        .storage-icon {
            width: 64px;
            height: 64px;
            border-radius: 6px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #fff;
            flex-shrink: 0;
        }

        .storage-icon svg {
            width: 28px;
            height: 28px;
        }

        .storage-icon.type-pdf { background: #dc2626; }
        .storage-icon.type-docx { background: #2563eb; }
        .storage-icon.type-xlsx { background: #16a34a; }
        .storage-icon.type-code { background: #7c3aed; }
        .storage-icon.type-archive { background: #d97706; }
        .storage-icon.type-default { background: var(--bg-tertiary); color: var(--text-secondary); }

        .storage-item .storage-info {
            width: 100%;
            min-width: 0;
            text-align: center;
        }

        .storage-name {
            font-size: 11px;
            line-height: 1.25;
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 108px;
            margin: 0 auto;
        }

        .storage-meta {
            display: none;
        }

        /* Hover action buttons */
        .storage-actions {
            position: absolute;
            top: 4px;
            right: 4px;
            display: flex;
            gap: 2px;
            opacity: 0;
            transition: opacity 0.12s ease;
            z-index: 2;
        }

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

        .storage-action-btn {
            width: 24px;
            height: 24px;
            border-radius: 4px;
            background: rgba(0, 0, 0, 0.65);
            border: 1px solid rgba(255, 255, 255, 0.12);
            color: #fff;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
            transition: background 0.12s ease;
            padding: 0;
        }

        .storage-action-btn:hover {
            background: rgba(0, 0, 0, 0.9);
        }

        .storage-action-btn.danger:hover {
            background: #dc2626;
        }

        .storage-action-btn svg {
            width: 12px;
            height: 12px;
            stroke: currentColor;
            fill: none;
            stroke-width: 2;
        }

        /* List view — Windows details style, 36px rows */
        .storage-grid.list-view .storage-item {
            width: auto;
            height: 40px;
            flex-direction: row;
            align-items: center;
            padding: 0 12px;
            gap: 10px;
            border-radius: 0;
            border-top: none;
            border-left: none;
            border-right: none;
            border-bottom: 1px solid transparent;
        }

        .storage-grid.list-view .storage-item:hover {
            background: var(--bg-tertiary);
            border-bottom-color: var(--border);
        }

        .storage-grid.list-view .storage-item .storage-thumb-box {
            width: 32px;
            height: 32px;
            border-radius: 4px;
        }

        .storage-grid.list-view .storage-item .storage-icon {
            width: 32px;
            height: 32px;
            border-radius: 4px;
        }

        .storage-grid.list-view .storage-item .storage-icon svg {
            width: 16px;
            height: 16px;
        }

        .storage-grid.list-view .storage-item .storage-info {
            flex: 1;
            min-width: 0;
            text-align: left;
            display: flex;
            align-items: center;
            gap: 12px;
            overflow: hidden;
        }

        .storage-grid.list-view .storage-item .storage-name {
            flex: 1;
            font-size: 12px;
            max-width: none;
            text-align: left;
            margin: 0;
        }

        .storage-grid.list-view .storage-item .storage-meta {
            display: block;
            color: var(--text-muted);
            font-size: 11px;
            white-space: nowrap;
            flex-shrink: 0;
        }

        .storage-grid.list-view .storage-actions {
            position: static;
            opacity: 1;
            margin-left: 4px;
        }

        .storage-grid.list-view .storage-action-btn {
            background: transparent;
            border-color: transparent;
            color: var(--text-muted);
            width: 24px;
            height: 24px;
        }

        .storage-grid.list-view .storage-action-btn:hover {
            background: var(--bg-tertiary);
            color: var(--text-primary);
        }

        .storage-grid.list-view .storage-action-btn.danger:hover {
            background: #dc2626;
            color: #fff;
        }

        .storage-empty {
            color: var(--text-muted);
            font-size: 13px;
            padding: 24px 0;
            text-align: center;
        }

        .lightbox-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, 0.85);
            z-index: 10000;
            display: none;
            align-items: center;
            justify-content: center;
            cursor: zoom-out;
            padding: 20px;
        }

        .lightbox-overlay.open {
            display: flex;
        }

        .lightbox-img {
            max-width: 90vw;
            max-height: 90vh;
            border-radius: 8px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
            cursor: default;
            object-fit: contain;
        }

        .lightbox-close {
            position: fixed;
            top: 20px;
            right: 20px;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            color: #fff;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 22px;
            line-height: 1;
            z-index: 10001;
            transition: background 0.15s;
            padding: 0;
        }

        .lightbox-close:hover {
            background: rgba(255, 255, 255, 0.2);
        }

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

        .model-selector {
            position: relative;
        }

        .model-selector-inline {
            position: relative;
            display: flex;
            align-items: center;
            flex-shrink: 0;
        }

        .model-btn-inline {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            background: transparent;
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text-secondary);
            font-size: 12px;
            font-weight: 450;
            cursor: pointer;
            transition: all 0.15s ease;
            white-space: nowrap;
        }

        .model-btn-inline:hover {
            border-color: var(--border-hover);
            color: var(--text-primary);
            background: var(--bg-tertiary);
        }

        .model-btn {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px 12px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text-primary);
            font-size: 13px;
            font-weight: 450;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .model-btn:hover {
            border-color: var(--border-hover);
        }

        .model-btn.active {
            background: var(--text-primary);
            color: var(--bg-primary);
            border-color: var(--text-primary);
        }

        .model-dropdown {
            position: absolute;
            bottom: calc(100% + 6px);
            right: 0;
            width: 220px;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 6px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.3);
            opacity: 0;
            visibility: hidden;
            transform: translateY(8px);
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 100;
        }

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

        .model-option {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .model-option:hover {
            background: var(--bg-tertiary);
        }

        .model-option.selected .model-radio {
            border-color: var(--text-primary);
            background: var(--text-primary);
        }

        .model-radio {
            width: 14px;
            height: 14px;
            border: 1.5px solid var(--border-hover);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
            transition: all 0.15s ease;
        }

        .model-radio::after {
            content: '';
            width: 5px;
            height: 5px;
            background: var(--bg-primary);
            border-radius: 50%;
            opacity: 0;
            transition: opacity 0.15s ease;
        }

        .model-option.selected .model-radio::after {
            opacity: 1;
        }

        .model-info {
            flex: 1;
        }

        .model-name {
            font-size: 13px;
            font-weight: 450;
            color: var(--text-primary);
        }

        .model-desc {
            font-size: 11px;
            color: var(--text-muted);
            margin-top: 1px;
        }

        .user-avatar {
            width: 32px;
            height: 32px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-primary);
            font-weight: 500;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .user-avatar:hover {
            border-color: var(--border-hover);
        }

        /* Chat Area */
        .chat-area {
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
        }

        /* Welcome Screen */
        .welcome-screen {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 40px;
            overflow-y: auto;
        }

        .welcome-logo {
            width: 64px;
            height: 64px;
            position: relative;
            margin-bottom: 24px;
        }

        .welcome-logo-node {
            position: absolute;
            border-radius: 50%;
            background: var(--text-primary);
            animation: nodePulse 2.5s ease-in-out infinite;
        }

        .welcome-logo-node:nth-child(1) {
            width: 16px;
            height: 16px;
            top: 8px;
            left: 8px;
        }

        .welcome-logo-node:nth-child(2) {
            width: 12px;
            height: 12px;
            top: 8px;
            right: 8px;
            animation-delay: 0.4s;
        }

        .welcome-logo-node:nth-child(3) {
            width: 10px;
            height: 10px;
            bottom: 8px;
            left: 50%;
            margin-left: -5px;
            animation-delay: 0.8s;
        }

        .welcome-logo-line {
            position: absolute;
            height: 2px;
            background: var(--text-primary);
            transform-origin: left center;
        }

        .welcome-logo-line:nth-child(4) {
            width: 34.06px;
            top: 15px;
            left: 16px;
            transform: rotate(0deg);
            animation: lineGlow 2.5s ease-in-out infinite;
        }

        .welcome-logo-line:nth-child(5) {
            width: 34px;
            top: 15px;
            left: 16px;
            transform: rotate(65deg);
            animation: lineGlow 2.5s ease-in-out infinite 0.4s;
        }

        .welcome-logo-line:nth-child(6) { display: none;
            width: 24px;
            top: 22px;
            left: 14px;
            transform: rotate(-60deg);
            animation: lineGlow 2.5s ease-in-out infinite 0.8s;
        }

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

        .welcome-title {
            font-size: 28px;
            font-weight: 300;
            letter-spacing: 8px;
            margin-bottom: 8px;
            color: var(--text-primary);
            text-transform: uppercase;
            opacity: 0;
            animation: fadeUp 0.6s ease-out 0.2s forwards;
        }

        .welcome-subtitle {
            font-size: 14px;
            color: var(--text-muted);
            margin-bottom: 48px;
            opacity: 0;
            animation: fadeUp 0.6s ease-out 0.3s forwards;
        }

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

        .quick-actions {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 12px;
            max-width: 640px;
            width: 100%;
        }

        .quick-action {
            padding: 16px;
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            text-align: left;
            opacity: 0;
            animation: fadeUp 0.5s ease-out forwards;
        }

        .quick-action:nth-child(1) { animation-delay: 0.4s; }
        .quick-action:nth-child(2) { animation-delay: 0.45s; }
        .quick-action:nth-child(3) { animation-delay: 0.5s; }
        .quick-action:nth-child(4) { animation-delay: 0.55s; }
        .quick-action:nth-child(5) { animation-delay: 0.6s; }
        .quick-action:nth-child(6) { animation-delay: 0.65s; }

        .quick-action:hover {
            border-color: var(--border-hover);
            background: var(--bg-tertiary);
            transform: translateY(-2px);
        }

        .quick-action-icon {
            width: 32px;
            height: 32px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 12px;
            color: var(--text-secondary);
            transition: all 0.2s ease;
        }

        .quick-action:hover .quick-action-icon {
            border-color: var(--text-muted);
            color: var(--text-primary);
        }

        .quick-action-title {
            font-size: 13px;
            font-weight: 500;
            color: var(--text-primary);
            margin-bottom: 3px;
        }

        .quick-action-desc {
            font-size: 12px;
            color: var(--text-muted);
            line-height: 1.4;
        }

        /* Messages */
        .messages-container {
            flex: 1;
            overflow-y: auto;
            padding: 24px;
            scroll-behavior: smooth;
        }



        .messages {
            max-width: 720px;
            margin: 0 auto;
            width: 100%;
            display: flex;
            flex-direction: column;
            gap: 0;
        }

        .message {
            display: flex;
            gap: 14px;
            animation: messageAppear 0.4s cubic-bezier(0.4, 0, 0.2, 1);
            padding: 20px 0;
            border-bottom: 1px solid var(--border);
        }

        .message:last-child {
            border-bottom: none;
        }

        /* Message Truncation - Perplexity-style */
        .message.truncated {
            display: none !important;
        }

        .message.truncated.revealed {
            display: flex !important;
            animation: fadeIn 0.3s ease;
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(-8px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .truncation-banner {
            text-align: center;
            padding: 12px;
            margin-bottom: 16px;
            cursor: pointer;
            border-radius: 8px;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            color: var(--text-muted);
            font-size: 13px;
            transition: all 0.2s ease;
            user-select: none;
            letter-spacing: 0.5px;
        }

        .truncation-banner:hover {
            background: var(--bg-tertiary);
            color: var(--text-secondary);
            border-color: var(--border-hover);
        }

        .truncation-banner .count {
            color: var(--text-secondary);
            font-weight: 500;
        }

        /* Loading Skeletons */
        .skeleton {
            background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
            background-size: 200% 100%;
            animation: shimmer 1.5s infinite;
            border-radius: 4px;
        }

        .skeleton-text {
            height: 16px;
            margin-bottom: 8px;
            border-radius: 4px;
        }

        .skeleton-text.short { width: 60%; }
        .skeleton-text.medium { width: 80%; }
        .skeleton-title {
            height: 20px;
            width: 40%;
            margin-bottom: 12px;
        }

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

        .skeleton-chat-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 12px;
            opacity: 0.6;
        }

        .skeleton-icon {
            width: 20px;
            height: 20px;
            border-radius: 50%;
            flex-shrink: 0;
        }

        .skeleton-line {
            height: 14px;
            border-radius: 4px;
            flex: 1;
        }







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

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

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

        .message-avatar {
            display: none;
        }

        .message-sender {
            font-size: 10px;
            font-weight: 300;
            color: var(--text-muted);
            letter-spacing: 3px;
            margin-bottom: 6px;
            text-transform: uppercase;
        }

        .message-content {
            font-size: 14px;
            line-height: 1.7;
            max-width: 85%;
            font-weight: 300;
        }

        .message-content img {
            max-width: 100%;
            height: auto;
            border-radius: 8px;
            margin: 8px 0;
        }

        .message-content.user {
            color: var(--text-primary);
            text-align: right;
        }

        .message-content.assistant {
            color: var(--text-primary);
        }

        .message-actions {
            display: none;
        }

        /* DNA Helix Thinking Indicator - Horizontal */
        .dna-helix {
            width: 44px;
            height: 14px;
            position: relative;
            display: inline-block;
            animation-play-state: running;
        }

        /* DNA stops spinning when response is complete */
        .message.assistant:not(.current-response) .dna-helix,
        .dna-helix.paused {
            animation-play-state: paused;
        }
        .dna-helix .pair {
            position: absolute;
            width: 2px;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
            animation: dnaRotate 1.6s ease-in-out infinite;
        }
        .dna-helix .pair::before,
        .dna-helix .pair::after {
            content: '';
            width: 3px;
            height: 3px;
            border-radius: 50%;
            background: var(--text-secondary);
            flex-shrink: 0;
        }
        .dna-helix .pair .bridge {
            width: 1.5px;
            flex: 1;
            background: var(--border-hover);
            margin: 1px 0;
        }
        .dna-helix .pair:nth-child(1) { left: 0px; animation-delay: 0s; }
        .dna-helix .pair:nth-child(2) { left: 6px; animation-delay: -0.2s; }
        .dna-helix .pair:nth-child(3) { left: 12px; animation-delay: -0.4s; }
        .dna-helix .pair:nth-child(4) { left: 18px; animation-delay: -0.6s; }
        .dna-helix .pair:nth-child(5) { left: 24px; animation-delay: -0.8s; }
        .dna-helix .pair:nth-child(6) { left: 30px; animation-delay: -1.0s; }
        .dna-helix .pair:nth-child(7) { left: 36px; animation-delay: -1.2s; }
        .dna-helix .pair:nth-child(8) { left: 42px; animation-delay: -1.4s; }

        @keyframes dnaRotate {
            0%, 100% { transform: rotateX(0deg); opacity: 1; }
            50% { transform: rotateX(180deg); opacity: 0.5; }
        }

        .thinking-indicator {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-top: 8px;
        }

        .thinking-text {
            font-size: 13px;
            color: var(--text-muted);
        }

        /* Input Area */
        .input-area {
            padding: 16px 20px 20px;
            background: var(--bg-secondary);
            border-top: none !important;
            position: sticky;
            bottom: 0;
            z-index: 10;
            flex-shrink: 0;
            transition: transform 0.2s ease-out;
        }

        #messagesContainer {
            transition: padding-bottom 0.2s ease-out;
        }

        .input-container {
            max-width: 720px;
            margin: 0 auto;
            position: relative;
        }

        .attachments-preview {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin-bottom: 10px;
        }

        .attachment-item {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 5px 10px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: 5px;
            font-size: 12px;
            color: var(--text-secondary);
            animation: slideIn 0.2s ease-out;
        }

        .attachment-remove {
            width: 16px;
            height: 16px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 3px;
            transition: all 0.15s ease;
        }

        .attachment-remove:hover {
            background: var(--border);
            color: var(--text-primary);
        }

        .input-wrapper {
            display: flex;
            align-items: flex-end;
            gap: 10px;
            padding: 10px 12px;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: 12px;
            transition: all 0.2s ease;
            position: relative;
        }

        .input-wrapper:focus-within {
            border-color: var(--border-hover);
        }

        .input-actions {
            display: flex;
            gap: 4px;
        }

        .input-action {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: transparent;
            color: var(--text-muted);
            cursor: pointer;
            border-radius: 6px;
            transition: all 0.15s ease;
            flex-shrink: 0;
        }

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

        .message-input {
            flex: 1;
            min-height: 20px;
            max-height: 160px;
            padding: 6px 0;
            background: transparent;
            border: none;
            color: var(--text-primary);
            font-size: 14px;
            line-height: 1.5;
            resize: none;
            outline: none;
            font-family: inherit;
        }

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

        .send-btn {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            background: var(--text-primary);
            color: var(--bg-primary);
            cursor: pointer;
            border-radius: 8px;
            transition: all 0.2s ease;
            flex-shrink: 0;
        }

        .send-btn:hover:not(:disabled) {
            transform: scale(1.05);
        }

        .send-btn:disabled {
            opacity: 0.3;
            cursor: not-allowed;
        }

        .input-hint {
            text-align: center;
            margin-top: 10px;
            font-size: 11px;
            color: var(--text-muted);
        }

        .input-hint kbd {
            padding: 2px 5px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: 4px;
            font-family: inherit;
            font-size: 10px;
        }

        /* Upload Overlay */
        .upload-overlay {
            position: absolute;
            inset: 0;
            background: var(--bg-tertiary);
            border: 1px dashed var(--border-hover);
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            visibility: hidden;
            transition: all 0.2s ease;
            pointer-events: none;
        }

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

        .upload-text {
            font-size: 13px;
            color: var(--text-secondary);
        }

        /* Empty State */
        .empty-chats {
            padding: 40px 20px;
            text-align: center;
            color: var(--text-muted);
            font-size: 13px;
        }

        /* Icons */
        .icon {
            width: 16px;
            height: 16px;
            stroke-width: 1.5;
            stroke-linecap: round;
            stroke-linejoin: round;
            fill: none;
            stroke: currentColor;
        }

        .icon-lg {
            width: 18px;
            height: 18px;
        }

        /* File Input */
        .file-input {
            display: none;
        }

        /* Skeleton Loaders */
        .skeleton {
            background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
            background-size: 200% 100%;
            animation: skeletonPulse 1.5s ease-in-out infinite;
            border-radius: 4px;
        }

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

        .skeleton-chat-item {
            height: 40px;
            margin-bottom: 8px;
            border-radius: 6px;
        }

        .skeleton-message {
            height: 60px;
            margin-bottom: 16px;
            border-radius: 12px;
        }

        .skeleton-text {
            height: 14px;
            margin-bottom: 8px;
        }

        .skeleton-text.short {
            width: 60%;
        }

        /* Toast Notifications */
        .toast-container {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 1000;
            display: flex;
            flex-direction: column;
            gap: 8px;
            pointer-events: none;
        }

        .toast {
            pointer-events: auto;
        }

        .toast {
            padding: 12px 16px;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: 8px;
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 280px;
            animation: toastSlide 0.3s ease-out;
            box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        }

        @keyframes toastSlide {
            from {
                transform: translateX(100%);
                opacity: 0;
            }
            to {
                transform: translateX(0);
                opacity: 1;
            }
        }

        .toast.success {
            border-left: 3px solid #22c55e;
        }

        .toast.error {
            border-left: 3px solid #ef4444;
        }

        .toast.warning {
            border-left: 3px solid #f59e0b;
        }

        .toast.info {
            border-left: 3px solid #3b82f6;
        }

        .toast.info .toast-icon {
            color: #3b82f6;
        }

        .toast-icon {
            width: 20px;
            height: 20px;
            flex-shrink: 0;
        }

        .toast.success .toast-icon {
            color: #22c55e;
        }

        .toast.error .toast-icon {
            color: #ef4444;
        }

        .toast.warning .toast-icon {
            color: #f59e0b;
        }

        .toast-message {
            flex: 1;
            font-size: 13px;
            color: var(--text-primary);
        }

        .toast-close {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .toast-close:hover {
            color: var(--text-primary);
        }

        /* Loading Overlay */
        .loading-overlay {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.5);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 999;
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transition: all 0.2s ease;
        }

        .loading-overlay.active {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        .loading-spinner {
            width: 40px;
            height: 40px;
            border: 3px solid var(--border);
            border-top-color: var(--text-primary);
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

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

        /* Auth Modal */
        .auth-modal {
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.7);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transition: all 0.3s ease;
        }

        .auth-modal.active {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }

        .auth-card {
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 16px;
            padding: 32px;
            width: 100%;
            max-width: 400px;
            animation: authSlide 0.3s ease-out;
        }

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

        .auth-title {
            font-size: 20px;
            font-weight: 500;
            margin-bottom: 24px;
            text-align: center;
        }

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

        .auth-input:focus {
            border-color: var(--border-hover);
        }

        .auth-btn {
            width: 100%;
            padding: 12px;
            background: var(--text-primary);
            color: var(--bg-primary);
            border: none;
            border-radius: 8px;
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
            margin-top: 8px;
        }

        .auth-btn:hover {
            opacity: 0.9;
        }

        .auth-btn:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        /* Settings & Admin Pages */
        .page-content {
            display: none;
            flex: 1;
            overflow-y: auto;
            padding: 32px 40px;
        }

        .page-content.active {
            display: block;
        }

        .page-header {
            margin-bottom: 32px;
        }

        .page-title {
            font-size: 24px;
            font-weight: 500;
            color: var(--text-primary);
            margin-bottom: 8px;
        }

        .page-subtitle {
            font-size: 14px;
            color: var(--text-muted);
            font-weight: 300;
        }

        /* Settings Menu */
        .settings-container {
            display: flex;
            gap: 40px;
            max-width: 900px;
        }

        .settings-sidebar {
            width: 240px;
            flex-shrink: 0;
        }

        .settings-menu-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px 16px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.15s ease;
            color: var(--text-secondary);
            font-size: 14px;
            font-weight: 400;
            margin-bottom: 2px;
        }

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

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

        .settings-menu-item svg {
            width: 18px;
            height: 18px;
        }

        .settings-content {
            flex: 1;
        }

        .settings-section {
            display: none;
        }

        .settings-section.active {
            display: block;
        }

        .settings-card {
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 24px;
            margin-bottom: 16px;
        }

        .settings-card-title {
            font-size: 16px;
            font-weight: 500;
            color: var(--text-primary);
            margin-bottom: 16px;
        }

        .settings-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 0;
            border-bottom: 1px solid var(--border);
        }

        .settings-row:last-child {
            border-bottom: none;
        }

        .settings-label {
            font-size: 14px;
            color: var(--text-primary);
        }

        .settings-value {
            font-size: 14px;
            color: var(--text-muted);
        }

        .settings-badge {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 10px;
            background: var(--bg-tertiary);
            border-radius: 4px;
            font-size: 12px;
            color: var(--text-secondary);
        }

        .settings-badge.pro {
            background: rgba(99, 102, 241, 0.15);
            color: #818cf8;
        }

        /* Admin Panel */
        .admin-stats {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 16px;
            margin-bottom: 32px;
        }

        .admin-stat-card {
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 20px 24px;
        }

        .admin-stat-value {
            font-size: 32px;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 4px;
        }

        .admin-stat-label {
            font-size: 12px;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .admin-table-container {
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 10px;
            overflow-x: auto;
            overflow-y: hidden;
        }

        .admin-table {
            width: 100%;
            border-collapse: collapse;
            table-layout: fixed;
            min-width: 820px;
            font-size: 13px;
        }

        .admin-table thead th {
            background: var(--bg-tertiary);
            font-size: 11px;
            font-weight: 500;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            text-align: left;
            padding: 10px 12px;
            border-bottom: 1px solid var(--border);
            white-space: nowrap;
        }

        .admin-table thead th.num,
        .admin-table tbody td.num {
            text-align: right;
            font-variant-numeric: tabular-nums;
        }

        .admin-table thead th.actions-col {
            text-align: right;
        }

        .admin-table tbody td {
            padding: 8px 12px;
            color: var(--text-primary);
            font-size: 13px;
            border-bottom: 1px solid var(--border);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            vertical-align: middle;
            height: 48px;
            line-height: 1.3;
        }

        .admin-table tbody tr:last-child td {
            border-bottom: none;
        }

        .admin-table tbody tr:hover {
            background: rgba(255, 255, 255, 0.025);
        }

        .admin-table td.email {
            color: var(--text-secondary);
        }

        .admin-table td.credits {
            font-size: 12px;
            color: var(--text-muted);
        }

        .admin-table td.actions {
            text-align: right;
        }

        .admin-table .actions-inline {
            display: inline-flex;
            gap: 6px;
            justify-content: flex-end;
            align-items: center;
        }

        .admin-role-select {
            padding: 4px 8px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border);
            border-radius: 5px;
            color: var(--text-primary);
            font-size: 12px;
            cursor: pointer;
            outline: none;
            max-width: 100%;
        }

        .admin-role-select:hover {
            border-color: var(--border-hover);
        }

        .admin-delete-btn {
            padding: 4px 10px;
            background: transparent;
            border: 1px solid var(--border);
            border-radius: 5px;
            color: var(--text-muted);
            font-size: 12px;
            cursor: pointer;
            transition: all 0.15s ease;
        }

        .admin-add-credits-btn {
            padding: 4px 8px;
            background: transparent;
            border: 1px solid var(--border);
            border-radius: 5px;
            color: var(--text-secondary);
            font-size: 11px;
            cursor: pointer;
            transition: all 0.15s ease;
            white-space: nowrap;
        }

        .admin-user-credits {
            font-size: 12px;
            color: var(--text-muted);
        }

        .admin-user-email-link {
            color: var(--text-secondary);
            cursor: pointer;
            text-decoration: none;
            border-bottom: 1px dotted var(--border-hover);
        }
        .admin-user-email-link:hover { color: var(--text-primary); }

        /* User detail page (admin → click email) */
        .user-detail-page {
            padding: 20px;
            max-width: 600px;
            margin: 0 auto;
            width: 100%;
        }
        @media (max-width: 768px) {
            .user-detail-page { padding: 16px; max-width: 100%; }
        }
        .user-detail-page-header {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 18px;
            padding-bottom: 14px;
            border-bottom: 1px solid var(--border);
        }
        .user-detail-back {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 10px;
            background: transparent;
            border: 1px solid var(--border);
            border-radius: 6px;
            color: var(--text-secondary);
            font-size: 13px;
            cursor: pointer;
            font-family: inherit;
        }
        .user-detail-back:hover { background: var(--bg-tertiary); color: var(--text-primary); }
        .user-detail-back svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }
        .user-detail-titles { flex: 1; min-width: 0; }
        .user-detail-name { font-size: 18px; font-weight: 500; color: var(--text-primary); line-height: 1.2; }
        .user-detail-email { font-size: 13px; color: var(--text-muted); margin-top: 2px; word-break: break-all; }
        .user-detail-body { display: flex; flex-direction: column; gap: 18px; }
        .user-detail-meta { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 13px; }
        .user-detail-meta .meta-label { color: var(--text-muted); text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; margin-right: 6px; }
        .user-detail-meta .meta-value { color: var(--text-primary); font-family: 'Fira Code', monospace; font-size: 12px; }
        .user-detail-section {
            background: var(--bg-secondary);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 12px 14px;
        }
        .user-detail-section h3 {
            font-size: 12px; letter-spacing: 0.5px; text-transform: uppercase;
            color: var(--text-muted); margin: 0 0 10px; font-weight: 500;
        }
        .credit-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
        .credit-label { width: 70px; font-size: 12px; color: var(--text-secondary); }
        .credit-bar-wrap { flex: 1; }
        .credit-bar { height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
        .credit-bar-fill { height: 100%; background: linear-gradient(90deg, #22c55e, #16a34a); width: 0%; transition: width 0.3s ease; }
        .credit-bar-fill.warn { background: linear-gradient(90deg, #eab308, #ca8a04); }
        .credit-bar-fill.crit { background: linear-gradient(90deg, #ef4444, #dc2626); }
        .credit-bar-text { font-size: 11px; color: var(--text-muted); font-family: 'Fira Code', monospace; }
        .limits-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 12px; color: var(--text-secondary); }
        @media (max-width: 500px) { .limits-grid { grid-template-columns: 1fr; } }
        .limits-grid label { display: block; }
        .limits-grid .auth-input { margin-top: 4px; margin-bottom: 0; }
        .ud-stats-table { width: 100%; border-collapse: collapse; font-size: 12px; }
        .ud-stats-table th, .ud-stats-table td {
            padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border);
        }
        .ud-stats-table th { color: var(--text-muted); font-weight: 500; text-transform: uppercase; font-size: 10px; letter-spacing: 0.5px; }
        .user-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
        .user-detail-actions .auth-btn { margin-top: 0; width: auto; flex: 1 1 auto; min-width: 140px; }

        /* Mobile adaptation for the user-detail page */
        @media (max-width: 768px) {
            .user-detail-body .stats-grid {
                grid-template-columns: 1fr 1fr;
                gap: 8px;
            }
            .user-detail-body .stats-grid .stat-value { font-size: 16px; }
            .user-detail-body .stats-grid .stat-label { font-size: 11px; }
            .user-detail-body .ud-stats-table {
                display: block;
                overflow-x: auto;
                font-size: 11px;
                white-space: nowrap;
            }
            .user-detail-actions .auth-btn { min-width: 120px; flex-basis: calc(50% - 4px); }
        }
        @media (max-width: 480px) {
            .user-detail-body .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
            .user-detail-body .stats-grid .stat-value { font-size: 15px; }
            .user-detail-actions .auth-btn { flex-basis: 100%; min-width: 0; }
        }

        .admin-add-credits-btn:hover {
            border-color: #22c55e;
            color: #22c55e;
        }

        .admin-delete-btn:hover {
            border-color: #ef4444;
            color: #ef4444;
        }

        .token-stats-card { background: var(--bg-secondary); border-radius: 12px; padding: 20px; margin-top: 24px; }
        .stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 12px; }
        .stat-item { text-align: center; }
        .stat-value { font-size: 24px; font-weight: 600; color: var(--text-primary); display: block; }
        .stat-label { font-size: 12px; color: var(--text-tertiary); text-transform: uppercase; }
        .token-table-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 10px; padding: 16px 0; margin-top: 16px; overflow: hidden; }
        .token-table-card h4 { padding: 0 16px 12px; margin: 0; font-size: 13px; font-weight: 500; color: var(--text-primary); text-transform: uppercase; letter-spacing: 0.5px; }
        .token-table-card table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
        .token-table-card th { text-align: left; padding: 8px 16px; border-bottom: 1px solid var(--border); border-top: 1px solid var(--border); background: var(--bg-tertiary); color: var(--text-muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
        .token-table-card th.num { text-align: right; }
        .token-table-card td { padding: 0 16px; height: 40px; border-bottom: 1px solid var(--border); color: var(--text-primary); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
        .token-table-card td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
        .token-table-card tbody tr:last-child td { border-bottom: none; }
        .token-table-card tbody tr:nth-child(odd) { background: rgba(255,255,255,0.02); }
        .token-table-card tbody tr:hover { background: rgba(255,255,255,0.04); }
        .model-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; flex-shrink: 0; vertical-align: middle; position: relative; top: -1px; }
        .model-dot.anthropic { background: #5b8ef0; }
        .model-dot.deepseek  { background: #3dbf7a; }
        .model-dot.moonshot  { background: #a855f7; }
        .model-dot.openai    { background: #f97316; }
        .provider-balances { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-top: 16px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
        .provider-balances h4 { margin: 0; font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0; }
        .balance-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-primary); }
        .balance-item .balance-val { font-weight: 500; font-variant-numeric: tabular-nums; }
        .limit-bar { width: 60px; height: 4px; background: var(--bg-tertiary); border-radius: 2px; display: inline-block; vertical-align: middle; }
        .limit-bar-fill { height: 100%; border-radius: 2px; background: #4a9; }
        .limit-bar-fill.warning { background: #e90; }
        .limit-bar-fill.danger { background: #e44; }

        /* User Profile Dropdown */
        .user-menu-dropdown {
            position: absolute;
            top: calc(100% + 8px);
            right: 0;
            width: 260px;
            background: var(--bg-elevated);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 8px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.4);
            opacity: 0;
            visibility: hidden;
            transform: translateY(-8px);
            transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 100;
        }

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

        .user-menu-header {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 12px;
            border-bottom: 1px solid var(--border);
            margin-bottom: 4px;
        }

        .user-menu-avatar {
            width: 40px;
            height: 40px;
            background: var(--bg-tertiary);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 500;
            font-size: 14px;
            color: var(--text-primary);
        }

        .user-menu-info {
            flex: 1;
        }

        .user-menu-name {
            font-size: 14px;
            font-weight: 500;
            color: var(--text-primary);
        }

        .user-menu-email {
            font-size: 12px;
            color: var(--text-muted);
        }

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

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

        .user-menu-item svg {
            width: 18px;
            height: 18px;
        }

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

        .user-menu-badge {
            margin-left: auto;
            font-size: 11px;
            color: var(--text-muted);
        }

        /* Plan Card */
        .plan-card {
            background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
            border: 1px solid rgba(99, 102, 241, 0.2);
            border-radius: 12px;
            padding: 24px;
            margin-bottom: 24px;
        }

        .plan-name {
            font-size: 20px;
            font-weight: 600;
            color: var(--text-primary);
            margin-bottom: 4px;
        }

        .plan-price {
            font-size: 14px;
            color: var(--text-muted);
            margin-bottom: 16px;
        }

        .plan-features {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .plan-feature {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 13px;
            color: var(--text-secondary);
        }

        .plan-feature svg {
            width: 16px;
            height: 16px;
            color: #22c55e;
        }

        /* Responsive */
        .mobile-menu-btn {
            display: none;
            background: none;
            border: none;
            color: var(--text-primary);
            cursor: pointer;
            padding: 8px;
            margin-right: 8px;
        }

        .sidebar-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0,0,0,0.5);
            z-index: 99;
        }

        .sidebar-overlay.active {
            display: block;
        }

        .tools-section-mobile-nav { display: none; }

        @media (max-width: 900px) {
            .tools-section-mobile-nav { display: block; }
        }

        @media (max-width: 900px) {
            .mobile-menu-btn {
                display: block;
            }

            .sidebar {
                position: fixed;
                left: 0;
                top: 0;
                bottom: 0;
                z-index: 100;
                transform: translateX(-100%);
            }

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

            .sidebar.open + .sidebar-overlay {
                display: block;
            }

            .quick-actions {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        /* iPhone Safe Area */
        @supports (padding-top: env(safe-area-inset-top)) {
            .sidebar {
                padding-top: env(safe-area-inset-top);
                padding-bottom: env(safe-area-inset-bottom);
            }
            
            .main-header {
                padding-top: env(safe-area-inset-top);
                height: calc(48px + env(safe-area-inset-top));
            }
            
            .input-area {
                padding-bottom: calc(20px + env(safe-area-inset-bottom));
            }
        }

        @media (max-width: 640px) {
            .quick-actions {
                grid-template-columns: 1fr;
            }

            .welcome-title {
                font-size: 26px;
            }

            .header-nav {
                gap: 2px;
            }
            .header-nav .nav-item {
                padding: 6px 10px;
                font-size: 12px;
            }

            /* Mobile input fixes */
            .messages-container {
                padding: 12px;
            }

            .message {
                padding: 12px 0;
                gap: 10px;
            }

            .message-content {
                font-size: 15px;
                line-height: 1.6;
            }

            .message-content.user {
                background: rgba(255, 255, 255, 0.05);
                border: 1px solid rgba(255, 255, 255, 0.07);
                border-radius: 14px;
                padding: 10px 14px;
            }

            .input-area {
                padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
            }

            .input-wrapper {
                padding: 10px 12px;
            }

            .model-selector-inline {
                display: none;
            }

            .message-input {
                font-size: 16px; /* Prevent iOS zoom */
                min-height: 32px;
            }

            .input-hint {
                display: none;
            }

            /* Welcome mode: logo pinned to visible viewport via JS (--vv-h) */
            .main.welcome-mode .chat-area {
                flex: 1 1 auto;
                padding-bottom: 0;
                overflow: hidden;
                position: relative;
            }
            .main.welcome-mode {
                justify-content: flex-start;
            }
            .main.welcome-mode .welcome-screen {
                position: fixed;
                left: 0;
                right: 0;
                transition: top 0.25s ease-out;
                top: calc(var(--vv-top, 0px) + (var(--vv-h, 100dvh) - env(keyboard-inset-height, 0px)) * 0.5 - 110px);
                padding: 20px;
                z-index: 1;
            }
            .main.welcome-mode .welcome-logo {
                margin-bottom: 16px;
            }
            .main.welcome-mode .input-area {
                padding-top: 0;
            }

            .main-header {
                padding: 0 12px;
                height: 48px;
            }

            .header-actions {
                gap: 6px;
            }

            .model-btn-inline {
                padding: 4px 10px;
                font-size: 11px;
            }

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

        @media (max-width: 768px) {
          .storage-header-btn {
            display: none !important;
          }
          .main-header {
            justify-content: flex-start !important;
            gap: 8px;
          }
          .header-nav {
            justify-content: flex-start !important;
            max-width: none !important;
            flex: 1 1 auto;
            margin-right: auto;
          }
          .header-actions {
            margin-left: auto;
            flex-shrink: 0;
          }
          .chat-input-area, .input-container, .chat-footer {
            position: fixed !important;
            /* env() follows the keyboard smoothly when VirtualKeyboard.overlaysContent
               is active (Chrome 94+). On other browsers env() resolves to 0px and
               interactive-widget=resizes-content handles it (close smooth, open snaps). */
            bottom: env(keyboard-inset-height, 0px) !important;
            left: 0;
            right: 0;
            z-index: 100;
            background: var(--bg-primary);
            will-change: bottom;
          }
          .messages-container, .chat-messages {
            padding-bottom: calc(80px + env(keyboard-inset-height, 0px)) !important;
          }
          .chat-input-area, .input-container, .chat-footer, .input-area {
            transition: bottom 0.25s ease-out, transform 0.25s ease-out;
          }
        }

        /* Auth tabs */
        .auth-tabs {
            display: flex;
            border-bottom: 1px solid var(--border);
            margin-bottom: 24px;
        }
        .auth-tab {
            flex: 1;
            padding: 10px;
            background: none;
            border: none;
            color: var(--text-secondary);
            font-size: 14px;
            cursor: pointer;
            border-bottom: 2px solid transparent;
            margin-bottom: -1px;
            transition: all 0.2s;
        }
        .auth-tab.active {
            color: var(--text-primary);
            border-bottom-color: var(--text-primary);
        }
        .auth-form { display: none; }
        .auth-form.active { display: block; }

        /* Markdown content */
        .message-body pre {
            background: #1e1e1e;
            border-radius: 6px;
            padding: 12px 16px;
            overflow-x: auto;
            margin: 8px 0;
            font-size: 13px;
        }
        html.light .message-body pre { background: #f6f8fa; }
        .message-body code {
            font-family: 'Fira Code', 'Cascadia Code', monospace;
            font-size: 13px;
        }
        .message-body p { margin-bottom: 8px; }
        .message-body ul, .message-body ol {
            padding-left: 20px;
            margin-bottom: 8px;
        }
        .message-body h1, .message-body h2, .message-body h3,
        .message-body h4, .message-body h5, .message-body h6 {
            margin: 12px 0 6px;
            font-size: inherit;
            font-weight: 600;
            line-height: inherit;
        }
        .message-body a { color: #4a9eff; text-decoration: none; }
        .message-body a:hover { text-decoration: underline; }
        .message-body blockquote {
            border-left: 3px solid var(--border-hover);
            padding-left: 12px;
            color: var(--text-secondary);
            margin: 8px 0;
        }
        .message-body img { max-width: 100%; max-height: 400px; border-radius: 8px; margin: 6px 0; display: block; object-fit: contain; }
        .msg-attachment-wrap { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
        .msg-attachment-img { max-width: 280px; max-height: 200px; border-radius: 8px; object-fit: cover; cursor: pointer; }
        .msg-attachment-doc { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text-primary); cursor: pointer; }
        .msg-attachment-doc:hover { background: var(--hover-bg); }
        .tool-use-indicator {
            font-size: 12px;
            color: var(--text-muted);
            padding: 4px 0;
            font-style: italic;
        }

/* Boot loader — fades out once the app finishes initializing (see app.js). */
#app-loading { transition: opacity 0.3s ease-out; }
