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

        :root {
            --bg-primary: #0c0d13;
            --bg-secondary: #11131c;
            --bg-tertiary: #161927;
            --border-color: #1f2333;
            --text-primary: #e4e7f5;
            --text-secondary: #7f85a7;
            --accent: #4a5ad6;
            --accent-hover: #5d6cf0;
            --success: #00d2ff;
            --danger: #ff4c67;
            --warning: #dcdcaa;
            --diff-add-bg: rgba(0, 210, 255, 0.15);
            --diff-add-line: #009cc2;
            --diff-add-text: #00d2ff;
            --diff-remove-bg: rgba(255, 76, 103, 0.15);
            --diff-remove-line: #d6324b;
            --diff-remove-text: #ff4c67;
            --diff-remove-gradient: rgba(255, 76, 103, 0.2);
        }

        .theme-gemini {
            --danger: #eab308;
            --diff-add-bg: rgba(99, 102, 241, 0.15);
            --diff-add-line: #4f46e5;
            --diff-add-text: #818cf8;
            --diff-remove-bg: rgba(234, 179, 8, 0.15);
            --diff-remove-line: #ca8a04;
            --diff-remove-text: #facc15;
            --diff-remove-gradient: rgba(234, 179, 8, 0.2);
        }

        /* Sliding Animations */
        @keyframes slideOutLeft { to { transform: translateX(-100%); } }
        @keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
        @keyframes slideOutRight { to { transform: translateX(100%); } }
        @keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }

        .slide-out-left { animation: slideOutLeft 0.2s forwards; }
        .slide-in-right { animation: slideInRight 0.2s forwards; }
        .slide-out-right { animation: slideOutRight 0.2s forwards; }
        .slide-in-left { animation: slideInLeft 0.2s forwards; }

        body {
            font-family: 'Satoshi', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            background: var(--bg-primary);
            color: var(--text-primary);
            height: 100vh;
            overflow: hidden;
        }

        .container {
            display: flex;
            height: 100vh;
        }

        /* Left Panel */
        .left-panel {
            position: relative;
            width: 30%;
            flex-shrink: 0;
            background: var(--bg-secondary);
            border-right: 1px solid var(--border-color);
            display: flex;
            flex-direction: column;
            z-index: 10;
        }

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

        .left-header h2 {
            font-size: 14px;
            font-weight: 600;
            color: var(--text-primary);
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .brand-logo {
            height: 26px;
            width: auto;
            display: block;
        }

        .settings-btn {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            padding: 8px 12px;
            border-radius: 2px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s;
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .settings-btn {
            border: none; /* Override existing border from above */
        }
        .settings-btn:hover {
            background: #2a2d3e;
        }

        .messages-container {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
            padding-bottom: 140px; /* Space for floating composer */
        }

        /* Updated message item (container for diamond and bubble) */
        .message-item {
            display: flex;
            align-items: flex-start; /* Aligns diamond to top of bubble */
            margin-bottom: 16px;
            position: relative;
        }

        /* Diamond version indicator */
        .version-indicator {
            display: none; /* Hides diamond and line */
            flex-direction: column;
            align-items: center;
            margin-right: 12px;
            position: relative;
            flex-shrink: 0;
            padding-top: 8px; /* Roughly align with first line of text */
        }

        .diamond {
            width: 10px;
            height: 10px;
            background: var(--border-color);
            transform: rotate(45deg);
            border-radius: 2px;
            transition: all 0.2s;
            z-index: 2;
            position: relative;
        }

        .diamond.active {
            background: var(--accent);
            box-shadow: 0 0 8px var(--accent);
        }

        .version-line {
            position: absolute;
            top: 15px; /* Start below diamond */
            left: 4px;
            width: 2px;
            height: calc(100% + 32px); /* Extend to next item's diamond */
            background: repeating-linear-gradient(
                to bottom,
                var(--border-color) 0,
                var(--border-color) 4px,
                transparent 4px,
                transparent 8px
            );
        }

        .message-item:last-child .version-line {
            display: none;
        }
        
        /* Wrapper to align user bubble to the right */
        .message-content-wrapper {
            flex: 1;
            display: flex;
            flex-direction: column;
            align-items: flex-end; /* Aligns bubble to the right */
            cursor: pointer;
        }
        
        /* User message bubble (blue, right) */
        .message-content {
            flex: 1;
            background: var(--accent);
            color: white;
            padding: 10px 14px;
            border-radius: 12px;
            transition: background 0.2s, box-shadow 0.2s;
            max-width: 90%;
            width: fit-content;
        }
        
        .message-content-wrapper:hover .message-content {
            background: var(--accent-hover);
        }
        
        .message-content-wrapper.active .message-content {
            background: #ff4b6c;
            /* box-shadow: 0 0 10px rgba(255, 214, 232, 0.5); */
        }

        .message-content-wrapper.active .message-text {
            color: #11131c;
        }

        .message-content-wrapper.active .message-time {
            color: rgba(17, 19, 28, 0.7);
        }

        .message-text {
            font-size: 13px;
            color: white; /* Text inside blue bubble */
            line-height: 1.5;
            word-wrap: break-word;
        }

        .message-time {
            font-size: 11px;
            color: rgba(255, 255, 255, 0.7); /* Lighter text for time */
            margin-top: 4px;
            text-align: right;
        }

        /* AI explanation bubble (grey, left) */
        .assistant-message {
            margin-left: 0; /* Aligned left */
            margin-bottom: 16px;
            padding: 10px 14px;
            background: var(--bg-tertiary); /* Grey bubble */
            border-left: none; /* Removed old border */
            border-radius: 12px; /* Bubble shape */
            font-size: 12px;
            color: var(--text-primary);
            line-height: 1.5;
            max-width: 90%;
            width: fit-content;
            word-wrap: break-word;
        }

        .model-chips {
            display: inline-flex;
            gap: 8px;
            flex-wrap: wrap;
        }

        .model-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 10px;
            border-radius: 999px;
            font-size: 10px;
            font-weight: 700;
            letter-spacing: 0.01em;
            cursor: pointer;
            border: 1px solid transparent;
            transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
            opacity: 0.9;
        }

        .model-chip:hover {
            transform: translateY(-1px);
            opacity: 1;
            box-shadow: 0 0 0 1px currentColor, 0 0 14px rgba(0, 0, 0, 0.2), 0 0 18px rgba(0, 0, 0, 0.15), 0 0 12px currentColor;
        }

        .model-chip.active {
            box-shadow: 0 0 0 1px currentColor;
            opacity: 1;
        }

        .model-chip::before {
            content: '';
            width: 8px;
            height: 8px;
            border-radius: 999px;
            background: currentColor;
            box-shadow: 0 0 0 0 currentColor;
            transition: box-shadow 0.25s ease;
        }

        .model-chip:hover::before {
            animation: pulse-dot 1.8s ease-in-out infinite;
        }

        .model-chip.openai {
            background: var(--diff-add-bg);
            color: var(--diff-add-line);
            border-color: rgba(0, 156, 194, 0.35);
        }

        .model-chip.gemini {
            background: rgba(120, 122, 255, 0.16);
            color: #5f5af6;
            border-color: rgba(95, 90, 246, 0.35);
        }

        @keyframes pulse-dot {
            0% { box-shadow: 0 0 0 0 currentColor; opacity: 0.85; }
            50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); opacity: 1; }
            100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); opacity: 0.85; }
        }

        .input-area {
            position: absolute;
            left: 12px;
            right: 12px;
            bottom: 16px;
            padding: 12px;
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
        }

        .input-wrapper {
            display: flex;
            gap: 10px;
            align-items: center;
        }

        .message-input {
            flex: 1;
            background: transparent;
            border: none;
            color: var(--text-primary);
            padding: 6px 4px;
            border-radius: 6px;
            font-size: 13px;
            font-family: inherit;
            resize: none;
            min-height: 40px;
            max-height: 120px;
        }

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

        .message-input:focus {
            outline: none;
        }

        .send-btn {
            background: var(--accent);
            border: 1px solid var(--accent);
            color: white;
            padding: 0;
            width: 42px;
            height: 42px;
            border-radius: 50%;
            cursor: pointer;
            font-size: 16px;
            font-weight: 600;
            transition: background 0.2s, box-shadow 0.2s;
            flex-shrink: 0; /* Prevent button from shrinking */
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .send-btn:hover {
            background: var(--accent-hover);
            box-shadow: 0 10px 30px rgba(90, 104, 240, 0.35);
        }

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

        .right-panel {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: var(--bg-primary);
            position: relative;
            min-width: 0; /* Prevents flexbox horizontal overflow */
        }

        .right-header {
            padding: 11px 12px;
            border-bottom: 1px solid var(--border-color);
            display: flex;
            justify-content: space-between;
            align-items: center;
            min-height: 48px;
        }

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

        .toggle-wrapper {
            display: flex;
            align-items: center;
            gap: 8px;
        }

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

        .toggle-switch {
            position: relative;
            width: 34px;
            height: 18px;
            background: var(--bg-tertiary);
            border-radius: 9px;
            cursor: pointer;
            transition: background 0.2s;
            border: 1px solid var(--border-color);
        }

        .toggle-switch.active {
            background: var(--accent);
            border-color: var(--accent);
        }

        .toggle-slider {
            position: absolute;
            top: 1px;
            left: 1px;
            width: 14px;
            height: 14px;
            background: white;
            border-radius: 50%;
            transition: transform 0.2s;
        }

        .toggle-switch.active .toggle-slider {
            transform: translateX(16px);
        }

        /* Old dropdown - hidden */
        .diff-dropdown {
            /* display: none; */ /* No longer needed, will be removed from HTML */
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 14px;
            cursor: pointer;
            outline: none;
        }

        /* NEW: Custom Dropdown */
        .custom-dropdown {
            position: relative;
            font-size: 12px;
            width: 160px; /* Set a specific width */
            display: inline-block;
        }

        .custom-dropdown.hidden {
            visibility: hidden;
            pointer-events: none;
        }

        .dropdown-selected {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            padding: 6px 12px;
            border-radius: 2px;
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
            transition: border-color 0.2s;
        }

        .dropdown-selected:hover {
            border-color: var(--accent);
        }

        .dropdown-arrow {
            width: 12px;
            height: 12px;
            fill: var(--text-primary);
            transition: transform 0.2s;
        }

        .custom-dropdown.open .dropdown-arrow {
            transform: rotate(180deg);
        }

        .dropdown-options {
            display: none;
            position: absolute;
            top: calc(100% + 4px);
            left: 0;
            right: 0;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 2px;
            z-index: 10;
            overflow: hidden;
        }

        .custom-dropdown.open .dropdown-options {
            display: block;
        }

        .dropdown-option {
            padding: 6px 12px;
            cursor: pointer;
        }

        .dropdown-option:hover {
            background: var(--bg-tertiary);
        }
        /* END: Custom Dropdown */

        .header-center {
            font-size: 12px;
            color: var(--text-secondary);
            font-weight: 500;
        }

        .header-right {
            display: flex;
            gap: 8px;
        }

        .icon-btn {
            background: var(--bg-tertiary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            padding: 8px 12px;
            border-radius: 2px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s;
            font-weight: 500;
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .icon-btn:hover:not(:disabled) {
            background: var(--accent);
            border-color: var(--accent);
            color: white;
            box-shadow: 0 12px 32px rgba(90, 104, 240, 0.28);
        }

        .icon-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .icon-btn.danger:hover:not(:disabled) {
            background: #ff4c67;
            border-color: #ff4c67;
            color: white;
        }

        .switcher-arrow-btn {
            background: transparent;
            border: none;
            color: var(--text-primary);
            padding: 4px 8px;
            height: 100%;
            cursor: pointer;
            transition: color 0.2s;
            display: inline-flex;
            align-items: center;
        }

        .switcher-arrow-btn:hover {
            color: white;
        }

        .code-container {
            flex: 1;
            position: relative;
            overflow-x: hidden;
            overflow-y: scroll; /* Hide outer scrollbar */
            background: var(--bg-primary);
        }

        /* NEW: Wrapper for editor + line numbers */
        .code-editor-wrapper {
            display: flex;
            height: 100%;
            width: 100%;
            background: var(--bg-primary);
        }

        /* NEW: Line numbers bar */
        .code-line-numbers {
            width: 74px;
            padding: 16px 12px;
            text-align: right;
            color: var(--text-secondary);
            user-select: none;
            background: var(--bg-secondary);
            border-right: 1px solid var(--border-color);
            flex-shrink: 0;
            font-family: 'SF Mono', ui-monospace, 'Menlo', 'Monaco', 'Courier New', monospace;
            font-size: 13px;
            line-height: 21px; /* Explicit line height */
            overflow-y: hidden; /* Synced with textarea */
            box-sizing: border-box;
        }

        .code-editor {
            width: 100%;
            height: 100%;
            background: var(--bg-primary);
            color: var(--text-primary);
            border: none;
            padding: 16px;
            font-family: 'SF Mono', ui-monospace, 'Menlo', 'Monaco', 'Courier New', monospace;
            font-size: 13px;
            line-height: 21px; /* Explicit line height */
            resize: none;
            outline: none;
            white-space: pre;
            overflow: auto;
            tab-size: 4;
            box-sizing: border-box;
        }

        .code-display {
            padding: 16px;
            font-family: 'SF Mono', ui-monospace, 'Menlo', 'Monaco', 'Courier New', monospace;
            font-size: 13px;
            line-height: 1.6;
        }

        .diff-view {
            font-family: 'SF Mono', ui-monospace, 'Menlo', 'Monaco', 'Courier New', monospace;
            font-size: 13px;
            line-height: 21px; /* Explicit line height */
        }

        .diff-line {
            display: flex;
            align-items: flex-start;
            min-height: 21px;
            font-family: 'SF Mono', ui-monospace, 'Menlo', 'Monaco', 'Courier New', monospace;
            position: relative;
        }

        .line-number {
            display: inline-block;
            width: 74px;
            padding: 0 12px;
            text-align: right;
            color: var(--text-secondary);
            user-select: none;
            background: var(--bg-secondary);
            border-right: 1px solid var(--border-color);
            flex-shrink: 0;
            line-height: 21px;
        }

        .diff-line:first-child .line-number {
            padding-top: 16px;
        }

        .diff-line:last-child .line-number {
            padding-bottom: 16px;
        }

        .line-content {
            flex: 1;
            padding: 0 16px;
            white-space: pre;
            font-family: 'SF Mono', ui-monospace, 'Menlo', 'Monaco', 'Courier New', monospace;
            overflow-x: auto;
            line-height: 21px;
        }

        .diff-line:first-child .line-content {
            padding-top: 16px;
        }

        .diff-line:last-child .line-content {
            padding-bottom: 16px;
        }

        .diff-line.added {
            background: var(--diff-add-bg);
        }

        .diff-line.added .line-number {
            background: var(--diff-add-bg);
            color: var(--diff-add-line);
        }

        .diff-line.added .line-content {
            color: var(--diff-add-text);
        }

        .diff-line.removed {
            background: var(--diff-remove-bg);
        }

        .diff-line.removed::before {
            content: '';
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;
            width: 4px;
            background: repeating-linear-gradient(
                -45deg,
                var(--diff-remove-gradient),
                var(--diff-remove-gradient) 2px,
                var(--danger) 2px,
                var(--danger) 4px
            );
            z-index: 10;
        }

        .diff-line.removed .line-number {
            background: var(--diff-remove-bg);
            color: var(--diff-remove-line);
        }

        .diff-line.removed .line-content {
            color: var(--diff-remove-text);
        }

        .diff-line.removed .line-number::before {
            content: '-';
        }

        /* Modal */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            display: flex; /* Changed from none */
            align-items: center;
            justify-content: center;
            z-index: 1000;
            opacity: 0; /* Start transparent */
            visibility: hidden; /* Start hidden */
            transition: opacity 0.3s ease, visibility 0.3s ease;
        }

        .modal-overlay.active {
            opacity: 1; /* Fade in */
            visibility: visible;
        }

        .modal {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 4px;
            padding: 18px;
            max-width: 400px;
            width: 90%;
            transform: translateY(20px); /* Start 20px lower */
            transition: opacity 0.3s ease, transform 0.3s ease;
            opacity: 0; /* Start transparent */
        }

        .modal-overlay.active .modal {
            transform: translateY(0); /* Slide up to original position */
            opacity: 1; /* Fade in */
        }

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

        .modal-input {
            width: 100%;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            padding: 10px 12px;
            border-radius: 8px;
            font-size: 13px;
            font-family: inherit;
            margin-bottom: 16px;
        }

        .modal-input:focus {
            outline: none;
            border-color: var(--accent);
        }

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

        .modal-btn {
            padding: 9px 16px;
            border-radius: 10px;
            font-size: 13px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            border: 1px solid var(--border-color);
            display: inline-flex;
            align-items: center;
            gap: 8px;
        }

        .modal-btn.primary {
            background: var(--accent);
            color: white;
            border-color: var(--accent);
        }

        .modal-btn.primary:hover {
            background: var(--accent-hover);
            box-shadow: 0 12px 32px rgba(90, 104, 240, 0.3);
        }

        .modal-btn.secondary {
            background: transparent;
            color: var(--text-primary);
        }

        .modal-btn.secondary:hover {
            background: var(--bg-tertiary);
        }

        /* Loading */
        .loading {
            display: inline-block;
            width: 12px;
            height: 12px;
            border: 2px solid var(--border-color);
            border-top-color: var(--accent);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }

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

        /* Empty State */
        .empty-state {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100%;
            color: var(--text-secondary);
            padding: 40px;
            text-align: center;
        }

        .empty-state-icon {
            font-size: 48px;
            margin-bottom: 16px;
            opacity: 0.5;
        }

        .empty-state-text {
            font-size: 14px;
            line-height: 1.6;
        }

        /* Scrollbar */
        /* Hides scrollbar for messages container and code editor */
        .messages-container::-webkit-scrollbar,
        .code-editor::-webkit-scrollbar {
            display: none;
        }

        .messages-container,
        .code-editor {
            scrollbar-width: none; /* For Firefox */
            -ms-overflow-style: none; /* For IE and Edge */
        }