:root {
  --glass-rim: #ffffffb8;
  --glass-sheen: #ffffffb8;
  --glass-tint: #fafffc92;
  --glass-face: #f2f9f5d9;
  --glass-depth: #315f4d24;
  --glass-reflection: #8ccbb63d;
  --brand-name: #193c43;
  --brand-ai: #875116;
}

html[data-theme='dark'] {
  color-scheme: dark;
  --base: #0b1720;
  --paper: #10252b;
  --line: #31575e;
  --green: #70e1bf;
  --ink: #e8fbf5;
  --secondary: #adc9c8;
  --chrome: #102a31;
  --glass: #102a31ed;
  --accent-wash: #163b40;
  --focus: #89efcf;
  --send: #f3bd67;
  --send-hover: #ffcf80;
  --send-text: #20291e;
  --rim: inset 0 1px 0 #d0f3e31c;
  --card-shadow: 0 6px 20px #0003;
  --glass-rim: #8fe6ca5c;
  --glass-sheen: #b9f7e635;
  --glass-tint: #173b40d9;
  --glass-face: #1a3c40ed;
  --glass-depth: #0005;
  --glass-reflection: #8ccbb62b;
  --brand-name: #e8fbf5;
  --brand-ai: #ffd17d;
}

[data-theme='dark'] body {
  background: radial-gradient(ellipse at 13% 15%, #203a32, transparent 60%), var(--base);
}

.chat-shell { isolation: isolate; }

/* The three sage ribbons use the handoff's oval shapes and proportions. */
.workspace-landscape {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(ellipse at 15% 5%, #f4f1e7aa, transparent 62%), linear-gradient(120deg, #f0f4ee 5%, #eef5f2 54%, #dcebea);
}

.workspace-ribbon {
  position: absolute;
  display: block;
  transform: rotate(-24deg);
  border: 1px solid #ffffff70;
  border-radius: 50%;
  box-shadow: inset 12px 30px 65px #ffffff30, 0 -8px 45px #faffff35;
}

.workspace-ribbon-1 { width: 150vw; height: 94vw; left: -43vw; top: 59vh; background: linear-gradient(140deg, #b5d0c508, #abc7c35c); }
.workspace-ribbon-2 { width: 145vw; height: 90vw; left: -32vw; top: 68vh; background: linear-gradient(140deg, #d5e3d920, #86b0a960); }
.workspace-ribbon-3 { width: 140vw; height: 85vw; left: -17vw; top: 79vh; background: linear-gradient(140deg, #dae8e210, #6b9d9466); }

[data-theme='dark'] .workspace-landscape { background: radial-gradient(ellipse at 88% 13%, #77542726, transparent 46%), radial-gradient(ellipse at 15% 72%, #17766b35, transparent 60%), #0b1720; }
[data-theme='dark'] .workspace-ribbon { opacity: .65; border-color: #8fe6ca24; box-shadow: inset 12px 30px 65px #326b6d26; }
[data-theme='dark'] .workspace-ribbon-1 { background: linear-gradient(140deg, #10232c, #173b43); }
[data-theme='dark'] .workspace-ribbon-2 { background: linear-gradient(140deg, #15343c, #20554f); }
[data-theme='dark'] .workspace-ribbon-3 { background: linear-gradient(140deg, #143a3c, #28736a); }

.chat-shell .topbar {
  gap: 10px;
  min-height: 64px;
  height: 64px;
  padding: 8px 24px;
  border-bottom-color: #8094a819;
  background: var(--glass-tint);
}

.topbar .identity {
  flex: none;
  gap: 5px;
  color: var(--ink);
  white-space: nowrap;
  min-height: 44px;
  padding-inline: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--chrome);
  box-shadow: inset 0 1px 0 var(--glass-rim);
}

.brand-wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: 13.5px;
  line-height: 1.2;
  letter-spacing: .005em;
  white-space: nowrap;
}
.brand-wordmark .brand-name { color: var(--brand-name); font-weight: 600; }
.brand-wordmark .brand-ai {
  color: var(--brand-ai);
  font-size: inherit;
  font-weight: 600;
  line-height: inherit;
  letter-spacing: inherit;
}
.topbar .identity-name { font-size: 13.5px; }
.assistant-label .brand-wordmark { font-size: 13px; }
.assistant-label { gap: 6px; }
.topbar .identity:hover,
.history .sidebar-brand:hover {
  color: var(--green);
  background: var(--accent-wash);
  border-color: var(--green);
  box-shadow: inset 0 1px 0 var(--glass-rim), 0 0 0 2px var(--glass-reflection);
  text-decoration: none;
}
.topbar .identity:hover .brand-name { color: var(--green); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.topbar .identity:active,
.history .sidebar-brand:active {
  color: var(--ink);
  background: var(--accent-wash);
  border-color: var(--green);
  box-shadow: inset 0 2px 5px var(--glass-depth);
}
.topbar .identity:active .brand-name { color: var(--brand-name); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.topbar .identity:focus-visible,
.history .sidebar-brand:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.topbar .identity:focus-visible .brand-name { text-decoration: underline; text-underline-offset: 4px; }
.history .sidebar-brand { width: 44px; height: 44px; flex: none; padding: 0; border-radius: 12px; box-shadow: inset 0 1px 0 var(--glass-rim); }
.topbar .conversation-title { color: var(--secondary); }
.topbar .dev-label { margin-left: 0; color: var(--secondary); background: var(--accent-wash); border-color: var(--line); }

.workspace-actions {
  display: flex;
  align-items: center;
  margin-left: auto;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--glass-rim);
  border-radius: 100px;
  background-color: var(--glass-tint);
  box-shadow: 0 9px 25px var(--glass-depth), inset 0 1px 0 var(--glass-rim);
  -webkit-backdrop-filter: blur(20px) saturate(125%);
  backdrop-filter: blur(20px) saturate(125%);
}

.workspace-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 12px;
  background-color: transparent;
  color: var(--green);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.workspace-actions .workspace-action { border-radius: 100px; }

.workspace-action svg,
.starter svg,
.demo-icon svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.workspace-action:hover:not(:disabled),
.topbar .history-trigger:hover:not(:disabled),
.composer .icon-button:hover:not(:disabled):not(.send) {
  color: var(--green);
  border-color: var(--line);
  background-color: var(--accent-wash);
}

.chat-shell .topbar :is(.history-trigger, #appearance-open),
.chat-shell .workspace-actions #reports-open,
.chat-shell .composer :is(#composer-more, #mic),
.welcome .demo-button {
  border: 1px solid var(--glass-rim);
  background-color: var(--glass-face);
  background-image: radial-gradient(85px circle at var(--aura-x, 28%) var(--aura-y, 0%), var(--glass-sheen), transparent 72%), linear-gradient(155deg, transparent 44%, var(--glass-reflection));
  box-shadow: 0 3px 10px var(--glass-depth), inset 0 1px 0 var(--glass-rim), inset 0 -1px 1px var(--glass-reflection);
}

.chat-shell .topbar .history-trigger { border-radius: 12px; }
.chat-shell .composer :is(#composer-more, #mic) { border-radius: 12px; }

.workspace-action,
.starter,
.demo-button,
.composer .icon-button,
.glass-control,
.response-tools button { transition: background-color .16s, border-color .16s, transform .12s; }

@media (hover: hover) {
  :root:not([data-motion='reduce']):not([data-solid='true']) :where(.workspace-action, .starter, .demo-button, .composer .icon-button, .glass-control, .response-tools button):hover:not(:disabled, [aria-disabled='true']) {
    background-image: radial-gradient(circle 38px at var(--aura-x, 50%) var(--aura-y, 50%), var(--aura), transparent);
  }

  :root:not([data-motion='reduce']):not([data-solid='true']) .composer .send:hover:not(:disabled) {
    background-image: radial-gradient(circle 36px at var(--aura-x, 50%) var(--aura-y, 50%), var(--aura-primary), transparent);
  }
}

:root:not([data-motion='reduce']) :where(.workspace-action, .starter, .demo-button, .composer .icon-button, .glass-control, .response-tools button):active:not(:disabled, [aria-disabled='true']) { transform: scale(.97); }

body .chat-shell main,
body:not(.needs-auth) .chat-shell main { width: min(100% - 32px, var(--workspace-reading-width, 800px)); }

body:not(.needs-auth) .chat-shell main:has(.welcome:not([hidden])) { width: calc(100% - 32px); }

.chat-shell main.has-messages,
#composer-chat { background: var(--paper); }

body:not(.needs-auth) .chat-shell:has(.has-messages) { background: var(--paper); }

.chat-shell .welcome {
  flex: 0 0 auto;
  width: 100%;
  margin: auto 0;
  padding: clamp(18px, 6vh, 68px) 0 clamp(20px, 5vh, 54px);
}

.chat-shell .welcome h1 {
  max-width: 740px;
  margin: 0 auto 10px;
  color: var(--ink);
  font-size: clamp(26px, 4.6vw, 39px);
}

.welcome #welcome-copy {
  max-width: 47ch;
  margin: 0 auto;
  color: var(--secondary);
  font-size: clamp(14px, 1.7vw, 16px);
  line-height: 1.55;
}

.chat-shell #composer-landing .composer-area,
.chat-shell #composer-chat .composer-area {
  width: min(100% - 32px, var(--workspace-reading-width, 800px));
  background: var(--paper);
  margin: 0 auto;
}

.chat-shell #composer-landing .composer-area {
  width: min(100%, 640px);
  padding: 0;
  margin-top: 24px;
  background: transparent;
}

.chat-shell #composer-chat { flex: none; }
.needs-auth #composer-chat { background: transparent; }
.needs-auth .chat-shell #composer-chat .composer-area { background: transparent; }

.chat-shell .composer {
  grid-template-columns: 44px minmax(0, 1fr) 44px minmax(44px, max-content);
  align-items: end;
  border-radius: 19px;
  background: var(--paper);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#composer-landing .composer {
  box-shadow: 0 18px 60px #315a4c18, 0 4px 10px #315a4c0a, inset 0 1px 0 var(--glass-rim);
}

#composer-landing .composer:focus-within {
  box-shadow: 0 0 0 1px var(--focus), 0 18px 60px #315a4c18, inset 0 1px 0 var(--glass-rim);
}

#composer-landing .composer {
  grid-template-rows: auto auto;
  padding: 9px;
  gap: 4px;
  text-align: left;
}

.composer .composer-add { grid-column: 1; }
.composer #mic { grid-column: 3; }
.composer #send, .composer #stop-request { grid-column: 4; }
#composer-chat .composer textarea { grid-column: 2; }

.composer #stop-request {
  width: auto;
  padding-inline: 12px;
  border-radius: 12px;
  background-color: var(--accent-wash);
  color: var(--ink);
}

.composer #stop-request:disabled { background: var(--accent-wash); color: var(--secondary); }
#check-request { display: block; margin: 4px auto 0; min-height: 44px; color: var(--green); }

.composer textarea {
  min-height: 44px;
  max-height: 180px;
  padding: 10px 6px;
  color: var(--ink);
  font-size: 16px;
  overflow-y: auto;
}

#composer-landing .composer textarea {
  grid-area: 1 / 1 / 2 / -1;
  min-height: 52px;
  padding: 4px 6px 0;
}

.composer textarea::placeholder { color: var(--secondary); }
.composer .icon-button { color: var(--green); }
.composer .icon-button:disabled:not(.send) { color: var(--secondary); }
.composer .send { background-color: var(--send); color: var(--send-text); }
.composer .send:hover:not(:disabled) { background-color: var(--send-hover); }
.composer .send:disabled { background-color: var(--accent-wash); color: var(--secondary); }
.composer .send:not(:disabled) { border-radius: 11px; box-shadow: 0 4px 12px #1a574b22, inset 0 1px 0 #d5ffe440, inset 0 -2px 3px #092f3633; }
.chat-shell .composer :is(#composer-more, #mic):disabled { background: var(--accent-wash); border-color: var(--line); box-shadow: none; }
.chat-shell .composer #mic[aria-pressed='true'] { background: #fae2db; color: #922f21; }

.composer-menu {
  max-width: min(280px, 100vw - 50px);
  background: var(--paper);
  border-color: var(--line);
}

#composer-landing .composer-menu { top: calc(100% + 5px); bottom: auto; }
.composer-menu .composer-menu-action { color: var(--ink); }
.composer-menu .composer-menu-action:hover:not(:disabled) { background: var(--accent-wash); }
.composer-menu-action span { color: var(--secondary); }

.workspace-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.workspace-status .status { margin: 0 0 5px; }
.status, .configuration, .composer-meta .credit-status { color: var(--secondary); }
.composer-meta .credit-status > summary { min-height: 44px; }
.credit-status > summary:hover, .credit-status[open] > summary { background: var(--accent-wash); }
.credit-details { background: var(--paper); color: var(--ink); border-color: var(--line); }
.credit-details p:last-child { color: var(--secondary); }

.welcome .welcome-actions {
  max-width: 640px;
  display: grid;
  justify-items: center;
  gap: 14px;
  margin: 16px auto 0;
}

.welcome .starter-prompts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(100%, 450px); gap: 12px; margin: 0; }

.welcome .starter {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 2px 0;
  border-color: transparent;
  background: none;
  box-shadow: none;
  text-align: center;
  color: var(--ink);
  font-size: 12px;
}

.welcome .starter svg {
  width: 54px;
  height: 54px;
  padding: 15px;
  border: 1px solid var(--glass-rim);
  outline: 1px solid var(--glass-reflection);
  border-radius: 13px;
  background: radial-gradient(60px circle at 27% 0%, var(--glass-sheen), transparent 78%), linear-gradient(145deg, var(--glass-face), var(--glass-reflection));
  box-shadow: 0 4px 13px var(--glass-depth), inset 0 1px 0 var(--glass-rim), inset 0 -1px 1px var(--glass-reflection);
  color: var(--green);
}

.welcome .starter:hover:not(:disabled) svg { box-shadow: 0 6px 16px var(--glass-depth), 0 0 0 2px var(--glass-reflection), inset 0 1px 0 var(--glass-rim); }
.welcome .starter:disabled svg { background: var(--accent-wash); box-shadow: none; }
.welcome .demo-button { width: fit-content; max-width: 100%; padding: 8px 12px; color: var(--ink); gap: 9px; }
.welcome .demo-button .demo-copy { margin-left: 0; color: var(--ink); }
.demo-icon { flex: none; width: 38px; height: 38px; background: #dbece3; color: #226b5c; border-radius: 12px; }
.demo-icon svg { width: 23px; height: 23px; }
.demo-button small { color: var(--secondary); }

#reports-sidebar-open { justify-content: flex-start; padding-inline: 12px; }
#logout { min-height: 44px; padding: 7px 10px; border-radius: 10px; }

.auth-panel {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--card-shadow);
}

.auth-panel { width: min(100%, 390px); padding: 22px 24px; }
.needs-auth .chat-shell .welcome { margin: 0; padding: 12px 0 22px; }
.auth-panel h2, .auth-panel label { color: var(--ink); }
.auth-panel input { border-color: var(--line); color: var(--ink); background: var(--paper); }
.auth-panel .auth-submit { background: var(--send); color: var(--send-text); border-color: var(--send); }
.auth-panel .auth-submit:hover:not(:disabled) { background: var(--send-hover); }
.auth-panel .google-signin, .auth-panel .auth-switch { background: var(--accent-wash); color: var(--green); border-color: var(--line); }

#kp-header, #kp-sidebar, #kp-status, [data-kp-response], [data-kp-thinking] { display: inline-flex; flex: none; }
[data-kp-response] { order: -1; }
.assistant-label:has([data-kp-response])::before { content: none; }
.kp-avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: radial-gradient(circle, var(--accent-wash), transparent 73%); }
[data-kp-response] .kp-avatar { width: 32px; height: 32px; }
#kp-status .kp-avatar, [data-kp-thinking] .kp-avatar { width: 24px; height: 24px; transform-origin: center; }
[data-kp-thinking] { width: 24px; height: 24px; align-items: center; justify-content: center; }
.thinking-line:has([data-kp-thinking]) { min-height: 28px; }
.thinking-line:has([data-kp-thinking])::before { content: none; }
.analysis-progress-card:has([data-kp-thinking]) { align-items: center; justify-content: flex-start; gap: 8px; }
.analysis-progress-card:has([data-kp-thinking]) > .analysis-progress { flex: 1; min-width: 0; }
.kp-avatar svg { width: 100%; height: 100%; }
.kp-edges { stroke: var(--green); stroke-width: .8; opacity: .22; }
.kp-letter { fill: var(--green); }
.kp-node { fill: var(--green); opacity: .25; }
.kp-signal { stop-color: transparent; }
.kp-avatar[data-pass='forward'] .kp-signal { stop-color: #00a783; }
.kp-avatar[data-pass='backward'] .kp-signal { stop-color: #b97a21; }
[data-theme='dark'] .kp-avatar[data-pass='forward'] .kp-signal { stop-color: #acffdd; }
[data-theme='dark'] .kp-avatar[data-pass='backward'] .kp-signal { stop-color: #ffca78; }

[data-theme='dark'] :is(.feedback-dialog, .composer-menu, .workflow, .analysis-brief, .analysis-chart, .run, .breakdown, .brief-details, .verification-log, .previous-versions, .artifact, .citation-claim, .action-table, .action-dictionary, .action-implementation, .chart-table, .auth-panel input, .feedback-form :is(input, textarea, select)) {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line);
}

[data-theme='dark'] :is(.feedback-dialog, .assistant-activity, .analysis-brief, .analysis-chart, .action-plan, .artifact, .drawer-account, .history-label, .session, .welcome-actions) :is(p, small, h3, h4, .muted) { color: var(--secondary); }
[data-theme='dark'] :is(.assistant-label, .message-body, .analysis-progress, .thinking-status, .drawer-account > span, .session, .mail-account, .auth-hint, .auth-status) { color: var(--ink); }
[data-theme='dark'] :is(.chat-shell, .history, .feedback-dialog) a { color: var(--green); }
[data-theme='dark'] :is(.message-body pre, .markdown-table th, .action-table th, .chart-table th, .skill-chip, .analysis-progress-card) { background: var(--accent-wash); color: var(--ink); }
[data-theme='dark'] .history { box-shadow: var(--card-shadow); }

[data-solid='true'] body { background: var(--base); }
[data-solid='true'] :is(.chat-shell .topbar, .history, .workspace-actions) { background: var(--chrome); -webkit-backdrop-filter: none; backdrop-filter: none; }
[data-solid='true'] :is(.chat-shell .topbar .history-trigger, .chat-shell .workspace-actions #reports-open, .chat-shell .composer #composer-more, .chat-shell .composer #mic, .welcome .demo-button, .welcome .starter svg) { background: linear-gradient(150deg, var(--chrome), var(--accent-wash)); border-color: var(--line); box-shadow: inset 0 1px 0 var(--glass-rim), 0 3px 10px var(--glass-depth); }
[data-solid='true'] .chat-shell .composer #mic[aria-pressed='true'] { background: #fae2db; color: #922f21; }
[data-motion='reduce'] :is(.chat-shell, .history, .feedback-dialog),
[data-motion='reduce'] :is(.chat-shell, .history, .feedback-dialog) *,
[data-motion='reduce'] .thinking-line::before { animation: none; transition: none; }

/* One-click theme switch: the icon shows the mode available on the next click. */
#appearance-open .theme-sun { display: none; }
[data-theme='dark'] #appearance-open .theme-moon { display: none; }
[data-theme='dark'] #appearance-open .theme-sun { display: block; }
.chat-shell .workspace-actions #appearance-open {
  color: #245e58;
  background: #f6eddd;
  border-color: #cfbf9e;
  box-shadow: inset 0 1px 0 #fff9, 0 2px 7px #59492714;
}
.chat-shell .workspace-actions #appearance-open:hover { color: #174d46; background: #f9e4bf; border-color: #b7a078; }
[data-theme='dark'] .chat-shell .workspace-actions #appearance-open {
  color: #ffd17d;
  background: #423b2b;
  border-color: #a78348;
  box-shadow: inset 0 1px 0 #ffe0a64d, 0 0 0 1px #241c1070;
}
[data-theme='dark'] .chat-shell .workspace-actions #appearance-open:hover { color: #ffe1a5; background: #57472c; border-color: #d9a85a; }
[data-theme='dark'] .chat-shell .topbar { border-bottom-color: #3e6d71; }
[data-theme='dark'] .welcome .starter:nth-child(2) svg { color: #f3c57d; border-color: #8b754c; }
[data-theme='dark'] .welcome .starter:nth-child(3) svg { color: #98cde9; border-color: #4e7b91; }
[data-theme='dark'] .welcome .demo-button { border-color: #54877c; }
[data-theme='dark'] .demo-icon { background: #514329; color: #ffd17d; box-shadow: inset 0 1px 0 #ffde9c38; }
[data-theme='dark'] .composer .send:not(:disabled) { border-color: #ffda91; box-shadow: 0 3px 14px #efb55926, inset 0 1px 0 #fff1c48c; }

/* Explicit interaction states override legacy light disabled/sidebar rules. */
html[data-theme='dark'] :is(.chat-shell, .history) :is(#new-chat, #reports-sidebar-open, #reports-open, #logout, #history-toggle, #history-close, #feedback-open):not(:disabled) {
  color: #baf3df;
  background: #163b40;
  border: 1px solid #3e6d71;
  opacity: 1;
  box-shadow: inset 0 1px 0 #9edbc32e;
}
html[data-theme='dark'] :is(.chat-shell, .history) :is(#new-chat, #reports-sidebar-open, #reports-open, #logout, #history-toggle, #history-close, #feedback-open):hover:not(:disabled) {
  color: #edfff7;
  background: #245257;
  border-color: #79cdb7;
  box-shadow: inset 0 1px 0 #9edbc34d;
}
html[data-theme='dark'] :is(.chat-shell, .history) :is(#new-chat, #reports-sidebar-open, #reports-open, #logout, #history-toggle, #history-close, #feedback-open):active:not(:disabled) {
  color: #effff7;
  background: #0e2c31;
  border-color: #79cdb7;
  box-shadow: inset 0 2px 5px #0005;
}
html[data-theme='dark'] :is(.chat-shell, .history) :is(#new-chat, #reports-sidebar-open, #reports-open, #logout, #history-toggle, #history-close, #feedback-open):disabled {
  color: #afc2c5;
  background: #1a2e34;
  border: 1px solid #39525a;
  opacity: 1;
  box-shadow: none;
}
html[data-theme='dark'] #history .session {
  color: #e8fbf5;
  background: #102a31;
  border-color: #31575e;
  box-shadow: none;
  opacity: 1;
}
html[data-theme='dark'] #history .session small { color: #adc9c8; }
html[data-theme='dark'] #history .session:hover:not(:disabled) { color: #effff7; background: #1c4148; border-color: #79cdb7; }
html[data-theme='dark'] #history .session[aria-current='true'] { color: #effff7; background: #1e4a48; border-color: #79cdb7; box-shadow: inset 3px 0 #70e1bf; }
html[data-theme='dark'] #history .session[aria-current='true'] small { color: #b9e7d6; }
html[data-theme='dark'] #history .session:active:not(:disabled) { color: #effff7; background: #123234; border-color: #79cdb7; box-shadow: inset 0 2px 5px #0005; }
html[data-theme='dark'] #history .session:disabled { color: #b0c2c3; background: #172a31; border-color: #39525a; box-shadow: none; opacity: 1; }
html[data-theme='dark'] #history .session:disabled small { color: #9eb4b6; }
html[data-theme='dark'] #history .session[aria-current='true']:disabled { color: #d5eee5; background: #1e3a40; border-color: #51766f; box-shadow: inset 3px 0 #68bba4; }
html[data-theme='dark'] #history .session[aria-current='true']:disabled small { color: #b2cec8; }
html[data-theme='dark'] :is(.chat-shell, .history) :is(button, a):focus-visible { outline-color: #89efcf; }

/* A wide sidebar must not push header actions outside a narrow desktop. */
@media (min-width: 960px) and (max-width: 1199px) {
  .topbar .conversation-title, .topbar .dev-label, .workspace-actions .action-label { display: none; }
  .workspace-actions .workspace-action { width: 44px; padding: 0; }
}
@media (max-width: 760px) {
  .chat-shell .topbar { min-height: 60px; height: 60px; padding-inline: 12px; gap: 5px; }
  .topbar .conversation-title, .workspace-actions .action-label { display: none; }
  .workspace-actions { gap: 1px; padding: 2px; }
  .workspace-actions .workspace-action { width: 44px; padding: 0; }
  .chat-shell .welcome { padding-top: 10px; }
  .welcome .starter-prompts { gap: 8px; }
  .welcome .starter svg { width: 50px; height: 50px; padding: 14px; }
}

@media (max-width: 600px) {
  .workspace-ribbon-1 { top: 55vh; width: 230vw; height: 180vw; left: -100vw; }
  .workspace-ribbon-2 { top: 65vh; width: 220vw; height: 170vw; left: -85vw; }
  .workspace-ribbon-3 { top: 76vh; width: 215vw; height: 165vw; left: -65vw; }
}

@media (max-width: 400px) {
  .topbar .identity-name { font-size: 13px; }
  .chat-shell .topbar { padding-inline: 8px; gap: 3px; }
  .workspace-actions { gap: 0; }
}

@media (max-width: 355px) {
  .topbar .identity-name { display: none; }
  .topbar .identity { width: 44px; padding-inline: 0; justify-content: center; }
}

/* Shared secondary controls and reading surfaces across the workspace. */
.assistant-label:has(.brand-wordmark)::before { content: none; }
:is(.feedback-dialog, .citation-dialog, .ex-workspace, .auth-panel) { font-family: inherit; }
:is(.chat-shell, .feedback-dialog, .citation-dialog) :is(.feedback-close, .response-tools button, .retry, .resume-analysis, .jump-latest, .citation-retry, .citation-sources button, .citation-files a, .ex-button, .ex-link-button) {
  min-height: 44px;
  border-radius: 10px;
  border-color: var(--line);
  background: var(--accent-wash);
  color: var(--green);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
}
:is(.chat-shell, .feedback-dialog, .citation-dialog) :is(.feedback-close, .response-tools button, .retry, .resume-analysis, .jump-latest, .citation-retry, .citation-sources button, .citation-files a, .ex-button):hover:not(:disabled) {
  background: var(--accent-wash); color: var(--ink); border-color: var(--green);
}
.feedback-dialog { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.feedback-dialog .feedback-submit, .composer #stop-request {
  background: var(--send); color: var(--send-text); border: 1px solid var(--send); border-radius: 10px; font-size: 13px; font-weight: 600; min-height: 44px;
}
.feedback-dialog .feedback-submit:hover:not(:disabled), .composer #stop-request:hover:not(:disabled) { background: var(--send-hover); color: var(--send-text); }
.feedback-form textarea::placeholder, .auth-panel input::placeholder { color: var(--secondary); opacity: 1; }
.feedback-check { min-height: 44px; align-items: center; }
.feedback-note, .feedback-status { color: var(--secondary); }
.feedback-form :is(input, textarea, select) { background: var(--paper); color: var(--ink); border-color: var(--line); }
.chat-shell :is(.workflow, .verification-log, .previous-versions, .brief-details, .breakdown) > summary {
  min-height: 44px; background: var(--accent-wash); color: var(--ink); border-color: var(--line); font-size: 13px;
}
.chat-shell :is(.workflow, .verification-log, .previous-versions, .brief-details, .breakdown) > summary:hover { background: var(--accent-wash); border-color: var(--green); }
.citation-dialog, .citation-head, .citation-assessment, .citation-assessment-details { background: var(--paper); color: var(--ink); border-color: var(--line); }
.citation-head button { min-width: 44px; min-height: 44px; }
.citation-detail h2 { font-family: inherit; font-size: 22px; font-weight: 650; }
:is(.citation-caption, .citation-version, .citation-status, .citation-conflict-note) { color: var(--secondary); }
:is(.citation-original, .citation-attachment, .citation-conflicts, .citation-assessment h3, .citation-assessment h4) { color: var(--green); }
.citation-quote, .citation-missing { color: var(--ink); background: var(--accent-wash); border-color: var(--line); }
.citation-chip { background: var(--accent-wash); color: var(--green); }
.citation-dialog :is(a,button):focus-visible, .ex-workspace :focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.ex-workspace { color: var(--ink); }
.ex-workspace :is(.ex-slicers, .ex-tree-section, .ex-kpis > div, .ex-chart, .ex-empty-state) { background: var(--paper); border-color: var(--line); }
.ex-workspace :is(.ex-eyebrow, .ex-slicers label, .ex-scope, .ex-caption, .ex-legend, .ex-node-meta, .ex-open-hint, .ex-kpis small, th, .ex-loading) { color: var(--secondary); }
.ex-slicers select { min-height: 44px; font-size: 16px; background: var(--paper); color: var(--ink); border-color: var(--line); }
.ex-workspace .ex-node { background: var(--accent-wash); color: var(--ink); border-color: var(--line); }
.ex-workspace .ex-root { background: #d7e9dc; border-color: #769d85; }
.ex-workspace .ex-loss { background: #fff0ed; border-color: #cb7c72; }
.ex-workspace .ex-incomplete { background: #fff7df; border-color: #be9d54; }
.ex-workspace .ex-node-info details[open] { background: var(--paper); color: var(--ink); }
.ex-workspace .ex-tabs [aria-pressed='true'] { background: var(--send); color: var(--send-text); border-color: var(--send); }
/* Chart artwork has its own fixed palette; keep its canvas readable in either theme. */
.ex-chart svg { background: #fff; border-radius: 8px; }
[data-theme='dark'] .ex-workspace .ex-loss { background: #492c30; border-color: #b7797e; }
[data-theme='dark'] .ex-workspace .ex-root { background: #1e4a48; border-color: #79cdb7; }
[data-theme='dark'] .ex-workspace .ex-incomplete { background: #493b27; border-color: #927448; }
[data-theme='dark'] :is(.ex-priority, .ex-error) { color: #ffb5ba; }
html[data-theme='dark'] :is(.feedback-dialog, .chat-shell, .ex-workspace) :is(.feedback-submit, .response-tools button, .retry, .resume-analysis, #stop-request, .ex-button):disabled {
  background: #1a2e34; color: #afc2c5; border-color: #39525a; opacity: 1;
}
.workspace-resize { position: fixed; z-index: 6; width: 10px; cursor: col-resize; touch-action: none; user-select: none; }
.workspace-resize::after { content: ''; position: absolute; width: 3px; height: 44px; top: 50%; left: 3px; transform: translateY(-50%); border-radius: 3px; background: var(--green); opacity: 0; }
.workspace-resize:hover::after, .workspace-resize:focus-visible::after, .workspace-resizing .workspace-resize::after { opacity: 1; }
.workspace-resize:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.workspace-resize[hidden] { display: none; }
.conversation-expand { width: 44px; padding: 0; }
.conversation-expand[hidden], .conversation-expand .restore-icon { display: none; }
.conversation-expand[aria-pressed='true'] .expand-icon { display: none; }
.conversation-expand[aria-pressed='true'] .restore-icon { display: block; }
.conversation-expand[aria-pressed='true'] { background: var(--accent-wash); border-color: var(--line); }
/* Hide only the transcript scrollbar; keep native scrolling and table scrollbars. */
body:not(.needs-auth) .chat-shell main { scrollbar-width: none; }
body:not(.needs-auth) .chat-shell main::-webkit-scrollbar { display: none; width: 0; height: 0; }
.chat-shell main:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.workspace-resizing, .workspace-resizing * { cursor: col-resize !important; user-select: none !important; }
@media (max-width: 959px) {
  .workspace-resize { display: none; }
  body:not(.needs-auth) .chat-shell main,
  .chat-shell #composer-chat .composer-area { width: calc(100% - 32px); }
}
@media (forced-colors: active) {
  .workspace-resize::after { background: ButtonText; }
  .workspace-landscape { display: none; }
  .kp-edges { stroke: CanvasText; }
  .kp-letter, .kp-node { fill: CanvasText; }
  .kp-avatar .kp-signal { stop-color: transparent; }
  .workspace-action { border-color: ButtonText; }
  .chat-shell :is(.topbar, .workspace-actions, .composer button, .starter svg) { background: Canvas; box-shadow: none; }
  .chat-shell .composer, .chat-shell main.has-messages, .chat-shell #composer-chat .composer-area { background: Canvas; }
  .composer textarea:focus-visible { outline: 2px solid Highlight; }
}
