/* chat-modern split: dark theme overrides. Loaded last so the dark
   surfaces win over the light defaults. */

/* ── Dark theme: same calm surfaces, dark-gray borders ──────────────── */

[data-color-scheme="dark"] #chat-app,
[data-color-scheme="dark"] .chat-sidebar {
    /* Same identity mapping as the light block: a dark theme's own palette
       already supplies the dark values, so there is no second palette here. */
    --gb-bg: var(--id-paper);
    --gb-surface: var(--id-surface-solid);
    --gb-surface-muted: var(--id-fill);
    --gb-text: var(--id-ink);
    --gb-muted: var(--id-muted);
    --gb-border: var(--id-line);
    --gb-border-soft: var(--id-line-soft);
    --gb-border-strong: var(--id-accent);
    --gb-accent: var(--id-accent);
    --gb-accent-soft: var(--id-accent-soft);
    --gb-shadow-bubble: var(--id-shadow-card);
    --gb-shadow-raised: var(--id-shadow-float);
    --gb-focus-ring: 0 0 0 3px var(--id-accent-soft);
}

[data-color-scheme="dark"] #chat-app .user-message {
    background: var(--gb-surface-muted);
    color: var(--gb-text);
    border-color: var(--gb-border);
}

[data-color-scheme="dark"] #chat-app .bot-message {
    background: var(--gb-surface);
    border-color: var(--gb-border-soft);
    color: var(--gb-text);
}

[data-color-scheme="dark"] #chat-app .bot-message,
[data-color-scheme="dark"] #chat-app .bot-message p,
[data-color-scheme="dark"] #chat-app .bot-message span,
[data-color-scheme="dark"] #chat-app .bot-message li,
[data-color-scheme="dark"] #chat-app .bot-message strong,
[data-color-scheme="dark"] #chat-app .bot-message h1,
[data-color-scheme="dark"] #chat-app .bot-message h2,
[data-color-scheme="dark"] #chat-app .bot-message h3 {
    color: var(--gb-text) !important;
}

[data-color-scheme="dark"] #chat-app .bot-message pre {
    background: var(--surface);
    color: var(--text);
}

[data-color-scheme="dark"] #chat-app .run-card {
    background: var(--surface);
    border-color: var(--gb-border-soft);
}
[data-color-scheme="dark"] #chat-app .run-title { color: var(--text-secondary); }
[data-color-scheme="dark"] .window-element,
[data-color-scheme="dark"] .window-element-glass {
    border-color: var(--gb-border-strong, var(--border-light));
}

/* Only the window that hosts the chat uses a neutral frame. The theme's
   focused border is a near-black green, which is exactly the hard edge the
   design review rejected. */
.window-element-glass:has(#chat-app),
.window-element:has(#chat-app),
.window-element-glass:has(#chat-app).window-focused,
.window-element:has(#chat-app).window-focused {
    border-color: var(--gb-border-strong, var(--border-light));
}

/* The window loading indicator inherited the theme's near-black green.
   A neutral track + brand arc is the same information without the hard edge. */
.gb-window-loading-spinner {
    border-color: var(--border-light);
    border-top-color: var(--success);
}

[data-color-scheme="dark"] .window-element-glass:has(#chat-app),
[data-color-scheme="dark"] .window-element:has(#chat-app),
[data-color-scheme="dark"] .window-element-glass:has(#chat-app).window-focused,
[data-color-scheme="dark"] .window-element:has(#chat-app).window-focused {
    border-color: var(--border-light);
}

[data-color-scheme="dark"] .gb-window-loading-spinner {
    border-color: var(--border-light);
    border-top-color: var(--success);
}

/* Run cards are flex children of the transcript. Without an explicit
   flex-basis the browser shrank them to a 2.5 px line; keep their header
   height whatever the transcript length. */
#chat-app #messages > .run-card {
    flex: 0 0 auto;
    width: fit-content;
    min-width: 220px;
    max-width: min(760px, 100%);
}


/* Dark chrome: the header/status bars are hardcoded white in the light
   shell. Leaving them white while the conversation is dark breaks the
   window into two products. */
[data-color-scheme="dark"] .window-element-glass:has(#chat-app) .window-header-glass,
[data-color-scheme="dark"] .window-element:has(#chat-app) .window-header,
[data-color-scheme="dark"] .window-element-glass .window-header-glass,
[data-color-scheme="dark"] .window-element .window-header {
    background: var(--surface);
    border-bottom-color: var(--border-light);
}

[data-color-scheme="dark"] .window-element-glass .window-title,
[data-color-scheme="dark"] .window-element .window-title {
    color: var(--text);
}

[data-color-scheme="dark"] .window-element-glass:has(#chat-app) .window-body,
[data-color-scheme="dark"] .window-element:has(#chat-app) .window-body,
[data-color-scheme="dark"] .window-element-glass .window-body,
[data-color-scheme="dark"] .window-element .window-body {
    background: var(--bg);
}

[data-color-scheme="dark"] .window-element-glass:has(#chat-app) .window-statusbar,
[data-color-scheme="dark"] .window-element:has(#chat-app) .window-statusbar,
[data-color-scheme="dark"] .window-element-glass .window-statusbar,
[data-color-scheme="dark"] .window-element .window-statusbar {
    background: var(--bg);
    border-top-color: var(--border-light);
    color: var(--text-secondary);
}

[data-color-scheme="dark"] #chat-app footer {
    background: var(--bg);
}

[data-color-scheme="dark"] #chat-app .input-container {
    background: var(--surface);
    border-color: var(--border-light);
}

[data-color-scheme="dark"] #chat-app .input-container:focus-within {
    border-color: rgba(74, 222, 128, 0.55);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}


/* Suggestion chips inherit the light-mode var(--surface-hover) text, which is almost
   invisible on the dark canvas. */
[data-color-scheme="dark"] #chat-app .suggestion-chip,
[data-color-scheme="dark"] #chat-app .suggestion-button {
    color: var(--gb-muted);
}
