/* Canonical component roles. No theme values are declared outside tokens.css. */
html, body { background-color: var(--bg-main); color: var(--text-2); }
html { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) var(--bg-main); }
*, *::before, *::after { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
::selection { background: var(--accent-soft); color: var(--text); }
:where(a) { color: var(--accent-fg); }
:where(button,input,textarea,select) { color: var(--text-2); }
:where(input,textarea,select) { background-color: var(--surface); border-color: var(--border); caret-color: var(--accent-fg); }
:where(input,textarea,select):disabled { color: var(--text-4); }
:where(input,textarea,select)::placeholder { color: var(--text-3); opacity: 1; }
.sidebar, .history-panel, .history-header, .history-tabs { background-color: var(--bg-side); border-color: var(--border); }
.chat-shell, .chat-header, .messages { background-color: var(--bg-main); }
:where(.dialog,.modal-card,.profile-card,.settings-card,.admin-card,.app-dialog,.img-dialog,.image-family-popover,.studio-model-menu,.studio-param-menu,.export-menu,.workbench-dialog,.mat-panel) { background-color: var(--surface); border-color: var(--border); box-shadow: none; }
.message.user .bubble { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); box-shadow: none; }
.input-wrap { background: var(--surface); border: 1px solid var(--border); box-shadow: none; }
.input-wrap:focus-within { border-color: var(--accent-line); box-shadow: none; }
.composer :is(input,textarea,[contenteditable="true"]) { color: var(--text); }
.composer :is(.icon-tool,.composer-tool), #exportLast, #stopButton { background: var(--surface); border: 1px solid var(--border); color: var(--text-2); box-shadow: none; }
#sendButton, .send-button, .primary, .promo-primary { background: var(--accent-base); color: var(--on-accent); border-color: var(--accent-base); box-shadow: none; }
#sendButton .ico, .send-button .ico, .primary .ico { color: var(--on-accent); }
:is(.history-meta,.history-open .history-meta) b { padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--text-3); font-weight: 400; }
.history-row.active :is(.history-meta b,.history-prompt) { color: var(--accent-fg); }
.history-row.active { background: var(--accent-soft); }
.history-row:hover { background: var(--hover); }
.history-row.active:hover { background: var(--accent-soft); }
.history-row.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 1px; background: var(--accent-base); }
.history-open :is(.history-title,.history-time,.history-meta,.history-prompt) { opacity: 1; }
.chat-header .ann-bell { background: var(--accent-soft); color: var(--accent-fg); }
.chat-header .ann-bell:hover { background: color-mix(in srgb, var(--accent-base) 18%, transparent); color: var(--accent-fg); }
.chat-header .usage-guide-trigger { background: var(--accent-soft); color: var(--accent-fg); }
.chat-header .usage-guide-trigger:hover { background: color-mix(in srgb, var(--accent-base) 18%, transparent); }
.chat-header .canvas-entry { background: var(--accent-soft); color: var(--accent-fg); border-color: var(--accent-line); }
.chat-header .canvas-entry:hover { background: var(--accent-soft); color: var(--accent-fg); border-color: var(--accent-line); }
:is(.image-family-popover,.studio-model-menu) :is(.image-family-row,.image-family-variant,.studio-model-row):hover { background: var(--hover); }
:is(.image-family-popover,.studio-model-menu) :is(.image-family-row,.image-family-variant,.studio-model-row)[aria-checked="true"] { background: var(--active); }
.accent-swatch.active { outline: 2px solid var(--accent-fg); outline-offset: 2px; }
.accent-swatch.active i::after { color: var(--swatch-ink,var(--on-accent)); }
.accent-custom { background: conic-gradient(var(--preset-terracotta),var(--preset-amber),var(--preset-olive),var(--preset-pine),var(--preset-lake),var(--preset-sky),var(--preset-indigo),var(--preset-wisteria),var(--preset-rose),var(--preset-terracotta)); }
/* Transitions affect paint only, never the existing folding/drag/scroll state. */
html,body,.app-shell,.sidebar,.history-panel,.chat-shell,.chat-header,.messages,.bubble,.input-wrap,
:where(button,input,textarea,select,.category-card,.prompt-card,.history-row,.dialog,.image-family-popover,.workbench-files,.workbench-flow-actions,.workbench-file) {
  transition-property: background-color,color,border-color,outline-color;
  transition-duration: var(--theme-color-time);
  transition-timing-function: ease;
}
@media (prefers-reduced-motion: reduce) {
  :root { --theme-color-time: 0ms; }
  html,body,.app-shell,.sidebar,.history-panel,.chat-shell,.chat-header,.messages,.bubble,.input-wrap,
  :where(button,input,textarea,select,.category-card,.prompt-card,.history-row,.dialog,.image-family-popover,.workbench-files,.workbench-flow-actions,.workbench-file) { transition-duration: 0s; }
}
.studio-menu-option:is(:hover,[aria-checked="true"]) :is(.studio-menu-copy,small,.studio-menu-price),
.model-menu button:is(:hover,.is-selected) :is(small,.model-note),
.image-family-variant:is(:hover,[aria-checked="true"]) :is(.image-family-description,.image-family-price) { color: var(--text-2); }
html[data-theme="mono"] #authyVideo,
html[data-surface="media"] #authyVideo { filter: grayscale(1); }

.user-avatar { background: var(--active); color: var(--text-2); }
.studio-menu-option:is(:hover,[aria-checked="true"]) :is(.studio-menu-copy,.studio-menu-price,small) { color: var(--text-2); }
.model-badge { background: var(--active); color: var(--text-2); border: 1px solid var(--border); }
.history-row:is(.active,:hover) :is(.history-time,.history-meta,.history-prompt) { color: var(--text-2); }
.history-row .history-open .history-meta b { padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--text-3); font-weight: 400; }
.history-row.active .history-open .history-meta b { background: transparent; color: var(--accent-fg); }
.theme-option:is(.active,:hover) em { color: var(--text-2); }


/* Shared non-accent controls and status labels. */
:is(.toast,.profile-avatar,.drawer-avatar,.img-head-mark,.music-head-mark,.mat-brand-mark,.mat-kind,.asset-destination-heading > i,.img-vw-badges em,.music-detail-action.asset-library-action > span) { background: var(--active); color: var(--text-2); }
:is(.status-chip.on,.promo-status.on,.recharge-plan-bonus) { background: var(--hover); color: var(--text-2); border-color: var(--border); }
.recharge-plan em { color: var(--text-3); }
.recharge-plan.has-bonus:not(.selected) { border-color: var(--border); }
:is(.usage-guide-dialog,.settings-editor .usage-guide-preview) { background: var(--surface); border-color: var(--border); }
:is(.usage-guide-head span,.settings-editor .usage-guide-preview span,.typing span,.pending-cell b) { color: var(--text-2); }
.typing span { background: var(--text-3); }
:is(.composer-chip,.composer-shelf-item,.composer-upload-strip,.upload-drop-overlay) { background: var(--surface); border-color: var(--border); }
.composer-shelf-item:is(:hover,:focus-within) { border-color: var(--accent-line); }
:is(.composer-chip .composer-chip-remove,.composer-shelf-remove,.composer-upload-cancel):hover { background: var(--hover); color: var(--text-2); }
:is(.img-rail,.music-rail,.mat-rail) { background: var(--bg-side); border-color: var(--border); }
:is(.authy-submit,.img-go,.music-create,.music-send-button,.img-ed-save,.img-ed-crop-yes,.img-dlg-yes,.mat-upload-btn,.asset-project-create button[type="submit"]) { background: var(--accent-base); color: var(--on-accent); border-color: var(--accent-base); }
:is(.primary,.send-button,.authy-submit,.img-go,.music-create,.music-send-button,.img-ed-save,.img-ed-crop-yes,.img-dlg-yes,.mat-upload-btn,.asset-project-create button[type="submit"]):is(:hover,:active) { background: var(--accent-base); color: var(--on-accent); border-color: var(--accent-base); filter: none; }
:is(.img-go .img-cost,.music-create em,.img-act.key small) { color: inherit; opacity: 1; }
:is(.archive-folder-choices button,.category-pills button,.theme-option,.skill-ide-skill):hover:not(.active) { background: var(--hover); color: var(--text-2); border-color: var(--border); }
:is(.layout-resizer:hover,.layout-resizer.is-dragging,.layout-resizer:focus-visible) { background: var(--active); }
:is(.layout-resizer:hover,.layout-resizer.is-dragging,.layout-resizer:focus-visible)::before { background: var(--border-strong); }
input:focus,textarea:focus,select:focus { border-color: var(--accent-line); }

.authy-tabs button { color: var(--text-2); }

/* Theme previews stay neutral while evaluating images in the studio theme. */
html[data-theme="mono"] .theme-swatch, html[data-surface="media"] .theme-swatch { filter: grayscale(1); }

/* Round 5: functional marks carry accent; brand artwork never receives a filter. */
:is(button,label.icon-tool) svg { color: var(--accent-fg); }
:is(.pg-arrow,.prompt-group-head,.model-trigger i,.rail-collapse,.rail-reopen,.message-actions,.copy-action,.workbench-steps summary) svg,
#categoryList > .category-card > summary em svg { color: var(--text-3); }
:is(button.primary,button.send-button,#stopButton,button.img-go,button.music-create,.workbench-primary,.promo-primary,.authy-submit,.img-ed-save,.img-ed-crop-yes,.img-dlg-yes,.mat-upload-btn,.music-send-button,.img-act.key,.prompt-use) svg { color: var(--on-accent); }
#categoryList .prompt-use svg { color: inherit; }
:is(.model-badge,.model-icon,.model-option-icon,.model-trigger-icon,.provider-icon,.studio-model-icon,.studio-family-icon,.image-family-logo,.avatar,.user-avatar,.profile-avatar,.drawer-avatar,.brand-mark,.canvas-entry-fish,[data-brand-logo]),
:is(.model-badge,.model-option-icon,.model-trigger-icon,.provider-icon,.studio-model-icon,.studio-family-icon,.image-family-logo,.avatar,.user-avatar,.profile-avatar,.drawer-avatar,.brand-mark,.canvas-entry-fish) img { filter: none; opacity: 1; mix-blend-mode: normal; }
/* Reuse the existing official white OpenAI mark on dark surfaces. */
html:is([data-theme="mono"],[data-theme="aurora"],[data-surface="media"]) img[src^="/model-openai.svg"] { content: url('/model-logos/openai.svg'); }
html[data-surface="paper"][data-theme="sand"] img[src^="/model-openai.svg"] { content: normal; }
.chat-header .header-actions { gap: 8px; }
.chat-header .header-actions .ann-bell-wrap { margin: 0; align-self: center; }
.chat-header :is(.ann-bell,.usage-guide-trigger) { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; min-width: 36px; max-width: 36px; height: 36px; padding: 0; gap: 0; border: 0; border-radius: 50%; color: var(--accent-fg); background: var(--accent-soft); line-height: 1; }
.chat-header :is(.ann-bell,.usage-guide-trigger) .ico { display: block; flex: 0 0 20px; width: 20px; height: 20px; margin: 0; padding: 0; transform: none; color: inherit; }
.chat-header :is(.ann-bell,.usage-guide-trigger):hover { background: color-mix(in srgb, var(--accent-base) 18%, transparent); color: var(--accent-fg); }
.chat-header .usage-guide-trigger.hidden { display: none; }
:is(.notice-card,.notice-card .notice-top) { overflow: visible; }
.message.notice .notice-card em { display: inline-flex; align-items: center; flex: 0 0 auto; max-width: 100%; padding: 0 8px; min-height: 24px; border: 0; border-radius: 999px; background: var(--hover); color: var(--text-3); line-height: 1.5; overflow: visible; white-space: nowrap; }
.sidebar:has(#categoryList) .studio-entry { background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.sidebar:has(#categoryList) .studio-entry-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-fg); }
.sidebar .studio-entry-mark svg { width: 18px; height: 18px; color: inherit; }
.sidebar .studio-entry-copy strong { color: var(--text-2); }
.composer :is(label.icon-tool,#speechMic):not(.is-active) { display: inline-flex; align-items: center; justify-content: center; width: 36px; min-width: 36px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--accent-fg); }
.composer #speechMic[hidden] { display: none; }
.composer :is(label.icon-tool,#speechMic):hover { background: var(--accent-soft); }
.composer :is(.expand-composer,.composer-chip-file) svg { color: var(--accent-fg); }
.composer #thinkingChip { height: 36px; background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent-fg); }
.composer #thinkingChip :is(svg,b) { color: var(--accent-fg); }
.composer .model-trigger { height: 36px; background: var(--surface); border-color: var(--border); color: var(--text-2); }
.composer #exportLast { height: 36px; background: var(--surface); color: var(--text-2); border-color: var(--border); }
.composer #exportLast svg { color: var(--accent-fg); }
.composer #stopButton { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 36px; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: var(--accent-base); color: var(--on-accent); opacity: 1; }
.composer #stopButton:disabled { display: none; }
.composer .composer-right:has(#stopButton:not(:disabled)) .send-button { display: none; }
.composer .send-button { flex: 0 0 36px; width: 36px; height: 36px; padding: 0; border-radius: 8px; }
.composer :is(#stopButton,.send-button) svg { color: var(--on-accent); }
/* Waiting remains truthful: an indeterminate stroke, real elapsed time and streamed reasoning. */
.thinking-shell { gap: 12px; padding: 16px; border-color: var(--border); border-radius: 12px; background: var(--surface); }
.thinking-head { gap: 8px; }
.thinking-dots { gap: 4px; }
.thinking-dots i { width: 4px; height: 4px; background: var(--accent-base); animation-duration: 1.6s; }
.thinking-label { color: var(--text); font-weight: 500; }
.thinking-track { height: 2px; background: var(--accent-soft); }
.thinking-track i { background: var(--accent-base); animation-duration: 1.8s; }
.thinking-foot { color: var(--text-3); }
.thinking-stream pre { color: var(--text-2); }
:is(.model-menu,.ann-pop,.export-menu,.studio-model-menu,.studio-param-menu,.image-family-popover,.image-mention-menu,.attachment-hover-preview) { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 12px 32px -12px color-mix(in srgb, var(--scrim-base) 24%, transparent); animation: menu-reveal-5 180ms cubic-bezier(.16,1,.3,1) both; }
@keyframes menu-reveal-5 { from { clip-path: inset(0 0 8% 0 round 12px); } to { clip-path: inset(0 0 0 0 round 12px); } }
@media (prefers-reduced-motion: reduce) {
  :is(.model-menu,.ann-pop,.export-menu,.studio-model-menu,.studio-param-menu,.image-family-popover,.image-mention-menu,.attachment-hover-preview) { animation: none; }
  .thinking-dots i,.thinking-track i,.composer-upload-row.is-processing .composer-upload-fill { animation: none; }
}
