/* IA Script attached to the HUB only. No shared ancestor of Stage is styled. */
:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel {
  --ps-ia-script-surface-bg: var(--ps-surface-soft);
  --ps-ia-script-control-bg: var(--ps-bg-soft);
  --ps-ia-script-line: var(--ps-line);
  --ps-ia-script-active-line: var(--ps-gold);
  --ps-ia-script-active-bg: var(--ps-surface-solid);
  --ps-ia-script-selected-bg: var(--ps-surface-solid);
  --ps-ia-script-source-bg: var(--ps-bg);
  --ps-ia-script-text: var(--ps-text);
  --ps-ia-script-muted: var(--ps-muted);
  --ps-ia-script-accent: var(--ps-gold-light);
  --ps-ia-script-control-shadow: none;
  --ps-ia-script-menu-shadow: 0 18px 50px #0006;
  --ps-ia-script-row-bg: transparent;
  --ps-ia-script-option-bg: transparent;
  background: var(--ps-surface-solid);
  border-color: var(--ps-line);
  color: var(--ps-text);
  font-family: var(--ps-font-ui);
  box-shadow: 0 8px 24px #0003;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel:hover {
  box-shadow: 0 16px 40px #0004;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel > .admin-subcard-heading > h3 {
  color: var(--ps-ink);
  line-height: 21px;
  /* Historical minimum measured in Chromium: IBM's min-content is 0.390625px
     wider and would otherwise push both actions in the narrow 320px panel. */
  min-width: 43.78125px;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel .admin-subcard-icon {
  background: var(--ps-bg-soft);
  color: var(--ps-gold);
}

/* Preserve the text metrics that determine wrapping, row alignment and scroll.
   The temporary editor retains its inline monospace font and native geometry. */
:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel #tr-script-table-wrap {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  scrollbar-color: var(--ps-line-strong) var(--ps-surface-soft);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel :is(#tr-script-speaker-filter-menu, [data-script-editor]) {
  scrollbar-color: var(--ps-line-strong) var(--ps-surface-soft);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel #tr-script-table-wrap th {
  background: var(--ps-bg-soft);
  color: var(--ps-ink);
  border-color: var(--ps-line);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel #tr-script-table-body > tr:hover {
  --ps-ia-script-row-bg: var(--ps-bg-soft);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel #tr-script-table-body > tr[data-ps-ia-script-selected="true"] {
  --ps-ia-script-source-bg: var(--ps-surface-solid);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel #tr-script-table-body > tr[data-ps-ia-script-selected="true"] > td:first-child {
  box-shadow: inset 2px 0 var(--ps-gold);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel [data-script-speaker-filter-option]:hover:not(:disabled) {
  --ps-ia-script-option-bg: var(--ps-surface-solid);
  box-shadow: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel button:hover:not(:disabled) {
  --ps-ia-script-line: var(--ps-gold);
  --ps-ia-script-control-bg: var(--ps-surface-solid);
  box-shadow: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel [data-script-editor] {
  background: var(--ps-bg);
  border-color: var(--ps-line);
  color: var(--ps-text);
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel :is(button, [data-script-editor]):focus-visible {
  outline: 2px solid var(--ps-focus);
  outline-offset: -2px;
  box-shadow: none;
}

:where(html[data-ps-theme="studio"][data-ps-window="hub"][data-ps-screen="app"] #section-project-detail:not(.hidden) #projectDynamicZone > [data-ps-ia-dubbing="workspace"],
  html[data-ps-theme="studio"][data-ps-window="workspace"][data-ps-screen="window"] .iadubbing-detached-root[data-ps-ia-dubbing="detached-left"]) #tr-script-panel [data-script-editor]::selection {
  background: var(--ps-gold);
  color: var(--ps-bg);
}
