/* Living Drama Studio: the dark cinematic look of the player (web/style.css tokens), laid out as a work
   surface. Mobile first; two columns from 900 px. Every control is at least 44 px tall and has a visible
   focus ring. Class names carry an "st-" prefix so they never collide with the player's. */

:root {
  --st-bg: var(--bg, #07080b);
  --st-panel: var(--frame, #111318);
  --st-edge: var(--frame-edge, #1c1f27);
  --st-raise: #171a21;
  --st-ink: var(--ink, #eceae4);
  --st-soft: var(--ink-soft, #a9a59b);
  --st-faint: var(--ink-faint, #6d6a63);
  --st-accent: var(--accent, #e7b98a);
  --st-accent-ink: #1a130c;
  --st-pass: #7fc49a;
  --st-weak: #e6c170;
  --st-fail: #ef8a7c;
  --st-danger: #ef8a7c;
  --st-focus: #9fd0ff;
  --st-radius: 12px;
  --st-touch: 44px;
  --st-sans: var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif);
  --st-serif: var(--serif, Georgia, serif);
  --st-mono: var(--mono, ui-monospace, Menlo, Consolas, monospace);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body.st-body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(120% 60% at 50% 0%, #121520 0%, var(--st-bg) 60%) fixed, var(--st-bg);
  color: var(--st-ink);
  font: 16px/1.5 var(--st-sans);
  -webkit-font-smoothing: antialiased;
}

.st-body a { color: var(--st-accent); }
.st-body :focus-visible { outline: 3px solid var(--st-focus); outline-offset: 2px; border-radius: 6px; }
.st-body h1, .st-body h2, .st-body h3, .st-body h4 { font-family: var(--st-serif); font-weight: 600; line-height: 1.2; margin: 0 0 8px; }
.st-body h1 { font-size: 1.6rem; }
.st-body h2 { font-size: 1.2rem; }
.st-body h3 { font-size: 1.05rem; }
.st-body h4 { font-size: 1rem; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.st-skip { position: absolute; left: 8px; top: -60px; padding: 10px 14px; background: var(--st-accent); color: var(--st-accent-ink); border-radius: 8px; z-index: 50; }
.st-skip:focus { top: 8px; }

/* -- header ------------------------------------------------------------------------------------- */
.st-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; min-height: 60px;
  background: rgba(7, 8, 11, 0.88); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--st-edge);
}
.st-brand { color: var(--st-ink) !important; text-decoration: none; font: 600 1.05rem var(--st-serif); display: inline-flex; align-items: center; min-height: var(--st-touch); }
.st-brand-sub { color: var(--st-accent); margin-left: 6px; font-family: var(--st-sans); font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; }
.st-header-right { display: flex; align-items: center; gap: 8px; }
.st-header-right { min-width: 0; }
.st-account { flex: 0 0 auto; }
.st-brand { min-width: 0; flex: 0 1 auto; }
#accountBtn { display: block; max-width: 22vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: calc(var(--st-touch) - 2px); padding: 0 10px; }
.st-credits {
  margin: 0; display: inline-flex; flex-direction: column; align-items: flex-end; justify-content: center;
  min-height: var(--st-touch); padding: 4px 12px; border-radius: 999px;
  background: var(--pill-bg, rgba(20, 22, 28, 0.55)); border: 1px solid var(--pill-edge, rgba(236, 234, 228, 0.18));
  line-height: 1.15;
}
.st-credits-main { font-weight: 600; color: var(--st-accent); font-variant-numeric: tabular-nums; }
.st-credits-day { font-size: 0.72rem; color: var(--st-soft); font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {  /* phone header: keep the pill on one short line each, never clipped */
  .st-credits { border-radius: 14px; padding: 4px 10px; white-space: nowrap; }
  .st-credits-main { font-size: 0.9rem; }
  .st-credits-day { font-size: 0.66rem; }
}
.st-credits.st-bump { animation: st-bump 700ms ease; }
@keyframes st-bump { 0% { box-shadow: 0 0 0 0 rgba(231, 185, 138, 0.7); } 100% { box-shadow: 0 0 0 12px rgba(231, 185, 138, 0); } }

.st-account { position: relative; }
.st-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 30;
  padding: 8px; border-radius: var(--st-radius); background: var(--st-raise); border: 1px solid var(--st-edge);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.st-menu p { margin: 4px 8px; }
.st-menu-email { font-weight: 600; word-break: break-all; }
.st-menu-plan { color: var(--st-soft); font-size: 0.85rem; }
.st-menu-item {
  display: flex; align-items: center; width: 100%; min-height: var(--st-touch); padding: 0 8px; margin-top: 4px;
  border: 0; border-radius: 8px; background: transparent; color: var(--st-ink) !important; font: inherit; text-align: left;
  text-decoration: none; cursor: pointer;
}
.st-menu-item:hover { background: rgba(255, 255, 255, 0.06); }

/* -- buttons and inputs ---------------------------------------------------------------------------- */
.st-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--st-touch); min-width: var(--st-touch); padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--st-edge); background: var(--st-raise); color: var(--st-ink) !important;
  font: 500 0.95rem var(--st-sans); text-decoration: none; cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.st-btn:hover:not(:disabled) { border-color: #333846; background: #1d2029; }
.st-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.st-btn[aria-busy="true"] { cursor: progress; }
.st-live { margin: 8px 0 0; font: 0.9rem/1.4 var(--st-sans); color: var(--st-soft); min-height: 1.4em; }
.st-live[data-tone="busy"]::before { content: "● "; color: var(--st-accent); }
.st-live[data-tone="ok"] { color: var(--st-pass); }
.st-live[data-tone="error"] { color: var(--st-danger); }
.st-primary { background: var(--st-accent); border-color: var(--st-accent); color: var(--st-accent-ink) !important; }
.st-primary:hover:not(:disabled) { background: #f0c9a0; border-color: #f0c9a0; }
.st-ghost { background: transparent; }
.st-danger { color: var(--st-danger) !important; }
.st-primary.st-danger { background: var(--st-danger); border-color: var(--st-danger); color: #210b08 !important; }
.st-small { min-height: var(--st-touch); padding: 0 12px; font-size: 0.85rem; }
.st-icon { padding: 0; width: var(--st-touch); font-size: 1rem; }
.st-cost {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.28);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.st-primary .st-cost { background: rgba(0, 0, 0, 0.14); }
.st-linkbtn { background: none; border: 0; color: var(--st-accent); font: inherit; text-align: left; padding: 6px 0; min-height: var(--st-touch); cursor: pointer; text-decoration: underline; }

.st-input {
  width: 100%; min-height: var(--st-touch); padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--st-edge); background: #0c0e12; color: var(--st-ink);
  font: 0.95rem/1.4 var(--st-sans);
}
textarea.st-input { resize: vertical; }
select.st-input { padding-right: 28px; }
.st-input[aria-invalid="true"], [aria-invalid="true"] > .st-input, fieldset[aria-invalid="true"], div[aria-invalid="true"] {
  border-color: var(--st-fail); box-shadow: 0 0 0 1px var(--st-fail);
}
.st-field { display: block; margin: 12px 0 4px; font-size: 0.8rem; color: var(--st-soft); letter-spacing: 0.02em; }
.st-optional { color: var(--st-faint); }
.st-check { display: inline-flex; align-items: center; gap: 8px; min-height: var(--st-touch); margin-right: 14px; cursor: pointer; }
.st-check input { width: 20px; height: 20px; accent-color: var(--st-accent); }
.st-counter { text-align: right; margin: 4px 0 0; }
.st-meta { color: var(--st-soft); font-size: 0.85rem; }
.st-hint { margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: rgba(231, 185, 138, 0.1); border: 1px solid rgba(231, 185, 138, 0.3); color: var(--st-ink); }
.st-empty { color: var(--st-soft); padding: 16px 0; }
.st-loading { color: var(--st-faint); list-style: none; padding: 12px 0; }
.st-lede { color: var(--st-soft); margin: 0 0 12px; }
.st-badge {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--st-edge); color: var(--st-soft); white-space: nowrap;
}
.st-stale { color: var(--st-weak); border-color: rgba(230, 193, 112, 0.5); }

.st-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.st-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.st-row .st-input { width: auto; flex: 1 1 120px; }
.st-grid2, .st-grid3 { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) {
  .st-grid2 { grid-template-columns: 1fr 1fr; }
  .st-grid3 { grid-template-columns: repeat(3, 1fr); }
}

/* -- layout ---------------------------------------------------------------------------------------- */
.st-main { max-width: 1240px; margin: 0 auto; padding: 16px 16px 140px; outline: none; }
.st-statescreen { max-width: 520px; margin: 12vh auto; text-align: center; }
.st-statescreen p { color: var(--st-soft); }
.st-state-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.st-card { background: var(--st-panel); border: 1px solid var(--st-edge); border-radius: var(--st-radius); padding: 16px; margin: 0 0 12px; }
.st-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.st-card-head h3, .st-card-head h4 { margin: 0; margin-right: auto; }

.st-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 16px; }
.st-page-head h1 { margin: 0; }
.st-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.st-project {
  display: flex; flex-direction: column; height: 100%; text-decoration: none; color: var(--st-ink) !important;
  border-radius: var(--st-radius); overflow: hidden; background: var(--st-panel); border: 1px solid var(--st-edge);
}
.st-project:hover { border-color: #333846; }
.st-project-cover { aspect-ratio: 9 / 16; max-height: 260px; background: linear-gradient(160deg, #1b2130, #0c0e12); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.st-project-cover img { width: 100%; height: 100%; object-fit: cover; }
.st-project-initial { font: 600 2.4rem var(--st-serif); color: var(--st-faint); }
.st-project-body { padding: 10px 12px 12px; }
.st-project-title { font-size: 1rem; margin: 0 0 4px; }
.st-project-body .st-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }

.st-ws-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 12px; }
.st-ws-head h1 { margin: 0; font-size: 1.35rem; }
.st-back { display: inline-flex; align-items: center; min-height: var(--st-touch); text-decoration: none; }
.st-ws-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

.st-tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px;
  border-bottom: 1px solid var(--st-edge);
}
.st-tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; min-height: var(--st-touch); padding: 0 14px;
  color: var(--st-soft) !important; text-decoration: none; border-bottom: 2px solid transparent; cursor: pointer;
}
.st-tab[aria-selected="true"] { color: var(--st-ink) !important; border-bottom-color: var(--st-accent); }
.st-tab[aria-disabled="true"] { color: var(--st-faint) !important; cursor: not-allowed; }
.st-tab[aria-disabled="true"]::after { content: " ·"; }

.st-ws-body { display: grid; grid-template-columns: 1fr; gap: 16px; }
.st-ws-side .st-card { position: static; }
.st-counts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 0.9rem; }
.st-counts dt { color: var(--st-soft); }
.st-counts dd { margin: 0; font-variant-numeric: tabular-nums; }

@media (min-width: 900px) {
  .st-ws-body { grid-template-columns: minmax(0, 1fr) 280px; }
  .st-ws-side .st-card { position: sticky; top: 76px; }
  .st-tabs { margin: 0 0 12px; padding: 0; }
  .st-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}

/* -- script editor ---------------------------------------------------------------------------------- */
.st-idea-text { font-family: var(--st-serif); font-size: 1.05rem; white-space: pre-wrap; margin: 0 0 4px; }
.st-toolbar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; margin: 16px 0 8px; }
.st-toolbar h2 { margin: 0; }
.st-dirty { color: var(--st-weak); font-size: 0.85rem; }
.st-dirty::before { content: "● "; }
.st-errors { border: 1px solid var(--st-fail); background: rgba(239, 138, 124, 0.08); border-radius: var(--st-radius); padding: 8px 14px; margin: 8px 0; }
.st-errors p { margin: 6px 0; font-weight: 600; }
.st-errors ul { margin: 0; padding-left: 18px; }
.st-section { border: 1px solid var(--st-edge); border-radius: var(--st-radius); padding: 8px 14px 14px; margin: 0 0 12px; background: var(--st-panel); min-width: 0; }
.st-section > legend { padding: 0 6px; font: 600 0.95rem var(--st-serif); color: var(--st-accent); }
.st-cards { display: grid; gap: 10px; grid-template-columns: 1fr; margin-bottom: 8px; }
@media (min-width: 1100px) { .st-cards { grid-template-columns: 1fr 1fr; } }
.st-subcard { background: var(--st-raise); margin: 0; }
.st-more > summary, .st-scene > summary { cursor: pointer; min-height: var(--st-touch); display: flex; align-items: center; gap: 6px; }
.st-more > summary { color: var(--st-soft); font-size: 0.9rem; }
.st-scene { border: 1px solid var(--st-edge); border-radius: 10px; padding: 0 12px; margin: 0 0 10px; background: var(--st-raise); }
.st-scene[open] { padding-bottom: 12px; }
.st-scene > summary { font-weight: 600; }
.st-scene-tools, .st-beat-tools { display: flex; gap: 4px; justify-content: flex-end; }
.st-chars { border: 0; padding: 0; margin: 8px 0 0; }
.st-chars legend { padding: 0; }
.st-beats { list-style: none; margin: 12px 0 8px; padding: 0; display: grid; gap: 8px; }
.st-beat { border-left: 3px solid var(--st-edge); padding: 4px 0 8px 12px; border-radius: 0 8px 8px 0; background: rgba(0, 0, 0, 0.18); }
.st-beat-dialogue { border-left-color: #6aa7d8; }
.st-beat-whisper { border-left-color: var(--st-accent); }
.st-beat-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.st-beat-id { font: 0.8rem var(--st-mono); color: var(--st-faint); align-self: center; min-width: 2.2em; }
.st-inline { flex: 1 1 130px; }
.st-inline .st-field { margin-top: 4px; }
.st-beat-tools { margin-left: auto; }
.st-choices { display: grid; gap: 6px; margin-top: 6px; }
.st-choice { display: grid; grid-template-columns: 1fr; gap: 0 8px; align-items: end; padding: 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); }
@media (min-width: 700px) { .st-choice { grid-template-columns: 80px 1fr 1.4fr auto; } }
.st-rewrite { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.st-rewrite .st-input { flex: 1 1 200px; width: auto; }
.st-savebar {
  position: sticky; bottom: 8px; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px;
  border-radius: var(--st-radius); background: rgba(17, 19, 24, 0.95); border: 1px solid var(--st-edge);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.st-savebar .st-input { flex: 1 1 200px; width: auto; }
.st-flash { animation: st-flash 2.4s ease; }
@keyframes st-flash { 0%, 60% { box-shadow: 0 0 0 3px var(--st-accent); background-color: rgba(231, 185, 138, 0.16); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* -- versions drawer --------------------------------------------------------------------------------- */
.st-drawer {
  position: fixed; z-index: 40; inset: auto 0 0 0; max-height: 85vh; overflow-y: auto;
  padding: 12px 16px 24px; background: var(--st-raise); border-top: 1px solid var(--st-edge);
  border-radius: 16px 16px 0 0; box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
}
@media (min-width: 900px) {
  .st-drawer { inset: 60px 0 0 auto; width: 440px; max-height: none; border-radius: 0; border-top: 0; border-left: 1px solid var(--st-edge); }
}
.st-drawer-head { display: flex; align-items: center; justify-content: space-between; }
.st-versions { list-style: none; margin: 0; padding: 0; }
.st-version { border-bottom: 1px solid var(--st-edge); padding: 10px 0; }
.st-version-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.st-version-summary { margin: 4px 0 0; color: var(--st-soft); font-size: 0.9rem; }
.st-diff { margin-top: 16px; }
.st-diff-out { font: 0.78rem/1.45 var(--st-mono); white-space: pre-wrap; word-break: break-word; background: #0b0c10; border: 1px solid var(--st-edge); border-radius: 10px; padding: 10px; max-height: 50vh; overflow: auto; margin: 0; }
.st-add { display: block; background: rgba(127, 196, 154, 0.14); color: #bfe8cd; }
.st-del { display: block; background: rgba(239, 138, 124, 0.12); color: #f3c0b8; text-decoration: line-through; text-decoration-color: rgba(239, 138, 124, 0.5); }
.st-same { display: block; color: var(--st-faint); }

/* -- review ------------------------------------------------------------------------------------------ */
.st-checklist { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.st-ck { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--st-panel); border: 1px solid var(--st-edge); border-left-width: 4px; }
.st-ck-icon { grid-row: 1 / span 2; font-weight: 700; font-size: 1.1rem; align-self: center; width: 1.2em; text-align: center; }
.st-ck-label { font-size: 0.85rem; }
.st-ck-status { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.st-ck-pass { border-left-color: var(--st-pass); } .st-ck-pass .st-ck-icon, .st-ck-pass .st-ck-status { color: var(--st-pass); }
.st-ck-weak { border-left-color: var(--st-weak); } .st-ck-weak .st-ck-icon, .st-ck-weak .st-ck-status { color: var(--st-weak); }
.st-ck-fail { border-left-color: var(--st-fail); } .st-ck-fail .st-ck-icon, .st-ck-fail .st-ck-status { color: var(--st-fail); }
.st-ck-none .st-ck-status { color: var(--st-faint); }
.st-applybar { position: sticky; top: 68px; z-index: 4; background: rgba(17, 19, 24, 0.96); border: 1px solid var(--st-edge); border-radius: var(--st-radius); padding: 4px 14px; margin: 8px 0 12px; }
.st-note-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.st-note-item { font-weight: 600; }
.st-note-status { margin-left: auto; font-size: 0.8rem; color: var(--st-soft); }
.st-sev-must { color: var(--st-fail); border-color: rgba(239, 138, 124, 0.5); }
.st-sev-should { color: var(--st-weak); border-color: rgba(230, 193, 112, 0.5); }
.st-sev-could { color: var(--st-soft); }
.st-note-accepted { border-color: rgba(127, 196, 154, 0.55); }
.st-note-rejected { opacity: 0.6; }
.st-note-applied { opacity: 0.7; border-style: dashed; }
.st-note p { margin: 6px 0; }
.st-quote { margin: 6px 0; padding: 4px 12px; border-left: 3px solid var(--st-edge); font-family: var(--st-serif); font-style: italic; color: var(--st-soft); }
.st-autofix { color: var(--st-pass); }

/* -- breakdown tables ------------------------------------------------------------------------------------ */
.st-tablewrap { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--st-edge); border-radius: var(--st-radius); background: var(--st-panel); }
.st-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.st-table caption { text-align: left; padding: 10px 12px 4px; font: 600 1rem var(--st-serif); color: var(--st-accent); }
.st-table th, .st-table td { padding: 8px 12px; text-align: left; vertical-align: top; border-top: 1px solid var(--st-edge); }
.st-table th { color: var(--st-soft); font-weight: 500; white-space: nowrap; }
.st-table td { min-width: 80px; }
.st-warnings { border: 1px solid rgba(230, 193, 112, 0.45); background: rgba(230, 193, 112, 0.08); border-radius: var(--st-radius); padding: 8px 14px; margin: 0 0 12px; }
.st-warnings ul { margin: 4px 0 0; padding-left: 18px; }

/* -- cast, locations, storyboard ------------------------------------------------------------------------------ */
.st-records { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 1100px) { .st-records { grid-template-columns: 1fr 1fr; } }
.st-state { font-size: 0.78rem; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--st-edge); color: var(--st-soft); white-space: nowrap; }
.st-state-approved { color: var(--st-pass); border-color: rgba(127, 196, 154, 0.5); }
.st-state-drafting { color: var(--st-focus); border-color: rgba(159, 208, 255, 0.5); }
.st-state-choose { color: var(--st-accent); border-color: rgba(231, 185, 138, 0.5); }
.st-state-stale { color: var(--st-weak); border-color: rgba(230, 193, 112, 0.5); }
.st-state-drafting.st-state { animation: st-pulse 1.6s ease-in-out infinite; }
@keyframes st-pulse { 50% { opacity: 0.55; } }
.st-count { width: auto; }
.st-strip { list-style: none; margin: 10px 0; padding: 0 0 6px; display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; }
.st-strip > li { flex: 0 0 auto; scroll-snap-align: start; }
.st-draft, .st-take {
  display: flex; flex-direction: column; width: 124px; padding: 0; border-radius: 10px; overflow: hidden;
  border: 2px solid var(--st-edge); background: #0c0e12; color: var(--st-ink); font: inherit; text-align: left; cursor: pointer;
}
.st-take { cursor: default; width: 150px; }
.st-draft img, .st-take img { display: block; width: 100%; aspect-ratio: 9 / 16; object-fit: cover; background: #1a1d24; }
.st-noimg { display: flex; align-items: center; justify-content: center; aspect-ratio: 9 / 16; color: var(--st-faint); font-size: 0.8rem; }
.st-draft-cap { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 0.78rem; }
.st-parent { color: var(--st-soft); font-size: 0.72rem; }
.st-draft.st-selected { border-color: var(--st-accent); }
.st-draft.st-approved, .st-take.st-approved { box-shadow: 0 0 0 2px var(--st-pass) inset; }
.st-take .st-btn { margin: 0 6px 6px; }
.st-bible { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 0.85rem; margin: 4px 0 8px; }
.st-bible dt { color: var(--st-soft); text-transform: capitalize; }
.st-bible dd { margin: 0; }

.st-sb-scene { margin: 0 0 20px; }
.st-sb-scene > h3 { margin: 0 0 4px; }
.st-sb-shots { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 8px; }
@media (min-width: 1100px) { .st-sb-shots { grid-template-columns: 1fr 1fr; } }
.st-shot-approved { border-color: rgba(127, 196, 154, 0.45); }
.st-blocked { margin: 8px 0; padding: 8px 12px; border-radius: 10px; background: rgba(239, 138, 124, 0.08); border: 1px solid rgba(239, 138, 124, 0.4); }
.st-blocked a { display: inline-block; min-height: 32px; padding: 4px 2px; }

/* -- job tray and toasts ----------------------------------------------------------------------------------- */
.st-tray {
  position: fixed; z-index: 35; left: 8px; right: 8px; bottom: 8px; max-height: 40vh; overflow-y: auto;
  padding: 8px 12px; border-radius: var(--st-radius); background: rgba(23, 26, 33, 0.97); border: 1px solid var(--st-edge);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
@media (min-width: 900px) { .st-tray { left: auto; width: 360px; right: 16px; bottom: 16px; } }
.st-tray-title { font: 600 0.8rem var(--st-sans) !important; text-transform: uppercase; letter-spacing: 0.1em; color: var(--st-soft); margin: 2px 0 6px !important; }
.st-jobs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.st-job { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 0; border-top: 1px solid var(--st-edge); font-size: 0.88rem; }
.st-job:first-child { border-top: 0; }
.st-job-kind { font-weight: 600; }
.st-job-status { color: var(--st-soft); font-variant-numeric: tabular-nums; }
.st-job-prog, .st-job-credits { color: var(--st-soft); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.st-job-error { flex-basis: 100%; color: var(--st-fail); font-size: 0.82rem; }
.st-job-succeeded .st-job-status { color: var(--st-pass); }
.st-job-failed .st-job-status { color: var(--st-fail); }
.st-job .st-btn { margin-left: auto; }

.st-toasts { position: fixed; z-index: 60; top: 68px; left: 50%; transform: translateX(-50%); width: min(92vw, 460px); display: grid; gap: 8px; pointer-events: none; }
.st-toast {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 10px; pointer-events: auto;
  background: #1f232c; border: 1px solid #2b303c; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.st-toast span { flex: 1; }
.st-toast-error { border-color: rgba(239, 138, 124, 0.6); }
.st-toast-x { min-width: var(--st-touch); min-height: var(--st-touch); border: 0; background: transparent; color: var(--st-soft); font-size: 1.2rem; cursor: pointer; border-radius: 8px; }

/* -- dialogs ------------------------------------------------------------------------------------------------ */
.st-dialog { width: min(94vw, 560px); padding: 0; border-radius: 16px; border: 1px solid var(--st-edge); background: var(--st-raise); color: var(--st-ink); }
.st-dialog::backdrop { background: rgba(0, 0, 0, 0.66); }
.st-dialog-form { padding: 18px; }
.st-dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.st-form-error { color: var(--st-fail); }

/* -- animatic (animatic.js) ------------------------------------------------------------------------------------ */
.an-root {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: #000; padding: 10px;
}
.an-frame {
  position: relative; overflow: hidden; background: #07080b; border-radius: 12px; cursor: pointer;
  height: min(calc(100vh - 90px), calc((100vw - 20px) * 16 / 9)); aspect-ratio: 9 / 16;
}
.an-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform-origin: 0 0; will-change: transform; }
.an-missing { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; color: var(--st-faint); }
.an-scrim { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(4, 5, 7, 0.7) 0%, rgba(4, 5, 7, 0) 22%, rgba(4, 5, 7, 0) 62%, rgba(4, 5, 7, 0.88) 100%); }
.an-title { position: absolute; top: 14px; left: 16px; right: 16px; margin: 0; font: 0.72rem var(--st-sans); letter-spacing: 0.14em; text-transform: uppercase; color: rgba(236, 234, 228, 0.75); }
.an-sub {
  position: absolute; left: 16px; right: 16px; bottom: 30px; margin: 0; text-align: center;
  font: 1.05rem/1.4 var(--st-sans); color: #f5f3ee; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
}
.an-who { color: var(--st-accent); font-weight: 600; }
.an-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, 0.12); }
.an-fill { height: 100%; width: 0; background: var(--st-accent); }
.an-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.an-btn {
  min-height: var(--st-touch); min-width: var(--st-touch); padding: 0 14px; border-radius: 10px;
  border: 1px solid #2b303c; background: #15181f; color: #eceae4; font: 500 0.9rem var(--st-sans); cursor: pointer;
}
.an-btn:focus-visible { outline: 3px solid var(--st-focus); outline-offset: 2px; }
.an-primary { background: var(--st-accent); border-color: var(--st-accent); color: var(--st-accent-ink); }
.an-count { color: #a9a59b; font-size: 0.85rem; font-variant-numeric: tabular-nums; min-width: 4em; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .st-btn, .st-credits.st-bump, .st-flash, .st-state-drafting.st-state { transition: none; animation: none; }
  .an-img, .an-fill { transition: none !important; }
}

/* -- confirm dialog: the itemised estimate ------------------------------------------------------------------ */
.st-confirm-items { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.st-confirm-items li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); }

/* -- Production and Film (production.js, timeline.js, preview.js) ----------------------------------------------
   Mobile first (390 px): one column, the preview on top (width 100%, max-height 56vh), the timeline in its own
   horizontally scrolling box, the inspector as a bottom sheet. The page itself never scrolls sideways. */
.st-ws-body:has(#panel-production:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
.st-ws-body:has(#panel-production:not([hidden])) > .st-ws-side { display: none; }
.pr-body { min-width: 0; max-width: 100%; }
.pr-head-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.pr-head-row h2, .pr-head-row h3 { margin: 0; margin-right: auto; }
.pr-newer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pr-totals { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 0; font-variant-numeric: tabular-nums; }
.pr-totals dt { color: var(--st-soft); }
.pr-totals dd { margin: 0; }
.pr-est summary { min-height: var(--st-touch); display: flex; align-items: center; cursor: pointer; color: var(--st-soft); }
.pr-est-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pr-est-items li { display: flex; justify-content: space-between; gap: 12px; }

.pr-voice-strip { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pr-voice { display: flex; align-items: center; gap: 4px; border: 1px solid var(--st-edge); border-radius: 12px; background: var(--st-raise); padding: 2px 4px 2px 2px; max-width: 100%; }
.pr-voice-open { border-color: var(--st-accent); }
.pr-voice-off { opacity: 0.6; }
.pr-voice-btn { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: var(--st-touch); padding: 4px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--st-ink); font: inherit; cursor: pointer; text-align: left; min-width: 0; }
.pr-voice-name { font-weight: 600; overflow-wrap: anywhere; }
.st-state-none { color: var(--st-faint); }
.pr-picks, .pr-auditions { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 8px; }
.pr-pick, .pr-audition { padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--st-edge); min-width: 0; }
.pr-audition.st-approved { border-color: rgba(127, 196, 154, 0.55); }
.pr-why { margin: 4px 0 0; color: var(--st-soft); font-size: 0.88rem; }
.pr-aud-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 6px; }
.pr-audio { display: block; width: 100%; max-width: 340px; height: var(--st-touch); margin: 4px 0; }
.pr-catalog > summary { min-height: var(--st-touch); display: flex; align-items: center; cursor: pointer; color: var(--st-accent); }
.pr-slider { display: flex; align-items: center; gap: 10px; }
.pr-range { flex: 1 1 auto; min-width: 0; min-height: var(--st-touch); accent-color: var(--st-accent); }
.pr-slider output { min-width: 4.5em; font-variant-numeric: tabular-nums; color: var(--st-soft); }
.pr-radios { border: 0; padding: 0; margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 0 8px; }
.pr-radios legend { padding: 0; }

.pr-scenes { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.pr-scene { display: flex; gap: 12px; align-items: flex-start; margin: 0; min-width: 0; }
.pr-thumb { flex: 0 0 72px; border-radius: 8px; overflow: hidden; background: #0c0e12; }
.pr-thumb img { display: block; width: 100%; aspect-ratio: 9 / 16; object-fit: cover; }
.pr-scene-body { flex: 1 1 auto; min-width: 0; }
.pr-scene-body h3 { margin: 0 0 2px; overflow-wrap: anywhere; }
.pr-chips { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 560px) { .pr-chips { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pr-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--st-edge); border-left-width: 4px; background: var(--st-panel); font-size: 0.82rem; min-width: 0; }
.pr-chip-icon { font-weight: 700; width: 1.1em; text-align: center; }
.pr-chip-label { font-weight: 600; }
.pr-chip-state { color: var(--st-soft); margin-left: auto; white-space: nowrap; }
.pr-chip-ready { border-left-color: var(--st-pass); } .pr-chip-ready .pr-chip-icon { color: var(--st-pass); }
.pr-chip-working { border-left-color: var(--st-focus); } .pr-chip-working .pr-chip-icon { color: var(--st-focus); }
.pr-chip-partial, .pr-chip-stale, .pr-chip-fallback { border-left-color: var(--st-weak); }
.pr-chip-partial .pr-chip-icon, .pr-chip-stale .pr-chip-icon, .pr-chip-fallback .pr-chip-icon { color: var(--st-weak); }
.pr-chip-blocked, .pr-chip-error { border-left-color: var(--st-fail); } .pr-chip-blocked .pr-chip-icon, .pr-chip-error .pr-chip-icon { color: var(--st-fail); }
.pr-chip-todo .pr-chip-icon { color: var(--st-faint); }

/* scene editor */
.pe-root { outline: none; min-width: 0; }
.pe-head .st-back { margin-right: 4px; }
.pe-state-dirty, .pe-state-conflict { color: var(--st-weak); border-color: rgba(230, 193, 112, 0.5); }
.pe-state-saving, .pe-state-rendering { color: var(--st-focus); border-color: rgba(159, 208, 255, 0.5); }
.pe-state-rendered { color: var(--st-pass); border-color: rgba(127, 196, 154, 0.5); }
.pe-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 8px 0; }
.pe-left { min-width: 0; }
.pe-preview { width: 100%; max-height: 56vh; display: flex; justify-content: center; }
.pv-root { width: 100%; display: flex; justify-content: center; }
.pv-frame {
  position: relative; overflow: hidden; background: #000; border-radius: 12px; aspect-ratio: 9 / 16;
  height: min(56vh, calc((100vw - 32px) * 16 / 9)); max-width: 100%;
}
.pv-layers, .pv-layer { position: absolute; inset: 0; overflow: hidden; }
.pv-img, .pv-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pv-img { transform-origin: 0 0; will-change: transform; }
.pv-black { position: absolute; inset: 0; background: #000; pointer-events: none; opacity: 0; }
.pv-sub {
  position: absolute; left: 8%; right: 8%; bottom: 14%; margin: 0; text-align: center; pointer-events: none;
  font: 600 1rem/1.35 var(--st-sans); color: #fff; text-shadow: 0 0 3px #000, 0 1px 3px #000, 0 0 6px rgba(0, 0, 0, 0.9);
}
.pv-status { position: absolute; top: 8px; left: 8px; right: 8px; margin: 0; padding: 4px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.6); color: var(--st-soft); font-size: 0.78rem; }
.pe-transport { margin-top: 8px; }
.pe-transport-row { display: flex; align-items: center; gap: 10px; }
.pe-play { flex: 0 0 auto; min-width: 56px; }
.pe-scrub { flex: 1 1 auto; min-width: 0; min-height: var(--st-touch); accent-color: var(--st-accent); }
.pe-time { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--st-soft); font-size: 0.85rem; }
.pe-mutes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pe-mute[aria-pressed="false"] { color: var(--st-faint) !important; text-decoration: line-through; }
.pe-tip { margin: 6px 0 0; font-size: 0.78rem; }

.pe-timeline { margin: 12px 0; min-width: 0; }
.pe-tl-head { display: flex; align-items: center; gap: 8px; }
.pe-tl-head h3 { margin: 0; margin-right: auto; }
.pe-zoom { display: flex; gap: 4px; }
.pe-tl-scroll { overflow-x: auto; overflow-y: hidden; max-width: 100%; border: 1px solid var(--st-edge); border-radius: var(--st-radius); background: #0b0c10; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.pe-tl-inner { position: relative; }
.pe-row { display: flex; height: 52px; border-top: 1px solid var(--st-edge); }
.pe-row-ruler { height: 26px; border-top: 0; }
.pe-row-subtitles { height: 40px; }
.pe-label {
  position: sticky; left: 0; z-index: 2; flex: 0 0 88px; display: flex; align-items: center; padding: 0 8px;
  background: #111318; color: var(--st-soft); font-size: 0.75rem; border-right: 1px solid var(--st-edge);
}
.pe-lane, .pe-ruler { position: relative; flex: 1 0 auto; }
.pe-ruler { cursor: pointer; }
.pe-tick { position: absolute; top: 4px; font-size: 0.68rem; color: var(--st-faint); transform: translateX(-50%); }
.pe-blk {
  position: absolute; top: 4px; bottom: 4px; display: flex; align-items: center; gap: 4px; overflow: hidden;
  padding: 0 6px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.14); background: #1b1f28; color: var(--st-ink);
  font: 0.72rem/1.2 var(--st-sans); text-align: left; cursor: pointer; white-space: nowrap; min-height: var(--st-touch);
}
.pe-row-subtitles .pe-blk { min-height: 0; cursor: default; }
.pe-blk[aria-pressed="true"] { outline: 2px solid var(--st-accent); outline-offset: -2px; z-index: 1; }
.pe-blk-text { overflow: hidden; text-overflow: ellipsis; position: relative; }
.pe-blk-thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.45; pointer-events: none; }
.pe-blk-picture { background: #232838; }
.pe-blk-dialogue { background: rgba(106, 167, 216, 0.28); border-color: rgba(106, 167, 216, 0.55); }
.pe-blk-ambience { background: rgba(127, 196, 154, 0.2); border-color: rgba(127, 196, 154, 0.45); }
.pe-blk-sfx { background: rgba(230, 193, 112, 0.22); border-color: rgba(230, 193, 112, 0.5); }
.pe-blk-music { background: rgba(231, 185, 138, 0.2); border-color: rgba(231, 185, 138, 0.5); }
.pe-blk-subtitles { background: rgba(255, 255, 255, 0.06); color: var(--st-soft); }
.pe-muted { opacity: 0.45; border-style: dashed; }
.pe-badge-clip, .pe-badge-warn, .pe-badge-x { position: relative; font-size: 0.66rem; padding: 1px 5px; border-radius: 999px; background: rgba(0, 0, 0, 0.6); }
.pe-badge-warn { color: var(--st-weak); }
.pe-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--st-accent); pointer-events: none; z-index: 3; }

/* inspector: a bottom sheet on phones, a column from 900 px */
.pe-inspector {
  display: none; position: fixed; z-index: 37; left: 0; right: 0; bottom: 0; max-height: 50vh; overflow-y: auto;
  padding: 12px 16px 24px; background: var(--st-raise); border-top: 1px solid var(--st-edge); border-radius: 16px 16px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
}
.pe-inspector.pe-sheet-open { display: block; }
.pe-sheet-close { float: right; }
.pe-field { margin: 8px 0; }
.pe-toggle { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.pe-toggle .st-btn[aria-pressed="true"], .pe-dir[aria-checked="true"] { background: var(--st-accent); border-color: var(--st-accent); color: var(--st-accent-ink) !important; }
.pe-pro { color: var(--st-accent); border-color: rgba(231, 185, 138, 0.5); }
.pe-stepper { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pe-num { width: 7.5em; flex: 0 0 auto; }
.pe-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.pe-dir { min-height: var(--st-touch); padding: 0 12px; border-radius: 999px; border: 1px solid var(--st-edge); background: #0c0e12; color: var(--st-ink); font: 0.85rem var(--st-sans); cursor: pointer; }
.pe-line-text { font-family: var(--st-serif); font-size: 1.02rem; margin: 4px 0 10px; overflow-wrap: anywhere; }
.pe-paren { color: var(--st-soft); }
.pe-takes, .pe-clips { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.pe-take, .pe-clip { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--st-edge); background: rgba(255, 255, 255, 0.03); min-width: 0; }
.pe-take.st-approved, .pe-clip.st-approved { border-color: rgba(127, 196, 154, 0.55); }
.pe-clip-video, .pe-render-video, .pf-video { display: block; width: 100%; max-width: 320px; aspect-ratio: 9 / 16; max-height: 56vh; background: #000; border-radius: 10px; }
.pe-refusal p { margin: 0 0 6px; }
.pe-render { margin-top: 8px; }
.pe-materials { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.pe-mat-list { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 4px; font-size: 0.88rem; }
.pe-mat-list li { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 4px 0; border-top: 1px solid var(--st-edge); }
.pe-mat-id { font-family: var(--st-mono); color: var(--st-faint); }
.pe-mat-list li.st-clickable { cursor: pointer; border-radius: 6px; }
.pe-mat-list li.st-clickable:hover, .pe-mat-list li.st-clickable:focus-visible { background: var(--st-hover, rgba(255, 255, 255, 0.06)); outline: none; }
.pe-stale { border-color: rgba(230, 193, 112, 0.5); }

/* film view */
.pf-preview { margin-bottom: 6px; }
.pf-idle { align-self: center; }
.pf-progress { font-weight: 600; color: var(--st-focus); }
.pf-scenes, .pf-history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pf-scene, .pf-hist { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 0; border-top: 1px solid var(--st-edge); min-width: 0; }
.pf-scene-title { font-weight: 600; flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.pf-scene-actions { display: flex; gap: 6px; }

@media (min-width: 900px) {
  .pr-scenes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pe-stage { grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); align-items: start; }
  .pe-preview { max-height: none; }
  .pv-frame { height: min(70vh, 620px); }
  .pe-inspector, .pe-inspector.pe-sheet-open {
    display: block; position: static; max-height: none; overflow: visible; padding: 16px; border: 1px solid var(--st-edge);
    border-radius: var(--st-radius); background: var(--st-panel); box-shadow: none;
  }
  .pe-sheet-close { display: none; }
  .pe-materials { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .pv-img { transition: none !important; will-change: auto; }
  .pe-inspector { transition: none; }
}
