/* Keep the existing light palette; only shared UI surfaces change in dark mode.
   Generated images, video, iframes, and the caption preview retain their colors. */
:root { color-scheme: light; }
.theme-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0; font-size: 12px; }
.theme-setting select { width: auto; min-width: 115px; margin: 0; padding: 7px 26px 7px 10px; font-size: 12px; }
@media (max-width: 850px) { aside .machine > .theme-setting { display: flex; width: 100%; } }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191a1c;
  --paper: #202225;
  --ink: #ededee;
  --muted: #adb0b6;
  --line: #3c3f44;
  --green: #dedee0;
  --soft: #292c30;
  --focus-ring: #91b8ff;
  --notice-info: #222e40;
  --notice-info-line: #415775;
  --notice-error: #40292b;
  --notice-error-line: #744348;
  --notice-success: #23382d;
  --notice-success-line: #41654d;
}
/* Structural surfaces, including dialogs and menus rendered outside main. */
[data-theme="dark"] :is(body > aside, body.sidebar-open > aside, .kms-library, .settings, .playground-settings, .lab-generation-settings) { background: #202225; border-color: var(--line); }
[data-theme="dark"] :is(dialog, #mediaOptionsDialog, .job-dialog, .action-dialog, .history-search-dialog, .history-action-popover, .compact-menu, .turn-menu, .read-aloud-player, .live-mini, .kms-shell, .playground-stage, .lab-generation-stage, .interactive-content, .generate-bar, .new-work, .chat-example, .local-badge) { background: var(--paper); color: var(--ink); border-color: var(--line); }
[data-theme="dark"] .locked > #loginScreen { background: var(--bg); }
[data-theme="dark"] :is(.card, .chat-turn, .job, .source-card, .read-aloud-preferences, .viewer-tabs, .response-viewer, .response-code, .response-markdown hr, .response-markdown th, .response-markdown td, .viewer-content details, .interactive-detail) { border-color: var(--line); }
[data-theme="dark"] :is(textarea, select, input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), #chatRequest, .compact-menu select, .live-voice-dialog select, .kms-shell input[type="search"], .kms-library input, .kms-source-location select, .lab-generation-settings textarea) { background: #292c30; color: var(--ink); border-color: var(--line); }
[data-theme="dark"] :is(textarea, input)::placeholder { color: #999da5; }
[data-theme="dark"] :is(.chat-composer, .chat-composer textarea, .chat-composer #chatRequest) { background: #292c30; border-color: var(--line); }
[data-theme="dark"] .chat-composer:focus-within { border-color: #9298a2; }
[data-theme="dark"] :is(.secondary, .segmented, .sidebar-toggle, .status-badge, .model-status-chip, .metric-badge, .lab-mode-bar > div, .live-orb, #liveLoad, .live-idle, .reasoning-toggle, .composer-tool-state) { background: #303339; color: var(--ink); border-color: var(--line); }
[data-theme="dark"] :is(.primary, .kms-upload-cta, .playground-environments button.selected, .interactive-tabs button[aria-pressed="true"], .interactive-content > button[aria-pressed="true"], .live-voice-dialog .voice-input-actions button, .inline-response-viewer button[aria-pressed="true"]) { background: #dedee0; color: #191a1c; border-color: #dedee0; }
[data-theme="dark"] .live-voice-dialog .voice-input-actions .secondary { background: #303339; color: var(--ink); }
[data-theme="dark"] :is(.nav.active, .history-item.selected, .segmented button.selected, .workspace-switch button[aria-pressed="true"], .workspace-projects button[aria-pressed="true"], .history-fold .history-filters .selected, .lab-mode-bar button.selected, .playground-mobile-panes button.selected, .kms-doc.current, .kms-chunk-link.current) { background: #373b41; color: var(--ink); border-color: #565d67; }
[data-theme="dark"] body[data-workspace="chat"] #taskHistory .history-row:has(.selected) { background: #373b41; }
[data-theme="dark"] :is(.nav, .history-item, .file-button, .chat-settings-link, .chat-empty, .chat-title, .composer-tool-name, .kms-prose, .kms-empty h2, .kms-actions a, .kms-actions button, .kms-chunk-link, .history-action-popover > button, .playground input, .chat-example, .delete-confirm-dialog p) { color: var(--ink); }
[data-theme="dark"] :is(.hint, .muted, label, .eyebrow, .history-label, .history-retention, .local-badge, .login-card p, .chat-turn-actions button, .chat-turn-metrics, .chat-turn-time, .chat-processing-time, #chatStreamStatus, #routeHint, #chatTitle, .turn-more, .icon-action, .history-more > summary, .chat-library > summary, .chat-metrics dt, .chat-settings-link, .compact-toolbar .composer-model-button, .composer-selection button, .project-heading strong, .sidebar-projects-head, .sidebar-projects-head strong, .workspace-projects > .text-button, #sidebarCollapse, #historySearchToggle, .search-palette-label, .search-palette-status, .search-palette-meta, .search-palette-snippet, .search-palette-empty, .search-palette-row svg, .composer-menu-heading, .composer-tool-description, .composer-tool-state, .reasoning-head, .reasoning-stops label, .live-models label, #liveStatus, #liveMiniStatus, .live-settings > summary, .live-transcript strong, .live-mini-words p + p, .voice-expression-settings > summary, .kms-doc small, .kms-file-type, .kms-library-note, .kms-empty, .kms-eyebrow, .kms-tabs button, #kmsSourceStatus, .kms-source-section h3, .kms-chunk-link span, .kms-chunk-link small, .kms-info dt, .code-project-picker > label, .code-welcome p, .code-boundary, #codeCapability, .playground .hint, .playground-width, .lab-empty, .lab-mode-bar button, .playground-tabs button, .interactive-description, .chat-example small, .send-shortcut, .progress-info, .result-tools span, .section-top > span, footer, .memory-stats dt, .code-header, .image-prompt-log summary, .image-prompt-log strong, #chatSettingsDrawer > summary, .workspace-switch button, .media-request > button, .live-ready) { color: var(--muted); }
[data-theme="dark"] .chat-turn-label { color: var(--muted) !important; }
[data-theme="dark"] :is(.chat-turn.user, .chat-turn.pending, .bubble.user, .media-user-prompt, .lab-user-prompt, .chat-attachment, .document-choices label, .file-item, .decision-choice, .decision-case, .decision-study-intro, .study-code, .activity-strip, #jobDialogStatus, #jobLogText, .chat-metrics dt, .chat-metrics dd, .viewer-content pre, .response-markdown code, .response-markdown th, .response-code pre, .code-header, .code-diff pre, .code-test pre, .source-card blockquote, .compact-menu #chatDocuments label, .live-transcript p, .knowledge-text, #knowledgeVector, .code-prompts button, .playground-environments button, #decisionPanel .decision-choice, .playground-input-summary, .playground-mobile-panes button, .interactive-tabs button, .interactive-content > button, .interactive-detail) { background: #292c30; border-color: var(--line); }
[data-theme="dark"] :is(.chat-turn.user, .chat-turn.pending) > .chat-user-text { background: #383c43; color: var(--ink); }
[data-theme="dark"] :is(.response-markdown a, .reasoning-head output) { color: #9bc2ff; }
[data-theme="dark"] .response-markdown blockquote { color: var(--muted); border-color: #606873; }
[data-theme="dark"] :is(.viewer-tabs button[aria-selected="true"], .kms-tabs button[aria-selected="true"], .playground-tabs button[aria-selected="true"]) { color: var(--ink); border-color: var(--ink); }
/* Hover and status colors remain distinguishable on dark surfaces. */
[data-theme="dark"] :is(.nav:hover, .history-item:hover, .icon-action:hover, .turn-menu button:hover, .compact-menu > button:hover, .composer-selection button:hover, .compact-toolbar .composer-model-button:hover, #sidebarCollapse:hover, #historySearchToggle:hover, .search-palette-row:hover, .kms-doc:hover, .kms-chunk-link:hover, .model-status-chip:hover, .chat-example:hover) { background: #34383e; color: var(--ink); border-color: #565d67; }
[data-theme="dark"] :is(.search-palette-row, .playground-environments button span, .playground-environments button.selected span) { color: var(--muted); }
[data-theme="dark"] :is(.status-badge.running, .status-badge.queued, .live-preview button, .reasoning-toggle[aria-checked="true"]) { background: #24354d; color: #aacbff; }
[data-theme="dark"] :is(.status-badge.succeeded, .chat-live, .chat-progress, #analysis, #decisionMessages .bubble.assistant, .composer-tool.selected .composer-tool-state) { background: #253b31; color: #b3dec1; border-color: #41654d; }
[data-theme="dark"] .analysis-title { color: #b3dec1; }
[data-theme="dark"] #decisionMessages .bubble.user { background: #24354d; color: #c0d8ff; border-color: #415775; }
[data-theme="dark"] :is(.failure-summary, .status-badge.failed, .status-badge.interrupted, .notice-error) { background: #40292b; color: #ffc0b7; border-color: #744348; }
[data-theme="dark"] :is(.error, #memoryShortage, .lc-dialog-status[data-tone="error"], .history-action-popover > button:last-child) { color: #ffafa7; }
[data-theme="dark"] :is(.chat-warning, .edit-banner) { background: #3c3422; color: #efd397; border-color: #8c7542; }
[data-theme="dark"] .notice-item { color: var(--ink); }
[data-theme="dark"] .notice-error { color: #ffc0b7; }
[data-theme="dark"] .notice-success { color: #b3dec1; }
[data-theme="dark"] .kms-prose mark { background: #695922; color: #fff4cb; }
[data-theme="dark"] .kms-prose mark.current-match { background: #9e7820; color: white; }
[data-theme="dark"] .kms-source-match { background: #304563 !important; }
[data-theme="dark"] .login-card { background: var(--paper); border-color: var(--line); }
[data-theme="dark"] :is(.playground-environments button[aria-pressed="true"], .interactive-tabs button[aria-pressed="true"], .interactive-content > button[aria-pressed="true"]) { background: #dedee0; color: #191a1c; border-color: #dedee0; }
[data-theme="dark"] .playground-environments button[aria-pressed="true"] span { color: #36383d; }
[data-theme="dark"] .reasoning-control .reasoning-head .reasoning-toggle { background: #303339; color: var(--muted); }
[data-theme="dark"] .reasoning-control .reasoning-head .reasoning-toggle[aria-checked="true"] { background: #24354d; color: #aacbff; }
[data-theme="dark"] .reasoning-control .reasoning-stops button { color: var(--muted); }
[data-theme="dark"] .reasoning-control .reasoning-stops button[aria-pressed="true"] { color: #aacbff; }
[data-theme="dark"] :is(.lc-dialog-status[data-tone="warn"], .job-stage.running) { color: #efd397; }
[data-theme="dark"] .chat-empty p { color: var(--muted); }
[data-theme="dark"] body > aside .workspace-projects { border-color: var(--line); }
[data-theme="dark"] .history-fold .history-filters button[aria-pressed="true"] { background: #373b41; color: var(--ink); }
[data-theme="dark"] :is(.lab-mode-bar button[aria-pressed="true"], .playground-mobile-panes button[aria-pressed="true"]) { background: #373b41; color: var(--ink); }
[data-theme="dark"] .kms-upload-cta { color: #191a1c; }
[data-theme="dark"] .kms-upload-cta:hover { background: #c2c4c9; }
/* Loaded rows and their available release action are distinct in both themes. */
.model-manager-row[data-state="ready"], .model-manager-row[data-state="busy"] { background: #f0f7f2; border-color: #6b9e7a; border-left-width: 4px; }
button.model-unload-active:not(:disabled) { background: #fff0db; border-color: #c78635; color: #75420b; font-weight: 650; }
button.model-unload-active:not(:disabled):hover { background: #ffe1b5; }
[data-theme="dark"] .model-manager-row[data-state="ready"], [data-theme="dark"] .model-manager-row[data-state="busy"] { background: #25362c; border-color: #567d61; }
[data-theme="dark"] button.model-unload-active:not(:disabled) { background: #503b24; border-color: #b68a4b; color: #ffe0a6; }
[data-theme="dark"] button.model-unload-active:not(:disabled):hover { background: #65492a; }
