/* Canvas chrome only. Artwork, live artwork text editors and color swatches
   retain their document colors. This also covers canvas-only body portals. */
body:not(.is-editor) .cv-root {
  --cv-canvas-bg: var(--workspace-canvas-bg, #f5f5f5);
}
body:not(.is-editor) .cv-root .cv-stage {
  background: var(--workspace-canvas-bg, #f5f5f5);
}

/* Assistant content and composer share the same column edges. */
body:not(.is-editor) .cv-root .cv-agent-msgs .msg.agent {
  width: 100%;
  min-width: 0;
}
body:not(.is-editor) .cv-root .cv-agent-msgs .msg.agent .a-body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}
body:not(.is-editor) .cv-root:not(.cv-panel-chat-max) .cv-agent-in {
  padding-inline: 18px;
}
@media (max-width: 850px) {
  body:not(.is-editor) .cv-root:not(.cv-panel-chat-max) .cv-agent-in {
    padding-inline: 12px;
  }
}

/* Charcoal UI surfaces, including styles injected after the page loads. */
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-left {
  --cv-accent: var(--workspace-text);
  --cv-accent-weak: var(--workspace-soft);
  background: var(--workspace-surface);
  color: var(--workspace-text);
  border-color: var(--workspace-border);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root :is(.cv-chat-sidebar, .cv-rtabs) {
  background: var(--workspace-surface);
  color: var(--workspace-text);
  border-color: var(--workspace-border);
}
html[data-workspace-theme=dark] body:not(.is-editor) :is(
  .cv-agent-msgs, .cv-agent-in, .cv-panel-chat-backdrop, .cv-chat-sidebar,
  .cv-input-content, .cv-chat-popup, .cv-history-dropdown,
  .cv-comment-panel, .cv-comment-description, .cv-comment-tools,
  .cv-pen-tools, .cv-studio-menu, .cv-studio-bar, .cv-studio-pop,
  .cv-page-menu, .cv-fbar, .cv-menu, .cv-submenu, .cv-blank-menu,
  .cv-gcard, .cv-gset, .cv-gpick, .cv-pop, .cv-tp,
  .cv-creative-panel, .cv-quick-prompt-card, .cv-quick-options,
  .cv-toolbar-dialog, .cv-toolbar-pin, .cv-history-dialog
) {
  background: var(--workspace-surface);
  color: var(--workspace-text);
  border-color: var(--workspace-border);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-input-content:focus-within {
  border-color: #666;
  box-shadow: 0 0 0 2px #ffffff0a;
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root :is(
  .cv-agent-msgs .msg.agent .a-body, .cv-rich-editor,
  .cv-conversation-title, .cv-chat-sidebar-new,
  .cv-chat-toolbar button, .cv-panel-control,
  .cv-execution-plan b, .cxt-link, .cv-layer-history,
  .cv-layer-item button, .cv-generated-file button,
  .cv-studio-bar button, .cv-studio-bar input,
  .cv-chat-reference span, .cv-chat-message-ref span, .cv-inline-ref > span,
  .cv-toolbar-options i, .cv-fbar button, .cv-flabel,
  .cv-creative-choice > span
) { color: var(--workspace-text); }
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root :is(
  .cv-chat-image-heading, .cv-chat-image-summary, .cv-chat-drag-hint,
  .cv-chat-result-meta, .cv-history-heading, .cv-history-empty,
  .cv-history-item small, .cv-chat-sidebar-heading,
  .cv-chat-sidebar-item small, .cv-chat-sidebar-status,
  .cv-chat-sidebar-empty, .cv-chat-setting-note,
  .cv-chat-setting-label, .cv-chat-caret, .cxt-head,
  .cv-layer-history p, .cv-overview-empty, .cv-zoom-menu small,
  .cv-page-menu-label, .cv-creative-note, .cv-creative-panel label,
  .cv-studio-bar label, .cv-studio-menu small, .cv-model-card small,
  .cv-agent-trace, .cv-agent-trace .tc-detail, .cv-chat-copy
) { color: var(--workspace-muted); }
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root #cvAgentPrice {
  color: var(--workspace-muted);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-rich-editor.empty:before {
  color: var(--workspace-muted);
}
/* The first conversation has prompt chips before any message is rendered. */
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cx-empty {
  color: var(--workspace-muted);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cx-hello {
  color: var(--workspace-text);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cx-chip {
  background: var(--workspace-soft);
  color: var(--workspace-text);
  border-color: var(--workspace-border);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cx-chip:hover {
  background: var(--workspace-hover, var(--workspace-soft));
  color: var(--workspace-text);
  border-color: var(--workspace-focus, #9b9b9b);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cx-chip:focus-visible {
  outline: 2px solid var(--workspace-focus, #9b9b9b);
  outline-offset: 2px;
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-empty-tip .cv-et-card {
  background: var(--workspace-surface);
  color: var(--workspace-muted);
  border-color: var(--workspace-border);
  box-shadow: 0 12px 40px -10px #0004;
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-empty-tip :is(.cv-et-act, .cv-et-key) {
  background: var(--workspace-soft);
  color: var(--workspace-text);
  border-color: var(--workspace-border);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-empty-tip .cv-et-act:hover {
  background: var(--workspace-hover, var(--workspace-soft));
  color: var(--workspace-text);
  border-color: var(--workspace-focus, #9b9b9b);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root #cvChatParams {
  background: var(--workspace-soft);
  color: var(--workspace-text);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root :is(
  .cv-agent-msgs .msg.user .bubble, .cv-execution-plan,
  .cv-chat-message-ref, .cv-input-content .cv-chat-reference,
  .cv-inline-ref, .cv-chat-dimensions label, .cv-model-tabs,
  .cv-quick-capsule, #cvAgentNew
) {
  background: var(--workspace-soft);
  color: var(--workspace-text);
  border-color: var(--workspace-border);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root :is(.cv-chat-toolbar .cv-send-btn, .cv-gc-send, .cv-gen-btn) .line-icon {
  color: inherit;
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cx-task {
  background: transparent;
  color: var(--workspace-text);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs :is(code, pre) {
  background: var(--workspace-soft);
  color: var(--workspace-text);
  border-color: var(--workspace-border);
}
html[data-workspace-theme=dark] body:not(.is-editor) :is(
  .cv-chat-mode-option, .cv-chat-settings button, .cv-chat-mention-list button,
  .cv-model-card, .cv-comment-head select, .cv-comment-actions button,
  .cv-comment-tools button, .cv-studio-menu button, .cv-studio-pop button,
  .cv-studio-bar select, .cv-history-actions button, .cv-gc-add,
  .cv-gc-chip, .cv-creative-actions button, .cv-creative-secondary,
  .cv-creative-choice button, .cv-toolbar-options button,
  .cv-toolbar-dialog footer button
) {
  background: var(--workspace-surface);
  color: var(--workspace-text);
  border-color: var(--workspace-border);
}
html[data-workspace-theme=dark] body:not(.is-editor) :is(
  .cv-document-tab.is-active, .cv-document-tab:hover,
  .cv-document-tab button:hover, .cv-document-new:hover,
  .cv-document-restore:hover, .cv-page-menu button:hover,
  .cv-dock .cv-tbtn.active, .cv-panel-control:hover,
  .cv-chat-sidebar-item.active, .cv-chat-sidebar-item:hover,
  .cv-chat-sidebar-new:hover, .cv-history-item.active, .cv-history-item:hover,
  .cv-chat-mode-option:hover, .cv-chat-mode-option.active,
  .cv-chat-settings button.active, .cv-chat-mention-list button:hover,
  .cv-chat-mention-list button.active, .cv-model-tabs button.active,
  .cv-model-card:hover, .cv-model-card.active, .cv-studio-menu button:hover,
  .cv-studio-menu button.active, .cv-studio-bar button:hover,
  .cv-studio-bar button.active, .cv-studio-pop button:hover,
  .cv-studio-pop button.active, .cv-toolbar-options button[aria-pressed=true]
) {
  background: var(--workspace-soft);
  color: var(--workspace-text);
  border-color: var(--workspace-border);
  box-shadow: none;
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root :is(
  .cv-document-tab, .cv-document-tab button, .cv-document-new,
  .cv-document-restore, .cv-zoom-pill button, .cv-chat-sidebar-item
) { color: var(--workspace-muted); }
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-document-tab.is-active {
  color: var(--workspace-text);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root :is(
  .cv-chat-toolbar .cv-send-btn, .cv-gc-send, .cv-gen-btn,
  .cv-creative-actions .cv-creative-primary, .cv-comment-actions [data-comment-add]
) {
  background: var(--workspace-accent);
  color: var(--workspace-accent-text);
  border-color: var(--workspace-accent);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root #cvAgentSend {
  color: var(--workspace-accent-text);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root #cvAgentSend svg {
  color: inherit;
}
html[data-workspace-theme=dark] body:not(.is-editor) :is(
  .cv-chat-sidebar-head, .cv-layer-history, .cv-zoom-menu button:nth-child(3),
  .cv-page-menu-label, .cv-creative-choice, .cv-fsep, .cv-menu-sep
) { border-color: var(--workspace-border); }

/* Durable Agent execution records use their own renderer and light palette.
   Scope these receipts to canvas chat; document objects keep their colors. */
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cv-agent-progress {
  background: var(--workspace-raised, #292929);
  color: var(--workspace-text);
  border-color: var(--workspace-border);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs :is(
  .cv-agent-progress header b, .cv-progress-requirements > div,
  .cv-progress-plan, .cv-progress-tool summary b, .tc-label,
  .cxt-plan b, .tl-step.done, .tl-step.running
) { color: var(--workspace-text); }
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs :is(
  .cv-agent-progress header span, .cv-progress-approach,
  .cv-progress-requirements > summary, .cv-progress-phases > summary,
  .cv-progress-phases ol, .cv-progress-phases time,
  .cv-progress-tool summary small, .cv-progress-tool > p,
  .cv-progress-receipt > b, .tc-detail, .tl-step, .tl-dur,
  .cxt-cr span, .cx-task .tag-model
) { color: var(--workspace-muted); }
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs :is(
  .cv-progress-tool, .cv-progress-receipt pre, .cxt-plan,
  .cx-task, .tc-row
) { border-color: var(--workspace-border); }
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cv-progress-receipt pre {
  background: var(--workspace-soft);
  color: var(--workspace-text);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cv-progress-state {
  background: var(--workspace-soft);
  color: var(--workspace-muted);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cv-progress-state.running {
  background: var(--workspace-info-bg, #293447);
  color: var(--workspace-info, #b6c9f1);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs :is(.cv-progress-state.completed, .cv-progress-state.submitted) {
  background: var(--workspace-success-bg, #23372b);
  color: var(--workspace-success, #9ce2bc);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs :is(.cv-progress-state.failed, .cv-progress-state.accepted_readback_failed) {
  background: var(--workspace-danger-bg, #44292d);
  color: var(--workspace-danger, #f5a0a8);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cv-progress-state.stopped {
  background: var(--workspace-warning-bg, #403521);
  color: var(--workspace-warning, #ecc48c);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cv-agent-progress summary::after,
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .cv-agent-trace > summary::after {
  color: var(--workspace-muted);
}

/* Conversations recorded before progressEvents still use legacy tool rows
   and task timelines. Preserve their success, failure and running signals. */
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .tc-row {
  background: transparent;
  color: var(--workspace-text);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .tc-row.fail {
  background: var(--workspace-danger-bg, #44292d);
  border-color: var(--workspace-danger-border, #694047);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs :is(.tc-row.ok .tc-ico, .tl-step.done .tl-ico) {
  color: var(--workspace-success, #9ce2bc);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs :is(.tc-row.fail .tc-ico, .tl-step.failed .tl-ico, .cxt-fail) {
  color: var(--workspace-danger, #f5a0a8);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .tc-row.run .tc-ico {
  color: var(--workspace-info, #b6c9f1);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .tl-ico {
  background: var(--workspace-soft);
  color: var(--workspace-muted);
  border-color: var(--workspace-border);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .tl-step.done .tl-ico {
  background: var(--workspace-success-bg, #23372b);
  border-color: var(--workspace-success-border, #365a44);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .tl-step.running .tl-ico {
  background: var(--workspace-info-bg, #293447);
  color: var(--workspace-info, #b6c9f1);
  border-color: var(--workspace-info-border, #43536e);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .tl-step.failed .tl-ico {
  background: var(--workspace-danger-bg, #44292d);
  border-color: var(--workspace-danger-border, #694047);
}
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .tl-step.done,
html[data-workspace-theme=dark] body:not(.is-editor) .cv-root .cv-agent-msgs .tl-step.running {
  color: var(--workspace-text);
}
