/* Document chrome only. Shared panel skins live in their existing CSS files.
   Every branch excludes monitor/window and all export render documents. */
:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]):has(body > .iadubbing-detached-root:is([data-ps-ia-dubbing="detached-left"], [data-ps-ia-dubbing="detached-ai"])),
:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) body:has(> .iadubbing-detached-root:is([data-ps-ia-dubbing="detached-left"], [data-ps-ia-dubbing="detached-ai"])) {
  background: var(--ps-bg);
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root:is([data-ps-ia-dubbing="detached-left"], [data-ps-ia-dubbing="detached-ai"]) > .iadubbing-detached-toolbar {
  background: var(--ps-bg-soft);
  border-color: var(--ps-line);
  color: var(--ps-ink);
  box-shadow: 0 4px 14px #0003;
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root:is([data-ps-ia-dubbing="detached-left"], [data-ps-ia-dubbing="detached-ai"]) > .iadubbing-detached-toolbar > strong {
  font-family: var(--ps-font-ui);
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root:is([data-ps-ia-dubbing="detached-left"], [data-ps-ia-dubbing="detached-ai"]) [data-reattach-panel] {
  background: var(--ps-surface-soft);
  border-color: var(--ps-line);
  color: var(--ps-text);
  box-shadow: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root:is([data-ps-ia-dubbing="detached-left"], [data-ps-ia-dubbing="detached-ai"]) [data-reattach-panel]:hover:not(:disabled) {
  background: var(--ps-surface-solid);
  border-color: var(--ps-gold);
}

/* These factory controls have literal inline paints, unlike the shared rows.
   Priorities change only those paints, never their handlers or box metrics. */
:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"] :is([data-detached-export-speakers], [data-detached-export-script], [data-detached-import-script]) {
  background: var(--ps-bg-soft) !important;
  border-color: var(--ps-line) !important;
  color: var(--ps-text) !important;
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"] :is([data-detached-export-speakers], [data-detached-export-script], [data-detached-import-script]):hover:not(:disabled) {
  border-color: var(--ps-gold) !important;
  background: var(--ps-surface-solid) !important;
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"] [data-detached-add-speaker] {
  background: var(--ps-button-bg);
  border-color: var(--ps-button-border);
  color: var(--ps-button-text);
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"] [data-detached-add-speaker]:hover:not(:disabled) {
  background: var(--ps-button-hover);
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"] #tr-script-table-wrap {
  background: var(--ps-surface-soft) !important;
  border-color: var(--ps-line) !important;
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"] [data-detached-left-split-handle] {
  background-image: linear-gradient(180deg, transparent, var(--ps-line), transparent) !important;
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"] [data-detached-left-split-handle][style*="0.95"] {
  background-image: linear-gradient(180deg, transparent, var(--ps-gold), transparent) !important;
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"] [data-detached-left-split-handle][style*="box-shadow:"] {
  box-shadow: 0 0 0 3px var(--ps-line) !important;
}

:where(html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"]) .iadubbing-detached-root:is([data-ps-ia-dubbing="detached-left"], [data-ps-ia-dubbing="detached-ai"]) :is([data-reattach-panel], [data-detached-add-speaker], [data-detached-export-speakers], [data-detached-export-script], [data-detached-import-script]):focus-visible {
  outline-color: var(--ps-focus);
}

/* Autonomous PixelSound AI: its own CSP, local fonts and document context.
   Original keeps Instrument Sans; functional text metrics retain that font. */
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]):has(body > .ai-shell),
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) body:has(> .ai-shell) {
  background: var(--ps-bg);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell {
  --accent: var(--ps-gold);
  --text: var(--ps-text);
  --muted: var(--ps-muted);
  --border: var(--ps-line);
  color: var(--ps-text);
  scrollbar-color: var(--ps-line-strong) var(--ps-bg);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-header h1 {
  font-family: var(--ps-font-ui);
  color: var(--ps-ink);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-brand-mark::before { background: radial-gradient(circle, #c9a97722, transparent 70%); }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell[data-processing="true"] .ai-brand-mark::before { background: radial-gradient(circle, #c9a97722, transparent 70%); }

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-aurora {
  background: radial-gradient(ellipse at 45% 28%, var(--ps-bg-soft), transparent 68%), var(--ps-bg);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-aurora > span {
  background: radial-gradient(ellipse at 28% 43%, #10272b77, transparent 74%), radial-gradient(ellipse at 61% 31%, #c9a9770d, transparent 74%);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-aurora > span:nth-child(2) {
  background: radial-gradient(ellipse at 72% 43%, #10212677, transparent 74%), radial-gradient(ellipse at 49% 72%, #c86b350d, transparent 74%);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-aurora > span:nth-child(3) {
  background: radial-gradient(ellipse at 22% 78%, #10272b55, transparent 74%);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell :is(.ai-project-card, .ai-transcript-card) {
  background: var(--ps-bg-soft);
  border-color: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell :is(#ai-cue-id, .ai-cancel) {
  background: var(--ps-surface-solid);
  color: var(--ps-text);
  border-color: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-cue-text {
  border-color: var(--ps-line-strong);
  color: var(--ps-text);
  scrollbar-color: var(--ps-line-strong) var(--ps-bg-soft);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell :is(.ai-cue-text:hover, .ai-cue-text:focus-visible, .ai-cancel:hover) {
  border-color: var(--ps-gold);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-counter {
  color: var(--ps-muted);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-capture-controls::before {
  background: radial-gradient(ellipse, #c9a97715, #10272b44 30%, transparent 68%);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-rec:not([data-state="RECORDING"]) {
  --halo: 201, 169, 119;
  background: var(--ps-button-bg);
  border-color: var(--ps-button-border);
  color: var(--ps-button-text);
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-rec[data-state="ERROR"] { --halo: 185, 113, 92; }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-rec:not([data-state="RECORDING"])::after { border-top-color: var(--ps-gold); }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-orbits { color: var(--ps-gold); }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-rec[data-state="RECORDING"] .ai-orbits { color: #16b985; }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-rec-processing::after { border-color: var(--ps-line); border-top-color: var(--ps-gold); border-right-color: var(--ps-gold-light); }

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-status-card {
  --status-accent: var(--ps-gold);
  --status-title: var(--ps-ink);
  --status-copy: var(--ps-muted);
  --status-wash: var(--ps-bg-soft);
  --status-icon: var(--ps-surface-solid);
  --status-border: var(--ps-line);
  background: linear-gradient(112deg, var(--status-wash), var(--ps-surface-soft));
}

:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-status-card:is([data-tone="recording"], [data-tone="completed"]) { --status-accent: #63c998; --status-title: #86efac; --status-border: #63c99877; }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-status-card:is([data-tone="refused"], [data-tone="warning"]) { --status-accent: #e5ac41; --status-title: #f6cd8f; --status-border: #e5ac4177; }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-status-card[data-tone="error"] { --status-accent: #f87171; --status-title: #fca5a5; --status-border: #f8717177; }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell .ai-status-card[data-tone="disconnected"] { --status-accent: var(--ps-muted); }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell #ai-bulk-items { scrollbar-color: var(--ps-line-strong) var(--ps-bg-soft); }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell #ai-bulk-items li { --journal-wash: var(--ps-surface-solid); }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell #ai-bulk-items li[data-result="succeeded"] { color: #86efac; --journal-wash: #164534; }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell #ai-bulk-items li[data-result="failed"] { color: #fca5a5; --journal-wash: #361c22; }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell #ai-bulk-items li[data-result="uncertain"] { color: #f6cd8f; --journal-wash: #382b19; }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell #ai-bulk-items li[data-result="cancelled"] { color: var(--ps-muted); }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell #ai-bulk-items li[data-result="succeeded"]::marker { color: #86efac; }
:where(html[data-ps-theme="studio"][data-ps-window="assistant"][data-ps-screen="window"]) .ai-shell #ai-bulk-items li:is([data-result="failed"], [data-result="uncertain"])::marker { color: #f6cd8f; }

/* Processing provenance belongs to this acquired instance, including after
   parent navigation. The monitor context is deliberately absent. No lock,
   focus, animation, SVG coordinates, progress values or z-index is changed. */
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] {
  background: #0009;
  color: var(--ps-text);
}

:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-processing-card {
  background: var(--ps-bg-soft);
  border-color: var(--ps-line);
  box-shadow: 0 24px 80px #0006;
}

:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] :is(h2, h3) { color: var(--ps-ink); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] :is(#psai-processing-subtitle, .psai-processing-steps p, .psai-processing-detail, #psai-processing-footer) { color: var(--ps-muted); border-color: var(--ps-line); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-processing-note { color: #f6cd8f; }

:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] :is(.psai-processing-indicator, .psai-emotion-preview) { background: var(--ps-surface-solid); border-color: var(--ps-line); color: var(--ps-muted); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] [data-state="active"] .psai-processing-indicator { background: var(--ps-bg); border-color: var(--ps-gold); color: var(--ps-gold-light); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] [data-state="done"] .psai-processing-indicator { color: #86efac; border-color: #63c99877; }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] :is([data-state="partial"], [data-state="stopped"]) .psai-processing-indicator { color: #f6cd8f; border-color: #e5ac4177; }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-processing-indicator::before { border-color: var(--ps-gold); }

:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] progress { background: var(--ps-surface-soft); accent-color: var(--ps-gold); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] progress::-webkit-progress-bar { background: var(--ps-surface-soft); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] progress[value]::-webkit-progress-value { background: var(--ps-button-bg); box-shadow: 0 0 5px #c9a97755; }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] progress[value]::-moz-progress-bar { background: var(--ps-button-bg); box-shadow: 0 0 5px #c9a97755; }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-processing-reflection::before { background: linear-gradient(90deg, transparent, #ecd2a288, transparent); }

:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] :is(.psai-processing-ambient, .psai-processing-halo) { background: radial-gradient(ellipse at 50% 45%, #c9a97722, transparent 65%); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-processing-ring { border-color: var(--ps-line-strong); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-processing-orbit::after { background: var(--ps-gold); box-shadow: 0 0 6px #c9a97788; }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-processing-wave-flow path:first-child { stroke: var(--ps-gold); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-processing-wave-flow path:last-child { stroke: var(--ps-copper); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-processing-wave-echo path { stroke: var(--ps-muted); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-emotion-preview strong { color: var(--ps-ink); }
:where(html[data-ps-theme="studio"]:is([data-ps-window="hub"][data-ps-screen="app"], [data-ps-window="workspace"][data-ps-screen="window"], [data-ps-window="assistant"][data-ps-screen="window"])) #psai-processing-overlay[data-ps-ia-portal="processing"] .psai-processing-card { scrollbar-color: var(--ps-line-strong) var(--ps-bg-soft); }
