:root,
.dark-theme {
    /* Color Palette - Codex Dark Mode */
    --bg-base: #181818;
    --bg-surface: #212121;
    --bg-surface-secondary: rgba(255, 255, 255, 0.08);
    --bg-glass: rgba(33, 33, 33, 0.95);
    --bg-glass-hover: rgba(43, 43, 43, 1);

    --border-glass: rgba(255, 255, 255, 0.05);
    --border-glass-strong: rgba(255, 255, 255, 0.1);

    --accent-cyan: #339cff;
    --accent-cyan-glow: transparent;
    --brand-blue-gradient-end: #339cff;

    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-placeholder: rgba(255, 255, 255, 0.5);

    --state-safe: #04b84c;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    /* Variables */
    --sidebar-width: 68px;
    --composer-max-width: 760px;
}

.light-theme {
    /* Color Palette - Codex Light Mode */
    --bg-base: #ffffff;
    --bg-surface: #f9f9f9;
    --bg-surface-secondary: rgba(0, 0, 0, 0.06);
    --bg-glass: rgba(255, 255, 255, 0.95);
    --bg-glass-hover: rgba(243, 243, 243, 1);

    --border-glass: rgba(13, 13, 13, 0.05);
    --border-glass-strong: rgba(13, 13, 13, 0.1);

    --accent-cyan: #0285ff;
    --accent-cyan-glow: transparent;
    --brand-blue-gradient-end: #0285ff;

    --text-primary: #000000;
    --text-secondary: rgba(13, 13, 13, 0.7);
    --text-placeholder: rgba(13, 13, 13, 0.5);

    --state-safe: #00a240;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}

body.theme-transitioning,
body.theme-transitioning * {
    transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease !important;
}

/* Base Glass Effect */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--border-glass);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.3);
}

/* App Shell Layout */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 800px;
}

/* Top Navigation */
.top-nav {
    height: 56px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    z-index: 50;
    background: transparent;
}

.brand-area {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
}

.sparkle-stars {
    font-size: 18px;
}

.sub-brand {
    color: var(--text-secondary);
    font-weight: 400;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    -webkit-app-region: no-drag;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(34, 197, 94, 0.1);
    color: var(--state-safe);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.status-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--state-safe);
    box-shadow: 0 0 8px var(--state-safe);
}

.status-indicator.offline {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-indicator.offline .dot {
    background-color: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

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

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Main Content Wrapper */
.main-layout {
    display: flex;
    flex: 1;
    overflow: visible;
    position: relative;
    padding-bottom: 24px;
}

/* Narrow Sidebar */
.narrow-sidebar {
    width: var(--sidebar-width);
    margin: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    z-index: 40;
}

.nav-top {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    align-items: center;
}

.nav-icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-icon-btn.primary-action {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid transparent;
}

.nav-icon-btn.primary-action:hover {
    background: rgba(255, 255, 255, 0.05);
    /* very subtle hover */
}

.nav-icon-btn.active,
.icon-btn.active {
    background: rgba(51, 156, 255, 0.14);
    color: var(--text-primary);
    border-color: rgba(51, 156, 255, 0.25);
}

/* Center Content Hub */
.content-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Floating Live Desk Screen (PiP Customization) */
.pip-video-widget {
    background: rgba(26, 26, 26, 0.8);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass-strong);
    border-radius: 12px;
    overflow: hidden;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-right: 8px;
    margin-bottom: 2px;
}

.pip-video-widget:hover {
    background: rgba(40, 40, 40, 0.9);
    color: var(--text-primary);
}

/* Minimized State (Inside Composer) */
.pip-video-widget.minimized {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    position: relative;
    display: none;
    /* Hidden until screen recording is active */
}

.pip-video-widget.minimized .pip-header {
    display: none;
}

.pip-video-widget.minimized .pip-canvas {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    /* Display a small icon instead of full canvas when collapsed */
}

/* Expanded State (Floating Picture-in-Picture) */
.pip-video-widget.expanded {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 320px;
    height: auto;
    z-index: 60;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    cursor: default;
    display: flex;
    flex-direction: column;
}

.pip-video-widget.expanded .pip-header {
    padding: 10px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.5);
    cursor: grab;
    /* Indicates it might be draggable in the future */
}

.pip-video-widget.expanded .pip-header .close-pip {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

.pip-video-widget.expanded .pip-header .close-pip:hover {
    color: #fff;
}

.title-drag-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--state-safe);
    box-shadow: 0 0 6px var(--state-safe);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

.pip-video-widget.expanded .pip-canvas {
    height: 180px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.pip-canvas .placeholder {
    color: var(--text-placeholder);
    font-size: 12px;
}

.pip-video-widget.expanded svg {
    display: none;
    /* Hide the minimized icon */
}

/* Chat Feed Area */
.chat-feed-container {
    flex: 1;
    width: 100%;
    max-width: var(--composer-max-width);
    overflow-y: auto;
    padding: 20px 24px 120px 24px;
    /* Padding bottom for composer overlap */
    display: flex;
    flex-direction: column;
}

.chat-history {
    display: flex;
    flex-direction: column;
    padding-bottom: 24px;
}

.chat-history.hidden {
    display: none;
}

.workspace-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    padding-bottom: 24px;
}

.workspace-view.hidden {
    display: none;
}

.workspace-shell {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--border-glass-strong);
    border-radius: 16px;
    padding: 18px;
}

.workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.workspace-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.workspace-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.workspace-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 14px;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.workspace-card:hover {
    border-color: rgba(51, 156, 255, 0.35);
    background: rgba(51, 156, 255, 0.08);
    transform: translateY(-1px);
}

.workspace-card h3 {
    font-size: 14px;
    margin-bottom: 6px;
}

.workspace-card p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.workspace-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.workspace-btn {
    border: 1px solid var(--border-glass-strong);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.workspace-btn:hover {
    color: var(--text-primary);
    border-color: rgba(51, 156, 255, 0.35);
    background: rgba(51, 156, 255, 0.08);
}

.workspace-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.workspace-list-item {
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.workspace-list-item .meta {
    font-size: 11px;
    color: var(--accent-cyan);
    margin-bottom: 6px;
}

.workspace-list-item p {
    font-size: 13px;
    line-height: 1.45;
}

.workspace-key-value {
    display: grid;
    gap: 8px;
}

.workspace-kv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px dashed var(--border-glass);
    padding-bottom: 6px;
}

.workspace-kv-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.workspace-kv-row span:first-child {
    color: var(--text-secondary);
    font-size: 12px;
}

.workspace-kv-row strong {
    font-size: 12px;
    color: var(--text-primary);
}

.workspace-template {
    margin-top: 12px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    max-height: 260px;
    overflow: auto;
    padding: 12px;
    white-space: pre-wrap;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.45;
}

/* Chat Message Layout overhaul */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

.message-row {
    display: flex;
    width: 100%;
    margin-bottom: 36px;
    animation: messageSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.message-row.agent {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 14px 20px;
    font-size: 15px;
    line-height: 1.5;
}

/* User Message: Highly distinct, solid modern grey/blue */
.message-row.user .message-bubble {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-radius: 16px;
    box-shadow: none;
    border: none;
}

/* Agent Message specific */
.message-row.agent .message-content {
    display: flex;
    gap: 16px;
    max-width: 100%;
    width: 100%;
}

.agent-avatar {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    box-shadow: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 2px;
    transition: all 0.3s;
}

.agent-avatar.thinking {
    width: auto;
    padding: 0 12px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
}



.agent-avatar.thinking .thinking-label::after {
    content: '';
    display: inline-block;
    width: 12px;
    text-align: left;
    animation: thinking-dots 1.5s infinite steps(4, end);
}

@keyframes thinking-dots {
    0% {
        content: '';
    }

    25% {
        content: '.';
    }

    50% {
        content: '..';
    }

    75% {
        content: '...';
    }

    100% {
        content: '';
    }
}

.agent-text-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.agent-text {
    color: #e2e8f0;
    padding-top: 2px;
    line-height: 1.65;
    font-size: 15px;
    letter-spacing: 0.15px;
    overflow-wrap: break-word;
    word-break: break-word;
}

.agent-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

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

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

.action-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Rich Markdown Rendering Overrides */
.agent-text p {
    margin-bottom: 16px;
}

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

.agent-text pre {
    background: #0f111a !important;
    /* Override hljs default */
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin-bottom: 16px;
}

.agent-text code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9em;
}

.agent-text pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.agent-text p code,
.agent-text li code {
    background: rgba(56, 189, 248, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.agent-text ul,
.agent-text ol {
    margin-left: 20px;
    margin-bottom: 16px;
}

.agent-text li {
    margin-bottom: 6px;
}

/* Elegant Markdown Tables */
.agent-text table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 14px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.agent-text th,
.agent-text td {
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    text-align: left;
}

.agent-text th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.agent-text tr {
    background: rgba(0, 0, 0, 0.2);
}

.agent-text tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Blockquotes */
.agent-text blockquote {
    border-left: 3px solid var(--accent-cyan);
    margin: 0 0 16px 0;
    padding: 12px 16px;
    background: rgba(0, 240, 255, 0.05);
    color: #a1a1aa;
    border-radius: 0 8px 8px 0;
    font-style: italic;
}

/* Horizontal Rule */
.agent-text hr {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-glass-strong), transparent);
    margin: 24px 0;
}

/* Removed Duplicate Thinking Block */

/* Images */
.agent-text img {
    max-width: 100%;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid var(--border-glass-strong);
}

/* Removed Duplicate Thinking Blocks */

/* Task Checkboxes */
.agent-text input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-glass-strong);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    vertical-align: middle;
    margin-right: 8px;
    position: relative;
    top: -1px;
}

.agent-text input[type="checkbox"]:checked {
    background: rgba(0, 240, 255, 0.2);
    border-color: rgba(0, 240, 255, 0.5);
}

.agent-text input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: var(--accent-cyan);
    font-size: 12px;
    left: 2px;
    top: -1px;
}

/* Agent Operational Badges */
.agent-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 12px;
    margin-bottom: 4px;
    font-family: var(--font-sans);
}

.agent-badge.now {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.agent-badge.plan {
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.agent-badge.doing {
    background: rgba(250, 204, 21, 0.15);
    color: #facc15;
    border: 1px solid rgba(250, 204, 21, 0.3);
}

.agent-badge.result {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.3);
}

/* Rich Content Blocks - 2026 Premium Aesthetics */
.code-block {
    background: #0d0d12;
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 8px 32px rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    margin: 18px 0;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s ease;
}

.code-block:hover {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 12px 40px rgba(0, 0, 0, 0.6);
    transform: translateY(-1px);
}

.code-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 10px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.5);
    font-size: 12px;
}

.code-header button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-family: var(--font-sans);
    transition: color 0.2s ease;
}

.code-lang {
    text-transform: uppercase;
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    color: rgba(255, 255, 255, 0.5);
}

.code-header button:hover {
    color: var(--text-primary);
}

.code-block pre {
    padding: 18px;
    margin: 0;
    overflow-x: auto;
}

.code-block code {
    font-family: 'SF Mono', 'Fira Code', Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #e2e8f0;
}

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

/* Premium Glassmorphism Thinking Block */
.thinking-block {
    margin: 16px 0;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.thinking-block:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
}

.thinking-block summary {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: color 0.2s;
    list-style: none !important;
    list-style-type: none !important;
}

.thinking-block summary::-webkit-details-marker,
.thinking-block summary::marker,
.thinking-block summary::before {
    display: none !important;
    content: "" !important;
}

.thinking-block summary:hover {
    color: var(--text-primary);
}

.thinking-block[open] summary .think-icon {
    transform: rotate(90deg);
}

.think-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
    color: var(--accent-cyan);
    opacity: 0.8;
}

.thinking-content {
    padding: 0 16px 16px 16px;
    font-size: 13.5px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.65);
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    margin-top: 4px;
    padding-top: 12px;
}

.task-block {
    background: #111111;
    border: 1px solid var(--border-glass-strong);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.task-block-title {
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 14px;
}

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

.task-item.done {
    color: var(--text-secondary);
}

.task-item.done .task-icon {
    color: var(--state-safe);
}

.task-item.active {
    color: var(--text-primary);
}

.task-item.active .task-icon {
    color: var(--accent-cyan);
    animation: rotate 2s linear infinite;
}

.task-item.pending {
    color: var(--text-placeholder);
}

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

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

.scrollbar-hidden::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

.scrollbar-hidden {
    scrollbar-width: none;
}

/* Welcome Hero */
.welcome-hero {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    /* Pushes content to center if empty */
    min-height: 200px;
}

.welcome-hero h1 {
    font-size: 32px;
    font-weight: 500;
    max-width: 500px;
    text-align: center;
    line-height: 1.3;
}

.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background-color: var(--accent-cyan);
    margin-left: 4px;
    vertical-align: text-bottom;
    animation: blink 1s step-end infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.text-glow {
    color: var(--text-primary);
    text-shadow: 0 0 24px var(--accent-cyan-glow);
    font-weight: 600;
}

/* Bottom Composer Component (Floating) */
.composer-container {
    position: absolute;
    bottom: 0;
    width: 100%;
    max-width: var(--composer-max-width);
    padding: 0 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 40;
}

.composer-container::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 180px;
    background: linear-gradient(to top, var(--bg-base) 40%, transparent);
    z-index: -1;
    pointer-events: none;
}

/* Action Prompts */
.quick-prompts-row {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    width: 100%;
    padding: 12px 24px;
    justify-content: flex-start;
}

.prompt-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.quick-prompts-row::after {
    content: '';
    display: block;
    padding-right: 24px;
}

.prompt-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--border-glass-strong);
}

/* ===== ChatGPT.com Input Bar \u2014 Exact Grid Layout from Live DOM =====
   Grid collapsed:  'leading primary trailing'
                    '.       footer  .'
   Grid expanded:   'primary primary primary'
                    'leading footer  trailing'
   Card:   border-radius:28px  padding:10px  dark:bg:#303030
   Primary:  min-h-14 (56px)  -my-2.5 (margin -10px)  px-1.5 (6px)
   Textarea: font-size:16px  line-height:24px  padding:0
   Buttons:  h-9 w-9  =  36x36px  rounded-full
   ================================================================ */

/* The Composer Card — CSS Grid with named areas */
.composer-box {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 28px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
    margin-bottom: 12px;
    overflow: visible;
    padding: 10px;
    /* p-2.5 = 10px */

    /* Default = expanded layout (textarea full width on top) */
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    grid-template-areas:
        'primary primary primary'
        'leading footer  trailing';
}

/* Expanded state (user focused / has content) */
.composer-box.expanded {
    grid-template-areas:
        'primary primary primary'
        'leading footer  trailing';
}

/* [grid-area: primary] — contains the textarea */
.composer-primary {
    grid-area: primary;
    display: flex;
    min-height: 56px;
    /* min-h-14 = 14*4px */
    align-items: center;
    overflow-x: hidden;
    padding: 0 6px;
    /* px-1.5 = 6px */
    margin: -10px 0;
    /* -my-2.5 = -10px to bleed into card padding */
}

.composer-prosemirror-parent {
    flex: 1;
    min-width: 0;
    max-height: 208px;
    /* max-h-52 = 52*4px */
    overflow-y: auto;
    scrollbar-width: thin;
}

/* Textarea \u2014 exact: font-size:16px, line-height:24px, padding:0 */
#userInput,
.composer-prosemirror-parent textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 16px;
    /* exact from chatgpt.com */
    line-height: 24px;
    /* exact 24px */
    resize: none;
    outline: none;
    padding: 0;
    /* exact: no padding */
    min-height: 24px;
    display: block;
}

#userInput::placeholder,
.composer-prosemirror-parent textarea::placeholder {
    color: var(--text-placeholder);
}

/* [grid-area: leading] \u2014 the + button column */
.composer-leading {
    grid-area: leading;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 10px;
    /* align with bottom of primary area in expanded */
}

/* [grid-area: footer] \u2014 the model/feature pills row */
.composer-footer-pills {
    grid-area: footer;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: visible;
    scrollbar-width: none;
    padding-top: 10px;
    /* gap below primary */
}

/* [grid-area: trailing] \u2014 mic + send buttons column */
.composer-trailing {
    grid-area: trailing;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-top: 10px;
}

/* Composer Button (+ and mic) \u2014 exact: composer-btn = 36x36, transparent, rounded-full */
.composer-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.composer-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
}

/* Model selector pill \u2014 gray, rounded-full, 36px tall */
.composer-pill-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 12px;
    background: var(--bg-surface-secondary);
    border: none;
    border-radius: 999px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.composer-pill-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Send (voice) button — orange circle to match ChatGPT reference */
.send-btn {
    background: #ef6c00;
    color: #fff;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.15s;
    opacity: 1;
    flex-shrink: 0;
    padding: 0;
}

.send-btn:hover {
    opacity: 0.85;
}

/* Show send-btn when typing OR when streaming */
.composer-box:has(textarea:not(:placeholder-shown)) .send-btn,
.composer-box.streaming .send-btn {
    display: flex;
    opacity: 1;
}

/* Backward compat aliases */
.submit-btn {
    background: var(--text-primary);
    color: var(--bg-base);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.25;
    border: none;
}

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




.composer-input-area {
    display: flex;
    flex-direction: column;
    background: transparent;
    min-height: 32px;
    /* ProseMirror min-h-[2rem] */
}

/* Exact Codex textarea — 13px base, no margin on <p> */
.composer-input-area textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    /* --text-base = 13px */
    resize: none;
    outline: none;
    padding: 4px 6px;
    /* tight inside the 8px box padding */
    max-height: 180px;
    line-height: 1.5;
    /* --leading-normal */
    margin: 0;
}

.composer-input-area textarea::placeholder {
    color: var(--text-placeholder);
    opacity: 0.5;
    /* Codex uses opacity:.5 on placeholder */
}

/* Base icon button — Codex uses h-token-button-composer = 28px */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.icon-btn:hover {
    background: var(--bg-surface-secondary);
    color: var(--text-primary);
}

/* Exact Codex: grid-template-columns:minmax(0,1fr) auto auto, gap=4px (1 spacing unit) */
.composer-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 4px;
    /* gap-1 = 1 * 4px */
    padding-top: 4px;
    /* 4px between textarea and footer row */
}

.composer-footer-left {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 4px;
    /* gap-1 = 4px between + and pills */
}

.composer-footer-right {
    display: flex;
    align-items: center;
    gap: 4px;
    /* gap-1 = 4px */
    flex-shrink: 0;
}

/* Model pill — rounded-full, px-2 (8px), text-xs (11px) */
.mode-btn {
    background: rgba(128, 128, 128, 0.1);
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    /* py-1 px-2 */
    border-radius: 999px;
    /* rounded-full */
    font-weight: 500;
    font-size: 12px;
    /* text-xs */
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.mode-btn:hover {
    background: rgba(128, 128, 128, 0.18);
    color: var(--text-primary);
}

.submit-btn {
    background: var(--text-primary);
    color: var(--bg-base);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
    opacity: 0.25;
    flex-shrink: 0;
}

.mic-btn {
    opacity: 0.5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
}

.mic-btn:hover {
    opacity: 1;
    background: transparent !important;
}

/* Show submit-btn when typing OR when streaming */
.composer-box:has(textarea:not(:placeholder-shown)) .submit-btn,
.composer-box.streaming .submit-btn {
    display: flex;
    opacity: 1;
}

.composer-box:has(textarea:not(:placeholder-shown)) .submit-btn:hover,
.composer-box.streaming .submit-btn:hover {
    opacity: 0.75;
}

/* Hide mic-btn when typing OR when streaming */
.composer-box:has(textarea:not(:placeholder-shown)) .mic-btn,
.composer-box.streaming .mic-btn {
    display: none;
}

.disclaimer {
    font-size: 12px;
    color: var(--text-placeholder);
    padding-bottom: 12px;
    text-align: center;
}

/* Model Selector Dropdown */
.model-selector-container {
    position: relative;
    display: inline-block;
}

/* ===== ChatGPT-style Dropdown Popover ===== */
.model-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    min-width: 200px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
    z-index: 100;
    padding: 8px;
    overflow: hidden;
}

.model-dropdown.hidden {
    display: none;
}

/* Header label — muted gray, smaller text */
.dropdown-header {
    padding: 8px 12px 6px;
    font-size: 13px;
    color: var(--text-placeholder);
    font-weight: 400;
    user-select: none;
}

/* Each dropdown item — flex row with icon, label, checkmark */
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    transition: background 0.12s;
    text-align: left;
}

.dropdown-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Icon in each item */
.dropdown-item-icon {
    flex-shrink: 0;
    color: var(--text-secondary);
}

/* The label text fills remaining space */
.dropdown-item-label {
    flex: 1;
    font-weight: 400;
}

/* Checkmark — hidden by default, shown on .selected */
.dropdown-check {
    flex-shrink: 0;
    opacity: 0;
    color: var(--text-primary);
    transition: opacity 0.12s;
}

.dropdown-item.selected .dropdown-check {
    opacity: 1;
}

/* Pill icon color — blue to match ChatGPT "Thinking" */
.pill-icon {
    color: #2563eb;
    flex-shrink: 0;
}

/* Chevron rotation when dropdown is open */
.pill-chevron {
    transition: transform 0.15s;
}

.model-selector-container.open .pill-chevron {
    transform: rotate(180deg);
}

.model-item.loading {
    color: var(--text-secondary);
    font-style: italic;
    cursor: default;
}

.model-item.loading:hover {
    background: transparent;
}

/* ===== Tools Dropdown Menu ( (+) button ) ===== */
.tools-selector-container {
    position: relative;
    display: inline-block;
}

.tools-dropdown {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    min-width: 240px;
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
    z-index: 1000;
    padding: 8px;
}

.tools-dropdown.hidden {
    display: none;
}

.tool-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    transition: background 0.12s;
    text-align: left;
}

.tool-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.tool-icon {
    flex-shrink: 0;
    color: var(--text-primary);
    opacity: 0.8;
}

.tool-label {
    flex: 1;
    font-weight: 400;
}

.tool-arrow {
    flex-shrink: 0;
    opacity: 0.5;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-glass);
    margin: 6px 4px;
}

/* Tools Sub-menu positioning with transitions */
.tools-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 8px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    padding: 6px;
    z-index: 1001;
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    /* Smooth transition */
    opacity: 0;
    transform: translateX(-4px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tools-submenu:not(.hidden) {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    display: flex;
}

.tools-submenu.hidden {
    display: none;
}

/* Ensure sub-menu stays open when hovering from More to Submenu */
.has-submenu {
    position: relative;
}

/* Active Pills in Footer */
.active-pills-container {
    display: flex;
    gap: 8px;
    margin-right: 8px;
}

.active-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    background: transparent;
    border: none;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
    color: var(--brand-blue-gradient-end);
    cursor: pointer;
    transition: background 0.12s;
}

.active-pill:hover {
    background: rgba(37, 99, 235, 0.08);
    /* brand-blue with low opacity */
}

.active-pill .pill-icon {
    opacity: 1;
    color: var(--brand-blue-gradient-end);
}

.tool-check {
    margin-left: auto;
    color: var(--brand-blue-gradient-end);
}

.tool-check.hidden {
    display: none;
}

.tool-item.selected {
    color: var(--brand-blue-gradient-end);
}

.tool-item.selected .tool-icon {
    color: var(--brand-blue-gradient-end);
    opacity: 1;
}

/* =======================================
   LIGHT THEME OVERRIDES 
   ======================================= */
/* Removed redundant light theme overrides for composer and messages since they are flat variable-driven now */

.light-theme .code-block {
    background: #f8f9fa;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.light-theme .code-block code {
    color: #333333;
}

.light-theme .code-header {
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.light-theme .code-lang {
    color: rgba(0, 0, 0, 0.5);
}

.light-theme .thinking-block {
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.01));
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.05);
}

.light-theme .thinking-block:hover {
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.01));
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 6px 20px 0 rgba(0, 0, 0, 0.08);
}

.light-theme .thinking-content {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    color: rgba(0, 0, 0, 0.7);
}

.light-theme .task-block {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.light-theme .agent-text th {
    background: rgba(0, 0, 0, 0.05);
}

.light-theme .agent-text tr {
    background: #ffffff;
}

.light-theme .agent-text tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

.light-theme .agent-text th,
.light-theme .agent-text td {
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.light-theme .pip-video-widget {
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Removed redundant nav-icon overrides */

.light-theme ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

.light-theme ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.light-theme .sidebar {
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

/* ── SDUI Incremental Streaming Blinking Cursor ── */
.agent-text-container.streaming .sdui-conditional>div:last-child::after,
.agent-text-container.streaming .sdui-repeater>div:last-child::after,
.agent-text-container.streaming .agent-text:last-child p:last-child::after {
    content: '▋';
    display: inline-block;
    vertical-align: bottom;
    animation: sdui-blink 1s step-end infinite;
    margin-left: 2px;
    color: var(--text-primary);
}

/* Do not show a standard text cursor inside the CodeBlock's pre element */
.agent-text-container.streaming .code-block:last-child code::after {
    content: '▋';
    display: inline-block;
    vertical-align: bottom;
    animation: sdui-blink 1s step-end infinite;
    margin-left: 2px;
    color: var(--text-primary);
}

@keyframes sdui-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@media (max-width: 900px) {
    .app-shell {
        min-width: 0;
    }

    .top-nav {
        padding: 0 12px;
    }

    .chat-feed-container {
        padding: 16px 12px 128px 12px;
    }

    .welcome-hero h1 {
        font-size: 24px;
    }

    .composer-container {
        padding: 0 12px;
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }
}