        :root {
            --bg-color: #050A14;
            --chat-bg: #0B111D;
            --user-msg-bg: #1A283D;
            --ai-msg-bg: #161b22;
            --text-color: #e0e0e0;
            --accent-color: #4285f4;
            --gemini-color: #4285f4;
            --openai-color: #10a37f;
            --llama-color: #ed4135;
            --grok-color: #d97706;
            --claude-color: #9c27b0;
            --synth-color: #fbbc04;
            --input-bg: #24242b;
            --border-color: #2d2d35;
        }

        body {
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: var(--bg-color);
            color: var(--text-color);
            margin: 0;
            display: flex;
            flex-direction: column;
            height: 100vh;
            overflow-x: hidden;
        }

        /* Login Screen */
        #login-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: var(--bg-color);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1000;
        }

        .login-box {
            background-color: var(--chat-bg);
            padding: 2.5rem;
            border-radius: 16px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
            text-align: center;
            width: 90%;
            max-width: 400px;
            border: 1px solid var(--border-color);
        }

        h2 {
            margin-top: 0;
            font-weight: 700;
            letter-spacing: -0.5px;
            color: var(--accent-color);
        }

        input[type="password"],
        input[type="text"] {
            width: 100%;
            padding: 14px;
            margin: 12px 0;
            background-color: var(--input-bg);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            color: var(--text-color);
            box-sizing: border-box;
            font-size: 16px;
            transition: border-color 0.2s;
        }

        input:focus {
            outline: none;
            border-color: var(--accent-color);
        }

        button {
            background-color: var(--accent-color);
            color: white;
            border: none;
            padding: 14px 24px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            font-weight: 600;
            width: 100%;
            transition: transform 0.1s, opacity 0.2s;
        }

        button:hover {
            opacity: 0.9;
        }

        button:active {
            transform: scale(0.98);
        }

        /* Chat Interface */
        #chat-container {
            display: flex;
            flex-direction: column;
            height: 100%;
            width: 100%;
            padding: 0 20px;
            box-sizing: border-box;
            display: none;
        }

        header {
            padding: 18px 25px;
            background-color: var(--chat-bg);
            border-bottom: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
            backdrop-filter: blur(10px);
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .header-title {
            display: flex;
            align-items: center;
            gap: 8px;
            font-weight: 800;
            font-size: 1.4rem;
            letter-spacing: -0.5px;
            background: linear-gradient(135deg, #00d4ff 0%, #3b82f6 50%, #60a5fa 100%);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.4));
            animation: logoTextShimmer 8s ease-in-out infinite;
        }

        @keyframes logoTextShimmer {

            0%,
            100% {
                filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.4));
            }

            50% {
                filter: drop-shadow(0 0 15px rgba(59, 130, 246, 0.6));
            }
        }

        .header-title .logo-image {
            height: 28px;
            width: auto;
            flex-shrink: 0;
        }

        /* Logo stars styling - 3 models (top) feed into 1 Judge (bottom) */
        .logo-stars {
            display: inline-block;
            position: relative;
            width: 1.2em;
            height: 1.3em;
            margin-right: 4px;
            vertical-align: middle;
        }

        /* Small star 1 - top left (Model 1) */
        .logo-stars .star1 {
            position: absolute;
            font-size: 0.35em;
            top: 0;
            left: 0;
        }

        /* Small star 2 - top center (Model 2) */
        .logo-stars .star2 {
            position: absolute;
            font-size: 0.35em;
            top: 0;
            left: 0.45em;
        }

        /* Small star 3 - top right (Model 3) */
        .logo-stars .star3 {
            position: absolute;
            font-size: 0.35em;
            top: 0;
            left: 0.9em;
        }

        /* Large star - bottom center (Judge) */
        .logo-stars .star4 {
            position: absolute;
            font-size: 0.85em;
            top: 0.35em;
            left: 0.2em;
        }

        /* Logo image styling */
        .logo-image {
            height: 1.5em;
            width: auto;
            vertical-align: middle;
            margin-right: 8px;
            transition: transform 0.3s ease;
            border-radius: 14px;
            /* Crop white corners */
        }

        /* Header logo: hover scale + spin on load */
        .header-title .logo-image {
            animation: logoSpinIn 0.8s ease-out;
        }

        .header-title .logo-image:hover {
            transform: scale(1.15);
        }

        @keyframes logoSpinIn {
            0% {
                transform: rotate(-360deg) scale(0.5);
                opacity: 0;
            }

            100% {
                transform: rotate(0deg) scale(1);
                opacity: 1;
            }
        }

        /* Login page: larger logo centered above text */
        .login-box .logo-image {
            height: 112px;
            display: block;
            margin: 0 auto 15px auto;
            animation: glowPulse 3s ease-in-out infinite, sparkle 30s ease-in-out infinite;
            filter: drop-shadow(0 0 10px rgba(66, 133, 244, 0.4));
        }

        .login-box h2 {
            display: block;
            text-align: center;
            font-size: 2.2rem;
            margin: 0;
        }

        @keyframes glowPulse {

            0%,
            100% {
                filter: drop-shadow(0 0 10px rgba(66, 133, 244, 0.4));
            }

            50% {
                filter: drop-shadow(0 0 20px rgba(66, 133, 244, 0.7));
            }
        }

        @keyframes sparkle {

            0%,
            95%,
            100% {
                filter: drop-shadow(0 0 10px rgba(66, 133, 244, 0.4));
                transform: scale(1);
            }

            96% {
                filter: drop-shadow(0 0 30px rgba(0, 212, 255, 1)) brightness(1.3);
                transform: scale(1.08);
            }

            97% {
                filter: drop-shadow(0 0 15px rgba(0, 212, 255, 0.8));
                transform: scale(1.02);
            }

            98% {
                filter: drop-shadow(0 0 25px rgba(0, 212, 255, 0.9)) brightness(1.2);
                transform: scale(1.05);
            }
        }

        .header-actions {
            display: flex;
            gap: 10px;
        }

        .logout-btn {
            background: none;
            color: #777;
            width: auto;
            padding: 8px 12px;
            font-size: 0.85rem;
            border-radius: 6px;
        }

        .logout-btn:hover {
            color: #fff;
            background-color: rgba(255, 255, 255, 0.05);
        }

        #messages {
            flex: 1;
            overflow-y: auto;
            padding: 25px;
            display: flex;
            flex-direction: column;
            gap: 25px;
            scrollbar-width: thin;
        }

        .message {
            max-width: 85%;
            padding: 16px 20px;
            border-radius: 14px;
            line-height: 1.6;
            position: relative;
            word-wrap: break-word;
            font-size: 0.95rem;
        }

        .message.user {
            align-self: flex-end;
            background-color: var(--user-msg-bg);
            border-bottom-right-radius: 2px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
        }

        .message.ai-multi {
            align-self: flex-stretch;
            background: transparent;
            padding: 0;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 15px;
            width: 100%;
            max-width: 100%;
        }

        .perspective-card {
            background-color: var(--ai-msg-bg);
            border-radius: 12px;
            padding: 20px;
            border-top: 3px solid #444;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
            display: flex;
            flex-direction: column;
            position: relative;
        }

        .perspective-card.gemini {
            border-color: var(--gemini-color);
        }

        .perspective-card.openai {
            border-color: var(--openai-color);
        }

        .perspective-card.llama {
            border-color: var(--llama-color);
        }

        .perspective-card.grok {
            border-color: var(--grok-color);
        }

        .perspective-card.claude {
            border-color: var(--claude-color);
        }

        .perspective-card.synthesis {
            grid-column: 1 / -1;
            background-color: #1a2536;
            border-color: var(--synth-color);
        }

        /* Synthesis card link styling - bright cyan for dark background */
        .perspective-card.synthesis a {
            color: #00d4ff;
            text-decoration: none;
            transition: color 0.2s ease, opacity 0.2s ease;
        }

        .perspective-card.synthesis a:hover {
            color: #66e5ff;
            opacity: 0.9;
        }

        .perspective-card.synthesis a:visited {
            color: #00b8d9;
        }

        /* Sources section styling - smaller font */
        .perspective-card.synthesis details {
            font-size: 0.85em;
            margin-top: 12px;
            padding: 10px;
            background: rgba(0, 0, 0, 0.2);
            border-radius: 8px;
        }

        .perspective-card.synthesis summary {
            cursor: pointer;
            font-weight: 600;
            color: #00d4ff;
            padding: 6px 0;
            list-style: none;
        }

        .perspective-card.synthesis summary::-webkit-details-marker {
            display: none;
        }

        .perspective-card.synthesis summary::before {
            content: '▶ ';
            font-size: 0.8em;
            transition: transform 0.2s ease;
            display: inline-block;
        }

        .perspective-card.synthesis details[open] summary::before {
            content: '▼ ';
        }

        .perspective-card.synthesis details ol,
        .perspective-card.synthesis details ul {
            margin: 8px 0;
            padding-left: 20px;
        }

        .perspective-card.synthesis details li {
            margin: 4px 0;
        }

        /* Horizontal row for the three collapsible sections */
        .synthesis-details-row {
            display: flex;
            flex-direction: row;
            gap: 12px;
            margin-top: 16px;
        }

        .synthesis-details-row details {
            flex: 1;
            margin-top: 0;
        }

        /* Mobile: stack vertically */
        @media (max-width: 767px) {
            .synthesis-details-row {
                flex-direction: column;
            }
        }

        /* Stacked layout mode - force 1 column */
        .message.ai-multi.stacked {
            grid-template-columns: 1fr !important;
        }

        /* Focus mode - collapse researcher cards, keep synthesis expanded */
        .message.ai-multi.focus-mode .perspective-card:not(.synthesis) {
            padding: 8px 16px;
            min-height: auto;
        }

        .message.ai-multi.focus-mode .perspective-card:not(.synthesis) .card-content {
            display: none;
        }

        .message.ai-multi.focus-mode .perspective-card:not(.synthesis) .perspective-label {
            margin-bottom: 0;
        }

        /* Subtle indicator that card is collapsed */
        .message.ai-multi.focus-mode .perspective-card:not(.synthesis)::after {
            content: '▸ Expand';
            position: absolute;
            right: 12px;
            top: 50%;
            transform: translateY(-50%);
            font-size: 0.65rem;
            color: #666;
            opacity: 0;
            transition: opacity 0.2s;
        }

        .message.ai-multi.focus-mode .perspective-card:not(.synthesis):hover::after {
            opacity: 1;
        }

        /* Cursor indicates expandability */
        .message.ai-multi.focus-mode .perspective-card:not(.synthesis) {
            cursor: pointer;
            transition: background 0.2s;
        }

        .message.ai-multi.focus-mode .perspective-card:not(.synthesis):hover {
            background: rgba(255, 255, 255, 0.08);
        }

        /* Individually expanded card in focus mode - show content again */
        .message.ai-multi.focus-mode .perspective-card.expanded:not(.synthesis) {
            padding: 20px;
        }

        .message.ai-multi.focus-mode .perspective-card.expanded:not(.synthesis) .card-content {
            display: block;
        }

        .message.ai-multi.focus-mode .perspective-card.expanded:not(.synthesis) .perspective-label {
            margin-bottom: 10px;
        }

        .message.ai-multi.focus-mode .perspective-card.expanded:not(.synthesis)::after {
            content: '▾ Collapse';
        }

        /* Collapsible synthesis card - toggle by clicking header */
        .perspective-card.synthesis .perspective-label {
            cursor: pointer;
            user-select: none;
        }

        .perspective-card.synthesis .perspective-label::after {
            content: ' ▾';
            font-size: 0.7em;
            opacity: 0.5;
            margin-left: 6px;
            transition: transform 0.2s ease;
        }

        .perspective-card.synthesis.collapsed .perspective-label::after {
            content: ' ▸';
        }

        .perspective-card.synthesis.collapsed .card-content,
        .perspective-card.synthesis.collapsed .copy-btn {
            display: none;
        }

        .perspective-card.synthesis.collapsed {
            padding: 12px 20px;
        }

        .perspective-card.synthesis.collapsed .perspective-label {
            margin-bottom: 0;
        }

        .perspective-label {
            font-size: 0.75rem;
            font-weight: 800;
            text-transform: uppercase;
            margin-bottom: 10px;
            display: flex;
            justify-content: space-between;
            color: #999;
        }

        .model-name {
            font-style: italic;
            font-weight: 400;
            opacity: 0.7;
        }

        .input-area {
            padding: 25px;
            background: linear-gradient(180deg, rgba(11, 17, 29, 0.95) 0%, rgba(15, 23, 42, 0.98) 50%, rgba(11, 17, 29, 1) 100%);
            border-top: 1px solid rgba(59, 130, 246, 0.2);
            display: flex;
            gap: 15px;
            align-items: center;
            box-shadow: 0 -4px 30px rgba(59, 130, 246, 0.08);
        }

        #message-input {
            margin: 0;
            flex: 1;
            font-size: 1rem;
        }

        #send-btn {
            width: auto;
            padding: 14px 30px;
        }




        .typing-indicator {
            font-style: italic;
            color: #888;
            margin: 10px 25px;
            display: none;
            font-size: 0.9rem;
        }

        .error-msg {
            color: #ff6b6b;
            margin-top: 10px;
            font-size: 0.9rem;
        }

        /* Markdown styling */
        pre {
            background-color: rgba(0, 0, 0, 0.4);
            padding: 12px;
            border-radius: 8px;
            overflow-x: auto;
            margin: 10px 0;
            max-width: 100%;
            white-space: pre-wrap;
            word-wrap: break-word;
        }

        code {
            font-family: 'Fira Code', monospace;
            font-size: 0.8em;
            word-break: break-word;
        }

        /* Card content max-width */
        .card-content {
            overflow-wrap: break-word;
            word-wrap: break-word;
        }

        /* Strip any inline colors from LLM responses (e.g., ChatGPT colored headings) */
        .card-content h1,
        .card-content h2,
        .card-content h3,
        .card-content h4,
        .card-content h5,
        .card-content h6,
        .card-content span,
        .card-content strong,
        .card-content b,
        .card-content em,
        .card-content i {
            color: inherit !important;
        }

        /* Copy button for each card */
        .copy-btn {
            position: absolute;
            top: 10px;
            left: 50%;
            transform: translateX(-50%);
            background: rgba(255, 255, 255, 0.1);
            border: none;
            color: #888;
            padding: 6px 10px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.75rem;
            opacity: 0;
            transition: opacity 0.2s, background 0.2s;
            width: auto;
            z-index: 10;
        }

        .perspective-card:hover .copy-btn {
            opacity: 1;
        }

        .copy-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            color: #fff;
        }

        .copy-btn.copied {
            background: var(--openai-color);
            color: #fff;
        }

        /* Cancel request button (in loading cards) */
        .cancel-request-btn {
            position: absolute;
            top: 15px;
            right: 15px;
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            color: #777;
            width: 24px;
            height: 24px;
            border-radius: 50%;
            cursor: pointer;
            font-size: 14px;
            line-height: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
            z-index: 20;
            padding: 0;
        }

        .cancel-request-btn:hover {
            background: rgba(255, 107, 107, 0.2);
            color: #ff6b6b;
            border-color: rgba(255, 107, 107, 0.3);
        }

        /* Mobile responsive - stack cards on small screens (phones only) */
        @media (max-width: 767px) {
            .message.ai-multi {
                grid-template-columns: 1fr !important;
            }

            .perspective-card {
                padding: 16px;
            }

            /* Smaller text on mobile */
            .message,
            .card-content {
                font-size: 0.85rem !important;
            }

            #chat-container {
                max-width: 100%;
                padding: 0 8px;
                /* Reduce side padding on mobile */
                /* Safe area for iPhone notches */
                padding-left: max(8px, env(safe-area-inset-left));
                padding-right: max(8px, env(safe-area-inset-right));
            }

            header {
                padding: 12px 15px;
                /* Safe area for iPhone notch */
                padding-top: max(12px, env(safe-area-inset-top));
            }

            .header-title {
                font-size: 1.1rem;
            }

            #messages {
                padding: 12px 10px;
                gap: 15px;
            }

            .input-area {
                padding: 12px 10px;
                /* Safe area for iPhone home bar */
                padding-bottom: max(12px, env(safe-area-inset-bottom));
            }

            /* TOGGLES ROW - Wrap into 2 rows on mobile */
            .toggles-row {
                flex-wrap: wrap !important;
                gap: 5px !important;
                justify-content: center !important;
                padding: 0 2px;
            }

            /* Hide vertical dividers on mobile */
            .toggles-row .divider {
                display: none !important;
            }

            /* Row 1: Search + Mode toggles */
            .toggle-group-primary {
                display: flex;
                align-items: center;
                gap: 15px;
                width: 100%;
                justify-content: center;
            }

            /* Row 2: Judge selector + Layout */
            .toggle-group-secondary {
                display: flex;
                align-items: center;
                gap: 8px;
                width: 100%;
                justify-content: center;
                flex-wrap: wrap;
            }

            /* Larger touch targets for buttons (Apple recommends min 44px) */
            /* Compact buttons for mobile */
            .judge-btn,
            .speed-btn {
                min-height: 30px !important;
                min-width: 36px !important;
                padding: 5px 8px !important;
                font-size: 0.7rem !important;
            }

            /* Compact icons for mobile */
            .toolbar-icon,
            .mode-toggle,
            #layout-toggle {
                min-height: 32px !important;
                min-width: 32px !important;
                width: 32px !important;
                padding: 0 !important;
            }

            /* Larger switch touch area */
            .switch {
                width: 40px !important;
                height: 24px !important;
            }

            .slider:before {
                height: 16px !important;
                width: 16px !important;
            }

            .switch input:checked+.slider:before {
                transform: translateX(16px) !important;
            }

            /* Smaller input area on mobile */
            .input-area.collapsed {
                padding: 10px 15px;
            }

            .input-area.collapsed .toggles-row {
                display: none;
            }

            /* Show expand button when collapsed */
            .expand-input-btn {
                display: block;
                background: var(--accent-color);
                color: white;
                border: none;
                padding: 12px;
                border-radius: 8px;
                width: 100%;
                font-size: 1rem;
                font-weight: 600;
            }

            .expand-input-btn.hidden {
                display: none;
            }

            /* Copy button always visible on mobile */
            .perspective-card .copy-btn {
                opacity: 1;
            }

            /* Larger send button for fat finger tapping */
            #send-btn {
                padding: 14px 20px !important;
                min-height: 48px;
            }

            /* Larger attach button */
            #attach-btn {
                min-height: 48px !important;
                min-width: 48px !important;
            }

            /* Message input - prevent zoom on iOS (font-size >= 16px) */
            #message-input {
                font-size: 16px !important;
            }
        }

        /* iPad/Tablet (Portrait & Landscape) - 768px to 1024px */
        @media (min-width: 768px) and (max-width: 1024px) {
            .message.ai-multi {
                grid-template-columns: repeat(3, 1fr);
            }

            /* Safe area for iPad Pro with Face ID */
            #chat-container {
                padding-left: max(15px, env(safe-area-inset-left));
                padding-right: max(15px, env(safe-area-inset-right));
            }

            /* Larger touch targets for iPad (Apple HIG: 44px) */
            .judge-btn,
            .speed-btn {
                min-height: 34px;
                padding: 6px 12px;
                font-size: 0.8rem;
            }

            #layout-toggle {
                min-height: 40px;
                min-width: 40px;
                width: 40px;
                padding: 0;
            }

            #send-btn {
                min-height: 48px;
                padding: 14px 28px;
            }

            #attach-btn {
                min-height: 48px;
                min-width: 48px;
            }

            /* Prevent iOS zoom on input focus */
            #message-input {
                font-size: 16px;
            }

            /* Larger toggle switches for touch */
            .switch {
                width: 38px;
                height: 22px;
            }
        }

        /* Desktop - 3 columns, full keyboard/mouse experience */
        @media (min-width: 1025px) {
            .message.ai-multi {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        /* ========== DESKTOP SETTINGS COLLAPSE TOGGLE ========== */
        /* Hide desktop toggle on mobile (mobile has its own button) */
        @media (max-width: 767px) {
            #desktop-settings-toggle {
                display: none !important;
            }
        }

        /* Desktop toggle hover effect */
        #desktop-settings-toggle:hover {
            opacity: 1 !important;
            color: #888 !important;
        }

        /* ========== DESKTOP-ONLY COLLAPSED SETTINGS (min-width: 768px) ========== */
        @media (min-width: 768px) {

            /* Collapsed settings container - hide content, minimal height */
            .settings-container.collapsed {
                padding-top: 8px !important;
                padding-bottom: 14px !important;
                margin-bottom: 8px !important;
            }

            /* Visible expand bar when collapsed - shows "Settings" text */
            .settings-container.collapsed::before {
                content: '⚙️ Settings (double-click to expand)';
                display: block;
                text-align: center;
                font-size: 0.75rem;
                color: rgba(59, 130, 246, 0.6);
                padding: 6px 0;
                margin-bottom: 8px;
                cursor: pointer;
                background: rgba(59, 130, 246, 0.05);
                border-radius: 8px;
                border: 1px dashed rgba(59, 130, 246, 0.2);
                transition: all 0.2s;
            }

            .settings-container.collapsed:hover::before {
                color: rgba(59, 130, 246, 1);
                background: rgba(59, 130, 246, 0.1);
                border-color: rgba(59, 130, 246, 0.4);
            }

            .settings-container.collapsed .toggles-row {
                display: none !important;
            }
        }

        /* Perspective card relative for copy button positioning */
        .perspective-card {
            position: relative;
        }

        /* ========== PROMPT BOX REDESIGN - BLUE GLOW THEME ========== */

        /* Main prompt box container with blue glow */
        .prompt-box-container {
            display: flex;
            flex-direction: column;
            gap: 12px;
            background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(11, 17, 29, 0.98) 50%, rgba(15, 23, 42, 0.95) 100%);
            padding: 14px 18px;
            border-radius: 16px;
            flex: 1;
            position: relative;
            border: 1px solid rgba(59, 130, 246, 0.35);
            box-shadow: 0 0 25px rgba(59, 130, 246, 0.2),
                0 0 50px rgba(59, 130, 246, 0.1),
                inset 0 0 40px rgba(59, 130, 246, 0.05),
                0 0 80px rgba(0, 212, 255, 0.05);
        }

        /* Textarea inside prompt box */
        .prompt-box-container #message-input {
            flex: 1;
            resize: vertical;
            padding: 12px;
            border-radius: 8px;
            border: 1px solid rgba(59, 130, 246, 0.2);
            background: rgba(0, 0, 0, 0.3);
            color: #e0e0e0;
            font-family: inherit;
            line-height: 1.5;
            min-height: 60px;
            font-size: 1rem;
        }

        .prompt-box-container #message-input:focus {
            outline: none;
            border-color: rgba(59, 130, 246, 0.5);
        }

        /* Bottom row: Normal (left) and Send (right) */
        .prompt-box-bottom {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
        }

        /* Bottom left buttons container */
        .bottom-left-buttons {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        /* Attach pill button */
        .attach-pill-btn {
            padding: 10px 14px;
            font-size: 1rem;
            border: none;
            background: rgba(30, 41, 59, 0.8);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 25px;
            color: #3b82f6;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .attach-pill-btn:hover {
            background: rgba(59, 130, 246, 0.15);
            border-color: rgba(59, 130, 246, 0.3);
        }

        /* Style dropdown as separate pill */
        .style-pill {
            position: relative;
        }

        .style-pill #style-dropdown-btn {
            padding: 10px 16px;
            font-size: 0.85rem;
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 25px;
            background: rgba(30, 41, 59, 0.8);
            color: #aaa;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            transition: all 0.2s ease;
        }

        .style-pill #style-dropdown-btn:hover {
            color: #fff;
            background: rgba(59, 130, 246, 0.1);
            border-color: rgba(59, 130, 246, 0.3);
        }

        /* Mode toggle (Chatable/Star) - fixed size to prevent layout shift */
        .mode-toggle {
            padding: 0;
            font-size: 1rem;
            margin-left: 8px;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 36px;
            height: 36px;
            min-width: 36px;
            min-height: 36px;
        }

        .mode-toggle .mode-icon {
            transition: all 0.2s ease;
        }

        .mode-toggle .multi-mode-icon {
            opacity: 0.8;
        }

        .mode-toggle:hover .multi-mode-icon {
            opacity: 1;
        }

        .mode-toggle .single-mode-icon {
            font-size: 1.2rem;
            color: #888;
            width: 20px;
            height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            line-height: 1;
        }

        .mode-toggle:hover .single-mode-icon {
            color: #aaa;
        }

        .mode-toggle.single-mode .multi-mode-icon {
            display: none !important;
        }

        .mode-toggle.single-mode .single-mode-icon {
            display: inline !important;
        }

        /* Desktop collapse toggle */
        #desktop-settings-toggle {
            position: absolute;
            top: 50%;
            right: 10px;
            transform: translateY(-50%);
            background: transparent;
            border: none;
            color: #555;
            cursor: pointer;
            font-size: 0.7rem;
            opacity: 0.5;
            transition: opacity 0.2s, color 0.2s;
            padding: 4px 6px;
            z-index: 5;
            width: auto;
        }

        /* Single row toolbar */
        .prompt-box-container .toggles-row {
            display: flex;
            justify-content: center;
            align-items: center;
            gap: 12px;
            flex-wrap: wrap;
        }

        /* Toolbar icon buttons (globe, stack) - fixed size to prevent layout shift */
        .toolbar-icon {
            padding: 0;
            font-size: 1.1rem;
            border-radius: 8px;
            border: none;
            background: transparent;
            color: #666;
            cursor: pointer;
            opacity: 0.6;
            transition: all 0.3s ease;
            width: 36px;
            height: 36px;
            min-width: 36px;
            min-height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .toolbar-icon:hover {
            opacity: 1;
            color: #3b82f6;
        }

        .toolbar-icon.active,
        .search-globe-btn.active {
            opacity: 1;
            color: #3b82f6;
            text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
        }

        /* Pill group container */
        .pill-group {
            display: flex;
            align-items: center;
            background: rgba(255, 255, 255, 0.03);
            border-radius: 25px;
            padding: 3px;
            border: 1px solid rgba(255, 255, 255, 0.08);
        }

        /* Speed and Judge pill buttons */
        .speed-btn,
        .judge-btn {
            padding: 6px 14px;
            font-size: 0.75rem;
            border-radius: 20px;
            border: none;
            background: transparent;
            color: #888;
            cursor: pointer;
            transition: all 0.2s ease;
            font-weight: 500;
            width: auto;
        }

        .speed-btn:hover,
        .judge-btn:hover {
            color: #ccc;
            background: rgba(255, 255, 255, 0.05);
        }

        .speed-btn.active,
        .judge-btn.active {
            background: #3b82f6;
            color: white;
            box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
        }

        /* Rejudge button (↻) inside judge pill */
        .rejudge-btn {
            padding: 6px 10px;
            font-size: 0.9rem;
            border-radius: 50%;
            border: none;
            background: transparent;
            color: #888;
            cursor: pointer;
            transition: all 0.2s ease;
            width: auto;
            margin-left: 2px;
        }

        .rejudge-btn:hover {
            color: #3b82f6;
            background: rgba(59, 130, 246, 0.15);
            transform: rotate(45deg);
        }

        /* Pill-shaped Style dropdown button */
        #style-dropdown-btn {
            padding: 8px 16px;
            font-size: 0.8rem;
            border-radius: 20px;
            border: 1px solid rgba(255, 255, 255, 0.15);
            background: rgba(11, 17, 29, 0.8);
            color: #aaa;
            cursor: pointer;
            min-width: 90px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 6px;
            transition: all 0.2s ease;
        }

        #style-dropdown-btn:hover {
            border-color: rgba(59, 130, 246, 0.4);
            color: #ddd;
        }

        /* Pill-shaped Send button with blue glow */
        #send-btn {
            padding: 12px 28px;
            border-radius: 25px;
            background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
            color: white;
            font-weight: 600;
            font-size: 0.9rem;
            border: none;
            cursor: pointer;
            box-shadow: 0 0 20px rgba(59, 130, 246, 0.4),
                0 4px 15px rgba(59, 130, 246, 0.3);
            transition: all 0.2s ease;
        }

        #send-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 0 30px rgba(59, 130, 246, 0.5),
                0 6px 20px rgba(59, 130, 246, 0.4);
        }

        #send-btn:active {
            transform: translateY(0);
        }

        /* Style dropdown menu styling - opens upward */
        #style-dropdown-menu {
            position: absolute;
            bottom: 100%;
            left: 0;
            margin-bottom: 6px;
            min-width: 120px;
            display: none;
            background: rgba(11, 17, 29, 0.95);
            border: 1px solid rgba(59, 130, 246, 0.2);
            border-radius: 12px;
            box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5),
                0 0 20px rgba(59, 130, 246, 0.1);
            z-index: 100;
        }

        .style-option {
            padding: 8px 16px;
            cursor: pointer;
            color: #888;
            font-size: 0.8rem;
            transition: all 0.2s ease;
        }

        .style-option:hover {
            background: rgba(59, 130, 246, 0.15);
            color: #fff;
        }

        /* ========== HISTORY SIDEBAR ========== */
        .history-sidebar {
            position: fixed;
            top: 0;
            left: -320px;
            width: 300px;
            height: 100%;
            background-color: var(--chat-bg);
            border-right: 1px solid var(--border-color);
            z-index: 999;
            transition: left 0.3s ease;
            display: flex;
            flex-direction: column;
            box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
        }

        .history-sidebar.open {
            left: 0;
        }

        .history-header {
            padding: 20px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .history-header h3 {
            margin: 0;
            font-size: 2.2rem;
            color: #e0e0e0;
            display: flex;
            align-items: center;
            gap: 12px;
            font-weight: 700;
        }

        .history-close-btn {
            background: none;
            border: none;
            color: #00d4ff;
            font-size: 0.9rem;
            cursor: pointer;
            padding: 5px;
            line-height: 1;
        }

        .history-close-btn:hover {
            color: #66e5ff;
        }

        .history-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
        }

        .history-item {
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 8px;
            background: rgba(255, 255, 255, 0.03);
            cursor: pointer;
            transition: background 0.2s;
            border-left: 3px solid transparent;
        }

        .history-item:hover {
            background: rgba(255, 255, 255, 0.08);
            border-left-color: var(--accent-color);
        }

        .history-item-query {
            font-size: 0.85rem;
            color: var(--text-color);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            margin-bottom: 4px;
        }

        .history-item-meta {
            font-size: 0.7rem;
            color: #666;
            display: flex;
            justify-content: space-between;
        }

        .history-clear-btn {
            margin: 10px;
            padding: 10px;
            background: #1a2536;
            border: 1px solid rgba(255, 255, 255, 0.2);
            color: #e0e0e0;
            border-radius: 8px;
            cursor: pointer;
            font-size: 0.8rem;
            transition: background 0.2s;
            width: calc(100% - 20px);
            box-sizing: border-box;
        }

        .history-clear-btn:hover {
            background: #243448;
        }

        .history-empty {
            text-align: center;
            padding: 40px 20px;
            color: #666;
            font-size: 0.85rem;
        }

        .history-overlay {
            /* No longer darkens - just used for click-outside-to-close on mobile */
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: transparent;
            z-index: 998;
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
        }

        .history-overlay.visible {
            opacity: 1;
            visibility: visible;
            /* Only capture clicks on mobile where we want overlay behavior */
        }

        .history-toggle-btn {
            background: none;
            border: none;
            color: #888;
            font-size: 1.3rem;
            cursor: pointer;
            padding: 5px 10px;
            margin-right: 10px;
            transition: color 0.2s;
        }

        .history-toggle-btn:hover {
            color: var(--accent-color);
        }

        .history-toggle-btn.has-history {
            color: var(--accent-color);
        }

        /* History item with delete button */
        .history-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
        }

        .history-item-content {
            flex: 1;
            min-width: 0;
            /* Allow text truncation */
        }

        .history-delete-btn {
            background: none;
            border: none;
            color: #666;
            cursor: pointer;
            padding: 4px;
            border-radius: 4px;
            font-size: 0.9rem;
            opacity: 0;
            transition: all 0.2s;
            flex-shrink: 0;
            width: 24px;
            height: 24px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .history-item:hover .history-delete-btn {
            opacity: 1;
        }

        .history-delete-btn:hover {
            background: rgba(255, 100, 100, 0.2);
            color: #ff6b6b;
        }

        /* Sidebar push effect for tablet/desktop */
        #chat-container {
            transition: margin-left 0.3s ease, width 0.3s ease;
            position: relative;
            box-sizing: border-box;
        }

        #chat-container.sidebar-open {
            margin-left: 300px;
            width: calc(100vw - 300px);
        }

        /* Mobile: overlay only, no push */
        @media (max-width: 767px) {
            #chat-container.sidebar-open {
                margin-left: 0;
                width: 100%;
            }

            .history-delete-btn {
                opacity: 1;
                /* Always visible on mobile for touch */
            }
        }

        /* Mobile: full-width sidebar */
        @media (max-width: 768px) {
            .history-sidebar {
                width: 85%;
                left: -90%;
            }
        }

        .switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .switch input:checked+.slider {
            background-color: #2196F3;
        }

        .switch input:focus+.slider {
            box-shadow: 0 0 1px #2196F3;
        }

        .switch input:checked+.slider:before {
            transform: translateX(14px);
        }

        .slider:before {
            position: absolute;
            content: "";
            height: 12px;
            width: 12px;
            left: 4px;
            bottom: 4px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }

        /* ========== UI POLISH ========== */
        /* Improved Data Tables */
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 15px 0;
            background: rgba(255, 255, 255, 0.02);
            border-radius: 8px;
            overflow: hidden;
            border: 1px solid var(--border-color);
        }

        th,
        td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid var(--border-color);
            font-size: 0.9rem;
        }

        th {
            background: rgba(255, 255, 255, 0.05);
            font-weight: 600;
            color: var(--accent-color);
            text-transform: uppercase;
            font-size: 0.75rem;
            letter-spacing: 0.5px;
        }

        tr:last-child td {
            border-bottom: none;
        }

        tr:hover {
            background: rgba(255, 255, 255, 0.03);
        }

        /* Table Copy Button for Excel */
        .table-copy-wrapper {
            position: relative;
        }

        .table-copy-btn {
            position: absolute;
            top: 8px;
            right: 8px;
            background: rgba(66, 133, 244, 0.9);
            border: none;
            color: white;
            padding: 6px 12px;
            border-radius: 6px;
            cursor: pointer;
            font-size: 0.75rem;
            font-weight: 600;
            opacity: 0;
            transition: opacity 0.2s, background 0.2s, transform 0.2s;
            z-index: 10;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
            width: auto;
        }

        .table-copy-wrapper:hover .table-copy-btn {
            opacity: 1;
        }

        .table-copy-btn:hover {
            background: rgba(66, 133, 244, 1);
            transform: scale(1.05);
        }

        .table-copy-btn.copied {
            background: #10a37f;
        }

        /* Always visible on mobile for touch */
        @media (max-width: 767px) {
            .table-copy-btn {
                opacity: 1;
            }
        }

        /* Thinking Animation - Gemini Style Pulse */
        .thinking-dots {
            display: inline-flex;
            gap: 6px;
            margin-right: 12px;
            vertical-align: middle;
        }

        .dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            animation: pulse-wave 1.5s infinite ease-in-out both;
        }

        .dot.gemini {
            background-color: var(--gemini-color);
            animation-delay: 0s;
        }

        .dot.openai {
            background-color: var(--openai-color);
            animation-delay: 0.2s;
        }

        .dot.third {
            background-color: var(--grok-color);
            animation-delay: 0.4s;
        }

        @keyframes pulse-wave {

            0%,
            100% {
                transform: scale(0.8);
                opacity: 0.5;
            }

            50% {
                transform: scale(1.3);
                opacity: 1;
                box-shadow: 0 0 8px currentColor;
            }
        }

        /* Mobile Sidebar Tune-up */
        @media (max-width: 768px) {
            .history-sidebar {
                width: 85%;
                max-width: 320px;
                box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
            }

            .history-overlay {
                backdrop-filter: blur(2px);
            }

            .history-item {
                padding: 16px 12px;
                /* Larger touch targets */
            }

            .history-clear-btn {
                min-height: 48px;
                /* Apple HIG touch target */
            }
        }

        /* Mobile-Only Collapsible Settings */
        .mobile-settings-btn {
            display: none;
            /* Hidden on desktop */
        }

        @media (max-width: 768px) {
            .mobile-settings-btn {
                display: flex;
                align-items: center;
                justify-content: center;
                gap: 8px;
                background: rgba(255, 255, 255, 0.05);
                border: 1px solid var(--border-color);
                color: #888;
                padding: 12px;
                border-radius: 10px;
                font-size: 0.85rem;
                font-weight: 600;
                cursor: pointer;
                min-height: 44px;
                transition: all 0.2s;
            }

            .mobile-settings-btn:hover,
            .mobile-settings-btn.active {
                background: rgba(66, 133, 244, 0.15);
                border-color: var(--accent-color);
                color: var(--accent-color);
            }

            .toggles-row {
                display: none !important;
                /* Hidden by default on mobile */
            }

            .toggles-row.expanded {
                display: flex !important;
                /* Shown when expanded */
            }

            /* Override desktop collapsed state on mobile - allow expanded to work */
            .settings-container.collapsed .toggles-row.expanded {
                display: flex !important;
            }
        }