/* Visible Voice Manager + explicitly owned body portals. A manager dialog
   keeps its theme independently of the section behind it (Lot 8.1).
   Shared AI Dubbing pickers and historical injected CSS remain untouched. */
html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]:has(#appContainer > main > #section-voice-manager:not(.hidden)),
:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) body:has(#appContainer > main > #section-voice-manager:not(.hidden)) {
  background: var(--ps-bg);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]:has(#appContainer > main > #section-voice-manager:not(.hidden))) #section-voice-manager:not(.hidden) {
  min-width: 0;
  max-width: 100%;
  background: var(--ps-bg);
  border-color: var(--ps-line);
  box-shadow: var(--ps-shell-reflection), 0 8px 24px #0003;
  overflow-anchor: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) {
  min-width: 0;
  max-width: 100%;
  font-family: var(--ps-font-ui);
  color: var(--ps-text);
  overflow-wrap: anywhere;
  container-type: inline-size;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #vmModalOverlay[data-ps-voice-manager="manager"] {
  --ps-vm-overlay: #0009;
  --ps-vm-modal-line: var(--ps-line);
  --ps-vm-modal-bg: var(--ps-bg-soft);
  --ps-vm-modal-shadow: 0 24px 60px #0009;
  background: var(--ps-vm-overlay);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(.vm-shell,.vm-panel,.vm-panel-body,.vm-row > div,.vm-field,.vm-toolbar-left,.vm-toolbar-right,.vm-hero > div) {
  min-width: 0;
  max-width: 100%;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(.vm-hero,.vm-panel) {
  background: var(--ps-surface-soft);
  border-color: var(--ps-line);
  box-shadow: var(--ps-shell-reflection);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(.vm-panel-header,.vm-modal-header) {
  background: var(--ps-surface-solid);
  border-color: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(.vm-panel-icon,.vm-row-icon) {
  background: var(--ps-surface-solid);
  color: var(--ps-gold-light);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(.vm-title,.vm-panel-title,.vm-row-title,.vm-modal-header h3) {
  color: var(--ps-ink);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-eyebrow {
  color: var(--ps-gold);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(.muted,.vm-subtitle,.vm-row-meta,.vm-folder-count,.vm-library-group-title,.vm-field label) {
  color: var(--ps-muted);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(.vm-row,.vm-empty) {
  background: var(--ps-bg-soft);
  border-color: var(--ps-line);
  box-shadow: var(--ps-shell-reflection);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-empty {
  color: var(--ps-muted);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-tag {
  max-width: 100%;
  background: var(--ps-surface-solid);
  color: var(--ps-muted);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-modal {
  background: var(--ps-bg-soft);
  border-color: var(--ps-line);
  box-shadow: 0 24px 60px #0009;
  container-type: inline-size;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-modal-actions {
  background: var(--ps-surface-soft);
  border-color: var(--ps-line);
  flex-wrap: wrap;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-character-image-preview {
  background: var(--ps-surface-solid);
  border-color: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-library-groups > div {
  min-width: 0;
  container-type: inline-size;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) button {
  max-width: 100%;
  background: var(--ps-surface-soft);
  border-color: var(--ps-line-strong);
  color: var(--ps-text);
  font-family: var(--ps-font-ui);
  box-shadow: var(--ps-shell-reflection);
  overflow-wrap: anywhere;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) button:hover:not(:disabled) {
  background: var(--ps-bg-soft);
  border-color: var(--ps-gold);
  color: var(--ps-ink);
  box-shadow: var(--ps-shell-reflection);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(.vm-tab.active,.vm-folder-btn.active) {
  background: var(--ps-surface-solid);
  border-color: var(--ps-gold);
  color: var(--ps-ink);
  box-shadow: var(--ps-shell-reflection);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .btn-primary {
  background: var(--ps-button-bg);
  border-color: var(--ps-button-border);
  color: var(--ps-button-text);
  box-shadow: var(--ps-button-shadow);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .btn-primary:hover:not(:disabled) {
  background: var(--ps-button-hover);
  color: var(--ps-button-text);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .btn-danger {
  background: #331f25;
  border-color: #82434f;
  color: #fda4af;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .btn-danger:hover:not(:disabled) {
  background: #48232b;
  border-color: #fda4af;
  color: #fecdd3;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(input,textarea,select) {
  min-width: 0;
  max-width: 100%;
  background: var(--ps-bg-soft);
  border-color: var(--ps-line-strong);
  color: var(--ps-text);
  font-family: var(--ps-font-ui);
  color-scheme: dark;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-search {
  width: 280px;
  min-width: 0;
  max-width: 100%;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(input,textarea)::placeholder {
  color: var(--ps-muted);
  opacity: .75;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(input,textarea,select):focus {
  box-shadow: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(input,textarea,select,button):focus-visible {
  outline: 2px solid var(--ps-focus);
  outline-offset: 2px;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(input,textarea,select,button):disabled {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) input[type="file"]::file-selector-button {
  background: var(--ps-surface-soft);
  color: var(--ps-text);
  border: 1px solid var(--ps-line-strong);
  font-family: var(--ps-font-ui);
  border-radius: 6px;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-glossary-row {
  border-color: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-glossary-row input[aria-invalid="true"] {
  border-color: #fda4af;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) :is(.vm-glossary-error,[data-ps-vm-state="error"]) {
  color: #fda4af;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) [data-ps-vm-state="pending"] {
  color: #fcd34d;
}

@container (max-width: 900px) {

  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-layout, :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-library-groups { grid-template-columns: minmax(0,1fr); }

  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-hero { flex-direction: column; }

}

@container (max-width: 520px) {

  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-row { grid-template-columns: 44px minmax(0,1fr); }

  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-row-actions { grid-column: 1 / -1; flex-wrap: wrap; }

  :where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) :is(:where(#section-voice-manager:not(.hidden)) #voiceManagerRoot, #vmModalOverlay[data-ps-voice-manager="manager"]) .vm-tabs { flex-wrap: wrap; }

}

/* Existing validity states only: no HTML validation attribute is introduced.
   Keep these affordances local to manager-owned dialogs in both root states. */
:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #vmModalOverlay[data-ps-voice-manager="manager"] :is(input, textarea, select):hover:not(:disabled, :invalid, [aria-invalid="true"]) {
  border-color: var(--ps-gold);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"]) #vmModalOverlay[data-ps-voice-manager="manager"] :is(input, textarea, select):is(:invalid, [aria-invalid="true"]) {
  border-color: #fda4af;
}
