:root{color-scheme:dark;--bg:#141316;--panel:#1c1a1e;--raised:#242126;--line:#363039;--ink:#f1ebe6;--muted:#b8aeb8;--accent:#ecb692;--accent-ink:#27180e;font-family:Inter,system-ui,sans-serif}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font-size:14px}
button,input,textarea,select{font:inherit}button,.button{border:1px solid var(--line);border-radius:7px;background:var(--raised);color:var(--ink);padding:9px 12px;cursor:pointer;text-decoration:none;display:inline-flex;align-items:center;justify-content:center;gap:5px}
button:hover,.button:hover{border-color:var(--accent)}button:disabled{opacity:.46;cursor:not-allowed}button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.primary{background:var(--accent);color:var(--accent-ink);border-color:transparent;font-weight:700}.subtle{background:transparent}.danger{color:#efaaa7}
.top{display:flex;justify-content:space-between;align-items:center;padding:15px clamp(16px,4vw,60px);border-bottom:1px solid var(--line);gap:12px}.brand{font-size:17px;font-weight:720;color:inherit;text-decoration:none;white-space:nowrap}.mark{display:inline-grid;place-items:center;width:30px;height:30px;background:var(--accent);color:var(--accent-ink);border-radius:8px;margin-right:8px;font-family:Georgia,serif}.top-actions,.actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
#workspace{max-width:1490px;margin:auto;padding:28px clamp(15px,4vw,60px) 60px}.heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:18px}.title{font:normal clamp(32px,5vw,54px) Georgia,serif;background:transparent!important;border:none!important;padding:0!important;min-width:0}
nav{display:flex;gap:4px;border-bottom:1px solid var(--line);margin-bottom:22px}nav button{border:0;background:none;border-radius:0;color:var(--muted);padding:13px 17px;border-bottom:2px solid transparent}nav .active{color:var(--accent);border-bottom-color:var(--accent)}
.layout{display:grid;grid-template-columns:minmax(220px, .75fr) minmax(0, 2.2fr);gap:18px}.layout.story{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.panel{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:18px;min-width:0}.panel+.panel.spaced{margin-top:14px}h2,h3,p{margin:0 0 12px}h2{font-size:17px}h3{font-size:14px}.muted,#save-state,small{color:var(--muted)}.empty{padding:32px 18px;text-align:center;color:var(--muted)}
label.field{display:grid;gap:7px;margin:0 0 14px;color:var(--muted);font-size:13px}input:not([type=file]),textarea,select{width:100%;min-width:0;background:var(--bg);border:1px solid var(--line);border-radius:7px;color:var(--ink);padding:9px 10px}textarea{resize:vertical;line-height:1.5;min-height:85px}textarea.long{min-height:230px}.small-input{max-width:85px}.field-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.scenes{align-self:start}.row{display:flex;align-items:center;gap:6px;margin-bottom:7px}.row .pick{flex:1;justify-content:flex-start;text-align:left;min-width:0;overflow-wrap:anywhere}.row .active{border-color:var(--accent);color:var(--accent)}.row .move{padding:7px 8px}.shot-list{margin:16px 0;border-top:1px solid var(--line);padding-top:14px}.shot{border-top:1px solid var(--line);padding-top:16px}.shot-main{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px}.visual{width:100%;aspect-ratio:16/9;object-fit:contain;background:#121014;border-radius:8px;display:block}.visual.empty{display:grid;place-items:center}.takes{display:flex;gap:6px;margin:9px 0;flex-wrap:wrap}.take{padding:3px}.take img{width:56px;height:36px;object-fit:cover;border-radius:4px}.take.active{border-color:var(--accent)}audio{width:100%;height:35px;margin:8px 0}.media-buttons{margin:8px 0}.upload{position:absolute;opacity:0;width:1px;height:1px}.button:focus-within{outline:2px solid var(--accent)}.section-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:9px}.section-head h2,.section-head h3{margin:0}.export-preview{max-height:58vh}.reference video{max-height:420px}.reference{margin-top:18px}summary{cursor:pointer;color:var(--muted)}
#status{position:fixed;bottom:17px;right:18px;max-width:min(580px,calc(100vw - 36px));background:#332931;border:1px solid #67505c;color:var(--ink);padding:13px 16px;border-radius:9px;box-shadow:0 8px 30px #0006;z-index:2}#status.error{border-color:#e38c88}
dialog{width:min(520px,calc(100% - 24px));border:1px solid var(--line);border-radius:12px;background:var(--panel);color:var(--ink);padding:21px}dialog::backdrop{background:#09070bd0}
@media(max-width:800px){.layout,.layout.story,.shot-main{grid-template-columns:1fr}.heading{align-items:flex-start}.top{align-items:flex-start}.top-actions{justify-content:flex-end}#save-state{display:none}}
.shot-table-wrap{overflow-x:auto;margin:0 0 12px;border:1px solid var(--line);border-radius:8px}
.shot-table{width:100%;min-width:480px;border-collapse:collapse;text-align:left}
.shot-table th,.shot-table td{padding:9px 10px;vertical-align:top;border-bottom:1px solid var(--line)}
.shot-table thead{background:var(--bg);color:var(--muted);font-size:12px}
.shot-table tbody tr:last-child td{border-bottom:0}
.shot-table tr.selected{background:var(--raised)}
.shot-table td:first-child,.shot-table td:nth-child(4),.shot-table td:nth-child(5){white-space:nowrap;color:var(--muted);font-size:13px}
.shot-name{background:none;border:none;padding:0;text-align:left;justify-content:flex-start;font-weight:700;overflow-wrap:anywhere}
.selected .shot-name{color:var(--accent)}
.shot-summary{display:block;color:var(--muted);font-size:13px;line-height:1.4;overflow-wrap:anywhere;margin-top:4px}
.shot-order{display:flex;gap:4px}
.shot-order button{padding:4px 8px}

.shot-thumb{display:grid;place-items:center;width:60px;height:38px;padding:0;border:0;border-radius:5px;background:var(--bg);overflow:hidden}
.shot-thumb img{display:block;width:100%;height:100%;object-fit:cover}
.empty-thumb{color:var(--muted)}
#preset-editor details{margin:12px 0}
#preset-editor details .option{display:block;margin:8px 0}
#preset-editor details[open] summary{margin-bottom:10px}
.story-library{display:grid;gap:6px;margin-top:10px}
.story-library button{justify-content:flex-start}
dialog>.actions+h3{margin-top:18px}
.connection-results{padding-left:20px;margin:14px 0 8px}
.connection-results li{margin:6px 0}
#pause-automation[hidden]{display:none}
.job-history{list-style:none;margin:0 0 14px;padding:0;max-height:55vh;overflow:auto}
.job-history li{border-bottom:1px solid var(--line);padding:10px 0}
.job-history time{display:block;color:var(--muted);font-size:.85rem}
.job-history p{margin:5px 0 0}
.library-title{font:normal clamp(32px,5vw,54px) Georgia,serif;margin:0}
.library-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,250px),1fr));gap:16px}
.library-card{display:flex;flex-direction:column;align-items:stretch;text-align:left;padding:0;overflow:hidden;background:var(--panel)}
.library-card img{display:block;width:100%;aspect-ratio:16/9;object-fit:cover}
.library-card-body{display:grid;gap:7px;padding:16px}
.library-card-body strong{font-size:18px;overflow-wrap:anywhere}
.library-status{color:var(--accent);font-size:13px}

/* Match system appearance and keep production navigation visible. */
:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", system-ui, sans-serif;
  --bg: #f5f5f7;
  --panel: #fff;
  --raised: #ededf0;
  --line: #dcdce1;
  --ink: #1d1d1f;
  --muted: #626269;
  --accent: #005ebd;
  --accent-ink: #fff;
  --selection: #deebfa;
  --danger: #a1232d;
  --shadow: 0 1px 2px #1717210a, 0 6px 20px #17172108;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1e;
    --panel: #262629;
    --raised: #323236;
    --line: #424247;
    --ink: #f5f5f7;
    --muted: #b1b1ba;
    --accent: #83baff;
    --accent-ink: #10223a;
    --selection: #253c58;
    --danger: #ff9d9d;
    --shadow: 0 1px 2px #0002, 0 6px 20px #0002;
  }
}
body { font-size: 14px; line-height: 1.45; }
.top {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 56px;
  padding: 10px clamp(14px, 3vw, 36px);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  -webkit-backdrop-filter: saturate(150%) blur(20px);
  backdrop-filter: saturate(150%) blur(20px);
}
.brand { display: inline-flex; align-items: center; font-size: 15px; font-weight: 650; letter-spacing: -.015em; }
.mark { width: 28px; height: 28px; font: 650 15px/1 -apple-system, system-ui, sans-serif; }
button,.button { padding: 7px 11px; border-radius: 8px; font-weight: 500; }
button:not(.primary):hover,.button:hover { background: color-mix(in srgb, var(--accent) 8%, var(--raised)); border-color: var(--line); }
.primary { font-weight: 600; }
.primary:hover { filter: brightness(.94); }
.danger { color: var(--danger); }
.studio-shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: calc(100dvh - 56px); }
.sidebar { padding: 20px 12px; background: var(--panel); border-right: 1px solid var(--line); }
.sidebar nav { display: grid; gap: 3px; margin: 12px 0 0; padding-top: 12px; border: 0; border-top: 1px solid var(--line); }
.sidebar nav[hidden] { display: none; }
.sidebar .sidebar-link {
  justify-content: flex-start;
  width: 100%;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
}
.sidebar-link span { width: 17px; text-align: center; color: var(--accent); font-size: 17px; line-height: 1; }
.sidebar .sidebar-link[aria-current] { background: var(--selection); color: var(--accent); font-weight: 650; }
#workspace { width: 100%; padding: clamp(22px, 4vw, 52px) clamp(16px, 4vw, 58px) 64px; }
.heading { margin-bottom: 26px; }
.title, .library-title { font: 680 clamp(29px, 4vw, 44px)/1.12 -apple-system, system-ui, sans-serif; letter-spacing: -.04em; }
.title { flex: 1; }
.heading .actions, .heading > button { flex-shrink: 0; }
.panel { border-radius: 16px; padding: clamp(15px, 2vw, 25px); box-shadow: var(--shadow); }
.layout { grid-template-columns: minmax(175px, .62fr) minmax(0, 2.2fr); }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.018em; }
label.field { color: var(--ink); font-weight: 550; }
input:not([type=file]),textarea,select { background: var(--bg); border-radius: 8px; font-weight: 400; }
.brief-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.brief-panel > .section-head, .brief-panel > button { flex: none; }
.brief-panel > button { align-self: flex-start; }
.brief-panel .field { flex: none; }
.brief-panel textarea { resize: none; overflow-y: auto; }
.layout.story textarea[data-field="story"] {
  min-height: 270px;
  font-size: 14px;
  line-height: 1.65;
}
.layout.story textarea.treatment-writing { border-color: #91bfb9; }
.treatment-footer { display: flex; align-items: end; flex-wrap: wrap; gap: 10px 14px; }
.treatment-runtime { display: grid; gap: 3px; margin-inline-start: auto; text-align: right; }
.treatment-runtime output { color: var(--link); font-weight: 650; font-variant-numeric: tabular-nums; }
.story-sheets { margin-top: 18px; }
.story-sheets .section-head { flex-wrap: wrap; }
.story-sheet-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.story-sheet-groups > section { min-width: 0; }
.story-sheet-groups h3 { margin: 0; font-size: 15px; }
.story-sheet {
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #ffffffb5;
}
.story-sheet summary { padding: 12px 14px; cursor: pointer; overflow-wrap: anywhere; }
.story-sheet summary::marker { color: var(--link); }
.character-reference-thumb {
  display: inline-block;
  margin-inline: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  object-fit: cover;
  vertical-align: middle;
}
.character-reference-thumb + strong { vertical-align: middle; }
.story-sheet[open] .character-reference-thumb { display: none; }
.story-sheet-fields { padding: 0 14px 12px; }
.story-sheet-fields textarea { min-height: 65px; }
.character-reference { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.character-reference-preview {
  display: block;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.character-reference-preview img { display: block; width: 100%; height: auto; border-radius: inherit; }
.character-reference .actions { gap: 6px; }
@media (min-width: 801px) {
  .brief-panel { contain: size; }
}
@media (max-width: 800px) {
  .brief-panel { max-block-size: max(380px, 80svh); }
  .story-sheet-groups { grid-template-columns: 1fr; }
}
input[type=checkbox] { width: auto; accent-color: var(--accent); }
.section-head { margin-bottom: 14px; }
.row .active, .shot-table tr.selected { background: var(--selection); }
.shot-table td,.shot-table th { padding: 10px 12px; }
.shot-name:not(.primary):hover { background: transparent; text-decoration: underline; }
.visual { background: #111113; border-radius: 10px; }
.visual.empty { background: var(--bg); }
.library-grid { grid-template-columns: repeat(auto-fill,minmax(min(100%, 245px), 1fr)); gap: 18px; }
.library-card { border-radius: 15px; box-shadow: var(--shadow); }
.library-card:not(.primary):hover { background: var(--panel); border-color: var(--accent); }
.library-card-body { gap: 5px; padding: 14px 16px 17px; }
.library-card-body strong { font-weight: 650; letter-spacing: -.018em; }
.library-status { margin-top: 3px; }
dialog { border-radius: 17px; box-shadow: 0 20px 70px #0004; }
dialog::backdrop { background: #10101865; }
#status { background: var(--panel); border-color: var(--line); box-shadow: 0 8px 30px #0003; }
#status.error { border-color: var(--danger); }
@media (max-width: 1000px) {
  .studio-shell { grid-template-columns: 160px minmax(0,1fr); }
  .layout:not(.story) { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .top { align-items: center; flex-wrap: wrap; }
  .top-actions { justify-content: flex-start; }
  .studio-shell { display: block; }
  .sidebar { display: flex; align-items: center; gap: 5px; overflow-x: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; margin: 0; padding: 0; border: 0; }
  .sidebar .sidebar-link { width: auto; white-space: nowrap; }
  .heading { align-items: flex-start; flex-wrap: wrap; }
  .heading .actions { flex-shrink: 1; }
}

:root {
  color-scheme: light;
  --bg: #f3f5f6;
  --panel: #ffffffc7;
  --raised: #ffffffa8;
  --line: #d7dce2;
  --ink: #282131;
  --muted: #5b5665;
  --accent: #d9ff46;
  --accent-ink: #202719;
  --selection: #ddedeb;
  --link: #235a56;
  --shadow: 0 12px 42px #2b29490e;
}
body { background: #f3f5f6; color: var(--ink); }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 11% 14%, #cdeeea 0%, transparent 42%),
    radial-gradient(ellipse at 89% 8%, #ded7f7 0%, transparent 48%),
    linear-gradient(145deg,#f2f6f5,#f7f7fa 72%);
}
.top {
  width: fit-content;
  max-width: calc(100% - 28px);
  margin: 16px auto 0;
  top: 12px;
  min-height: 54px;
  padding: 8px 10px 8px 14px;
  border: 1px solid #fff;
  border-radius: 100px;
  background: #ffffffa6;
  box-shadow: 0 10px 28px #2f294013, inset 0 1px 0 #fff;
  gap: clamp(16px,5vw,68px);
}
.top button { border-radius: 999px; }
.brand { gap: 7px; font-size: 19px; line-height: 1; letter-spacing: -.055em; }
.brand .mark {
  width: 14px;
  height: 14px;
  margin: 0;
  flex: 0 0 14px;
  border-radius: 50%;
  background: #e82e49;
  box-shadow: inset 0 0 0 1px #b7193433, 0 0 0 3px #e82e4915;
}
.brand.is-recording .mark {
  animation: recording-dot 1.2s ease-in-out infinite;
  box-shadow: 0 0 0 4px #e82e4925;
}
@keyframes recording-dot { 50% { opacity: .32; } }
@media (prefers-reduced-motion: reduce) {
  .brand.is-recording .mark { animation: none; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.wordmark { display: inline-flex; align-items: baseline; }
.wordmark strong { font-weight: 820; }
.wordmark > span { font-weight: 430; }
.studio-shell { width: min(1510px,100%); margin: 0 auto; }
.library-page .studio-shell { display: block; }
.library-page .sidebar { display: none; }
.sidebar {
  align-self: start;
  position: sticky;
  top: 88px;
  margin: 24px 0 0 16px;
  padding: 10px;
  border: 1px solid #fff;
  border-radius: 18px;
  background: #ffffff9e;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.sidebar .sidebar-link[aria-current],.sidebar-link span { color: var(--link); }
#workspace { max-width: 1440px; }
.library-page #workspace { padding-top: clamp(24px,4vw,50px); }
.library-hero {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr);
  gap: clamp(20px,5vw,64px);
  align-items: center;
  padding: clamp(20px,4vw,50px);
  min-height: 350px;
  border: 1px solid #fff;
  border-radius: 32px;
  background: linear-gradient(125deg,#fff9,#e9ecf694);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.library-hero::before,.library-hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  width: 64%;
  height: 115%;
  border-radius: 50%;
  filter: blur(58px);
  opacity: .65;
  animation: drift 16s ease-in-out infinite alternate;
}
.library-hero::before { top: -42%; right: 4%; background: #a6eae1; }
.library-hero::after { bottom: -64%; left: 17%; background: #c7b3f0; animation-delay: -6s; }
@keyframes drift {
  from { transform: translate3d(-8%,0,0) scale(.9); }
  to { transform: translate3d(15%,11%,0) scale(1.12); }
}
.library-title {
  font-size: clamp(58px,8.5vw,120px);
  line-height: .88;
  letter-spacing: -.078em;
  font-weight: 890;
  margin: 0 0 22px;
}
.library-title span { color: #337d72; }
.hero-copy p { font-size: clamp(15px,1.65vw,20px); color: var(--muted); max-width: 28ch; margin-bottom: 22px; }
.hero-copy button { padding: 10px 15px; border-radius: 999px; }
.hero-secondary { background: #fff9; }
.hero-preview { position: relative; min-width: 0; }
.reel-card {
  position: relative;
  width: 100%;
  display: block;
  padding: 0;
  border: 1px solid #ffffffba;
  border-radius: 25px;
  overflow: hidden;
  isolation: isolate;
  aspect-ratio: 16/10;
  background: #2a2531;
  box-shadow: 0 18px 35px #33264229;
  text-align: left;
}
.reel-card::after {
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  background:linear-gradient(0deg,#1d1526a8,transparent 46%);
}
.reel-image,.reel-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.reel-image { animation: frame-drift 18s ease-in-out infinite alternate; }
.reel-video[hidden],.reel-toggle[hidden] { display: none; }
@keyframes frame-drift { from { transform: scale(1); } to { transform: scale(1.12) translateX(-2%); } }
.reel-label,.reel-arrow,.reel-toggle {
  position: absolute;
  z-index: 1;
  border: 1px solid #ffffff55;
  color: #fff;
  background: #20162775;
  backdrop-filter: blur(15px);
  border-radius: 13px;
}
.reel-label { left: 13px; bottom: 13px; padding: 8px 12px; display: grid; gap: 2px; }
.reel-label strong { font-size: 18px; }
.reel-label span { font-size: 12px; color: #f3ebf6; }
.reel-arrow { right: 13px; bottom: 13px; padding: 7px 11px; font-size: 19px; }
.reel-toggle { top: 13px; right: 13px; font-size: 12px; }
.reel-toggle:not(.primary):hover { background: #2a1c37c9; color: #fff; }
.library-projects { margin-top: 31px; }
.library-projects h2 { font-size: 24px; font-weight: 760; letter-spacing: -.035em; }
.library-card { border: 1px solid #fff; border-radius: 19px; background: #ffffffb5; backdrop-filter: blur(16px); transition: transform .22s,box-shadow .22s; }
.library-card:not(.primary):hover { transform: translateY(-4px); border-color: #91bfb9; background: #fff; }
.library-placeholder { display: grid; place-items: center; aspect-ratio: 16/9; background: linear-gradient(135deg,#d0efe8,#ded2f5); font-size: 33px; color: #427873; }
.library-status { color: var(--link); }
.panel, dialog, #status { backdrop-filter: blur(20px); }
dialog { background: #fdfdfbf5; }
.row .active,.selected .shot-name { color: var(--link); }
button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible { outline-color: var(--link); }
.primary { box-shadow: inset 0 1px 0 #fff9; }
.primary:hover { filter: none; background: #c9f330; }
button[disabled] { animation: none; }
#pause-automation:not([hidden]) { animation: queue-glow 2.5s ease-in-out infinite; }
@keyframes queue-glow { 50% { box-shadow: 0 0 0 4px #95cbb54d; } }
.motion-paused *, .motion-paused *::before, .motion-paused *::after { animation-play-state: paused !important; }
@media (max-width: 780px) {
  .library-hero { grid-template-columns: 1fr; border-radius: 24px; min-height: auto; }
  .library-title { font-size: clamp(52px,11vw,78px); }
  .hero-preview { max-width: 620px; width: 100%; }
  .top { gap: 8px; border-radius: 20px; justify-content: center; }
  .top-actions { justify-content: center; }
}
@media (max-width: 680px) {
  .sidebar { position: static; margin: 14px 12px 0; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation: none !important; transition: none !important; }
}

.shots-view > .section-head h2 {
  font-size: 24px;
  letter-spacing: -.035em;
}
.shot-group + .shot-group { margin-top: 26px; }
.shot-group h3 { display: flex; align-items: baseline; gap: 9px; overflow-wrap: anywhere; }
.shot-group h3 span { color: var(--muted); white-space: nowrap; font-size: 12px; font-weight: 550; }
.shot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 12px;
}
.shot-card {
  display: grid;
  align-content: start;
  justify-content: stretch;
  gap: 0;
  overflow: hidden;
  min-width: 0;
  padding: 0;
  border-color: #fff;
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform .2s ease, border-color .2s ease;
}
.shot-card:not(.primary):hover { transform: translateY(-3px); background: #fff; border-color: #91bfb9; }
.shot-card-frame {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: var(--shot-aspect, 16/9);
  background: linear-gradient(135deg, #e2f3f0, #eae3f5);
  color: var(--muted);
  font-size: 12px;
}
.shot-card-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.shot-card-media {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 4px 9px;
  border: 1px solid #ffffff47;
  border-radius: 999px;
  background: #25202bd6;
  color: #fff;
  font-weight: 550;
  backdrop-filter: blur(12px);
}
.shot-card-text { display: grid; gap: 5px; padding: 11px 13px 13px; overflow-wrap: anywhere; }
.shot-card-meta { color: var(--link); font-size: 12px; }
.shot-navigation { flex-wrap: wrap; }
.shot-context { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); overflow-wrap: anywhere; }
.shot-context span { margin-left: auto; font-size: 12px; }
.shot-detail .shot { border-top: 0; padding-top: 0; }
.shot-detail .section-head { flex-wrap: wrap; }

.shot-editor-heading { flex-wrap: wrap; }
.shot-editor-heading .actions { gap: 6px; }
.shot-preview-column { container-type: inline-size; }
.shot-media-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.shot-media-group {
  position: relative;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff75;
}
.shot-media-group:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 21px;
  right: -11px;
  width: 6px;
  height: 6px;
  border-top: 1px solid var(--link);
  border-right: 1px solid var(--link);
  transform: rotate(45deg);
}
.shot-media-group h3 { display: flex; align-items: center; gap: 7px; margin: 0 0 8px; }
.shot-media-group h3 svg { color: var(--link); }
.shot-media-group .actions { display: grid; gap: 6px; }
.shot-media-group .actions > *, .shot-prompts-heading button { font-size: 13px; }
.shot-media-group .actions > * { min-width: 0; padding-inline: 6px; text-align: center; }
.shot-generate { color: var(--link); border-color: #acd0c9; background: #e2efeb; }
.shot-generate:not(.primary):hover { background: #d4e9e3; border-color: #91bfb9; }
.shot-remove { color: #862d41; border-color: transparent; }
.shot-media-group .takes { margin: 9px 0 0; }
.shot-media-group .take.active { border-color: var(--link); background: var(--selection); }
.shot-media-group audio { display: block; margin: 10px 0 0; }
.shot-stage-note { display: block; margin-top: 8px; }
@container (max-width: 380px) {
  .shot-media-groups { grid-template-columns: minmax(0, 1fr); }
  .shot-media-group .actions { display: flex; }
  .shot-media-group:not(:last-child)::after {
    top: auto;
    right: calc(50% - 3px);
    bottom: -10px;
    transform: rotate(135deg);
  }
}
.shot-prompts-heading { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 14px; }
.shot-editor-footer { margin-top: 14px; padding-top: 8px; border-top: 1px solid var(--line); text-align: right; }

.plan-picker { min-width: 0; margin: 0 0 12px; padding: 0; border: 0; }
.plan-picker legend { padding: 0; margin-bottom: 7px; font-size: 13px; font-weight: 550; }
.plan-options {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #e9efef;
}
.plan-options label { position: relative; min-width: 0; cursor: pointer; }
.plan-options input[type="radio"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.plan-options span {
  display: grid;
  place-items: center;
  min-height: 36px;
  padding: 5px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
}
.plan-options input:checked + span {
  background: #fff;
  color: var(--link);
  box-shadow: 0 1px 5px #253b3a22;
}
.plan-options input:focus-visible + span { outline: 2px solid var(--link); outline-offset: -2px; }

.production-panel { margin-top: 18px; }
.storage-path { overflow-wrap: anywhere; }
.storage-note { margin-top: 10px; }
.production-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.art-direction-panel .section-head { flex-wrap: wrap; }
@media (max-width: 1050px) {
  .production-sections { grid-template-columns: minmax(0, 1fr); }
}
.production-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr));
  gap: 0 12px;
}
div.field { display: grid; min-width: 0; gap: 7px; margin: 0 0 14px; font-size: 13px; font-weight: 550; }
.selector-trigger, label.field select:not([hidden]) {
  position: relative;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #ffffffb5;
  color: var(--ink);
  padding: 9px 32px 9px 12px;
  justify-content: flex-start;
  text-align: left;
}
.selector-trigger:not(.primary):hover, .selector-trigger[aria-expanded="true"] {
  background: #fff;
  border-color: #91bfb9;
}
.selector-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selector-trigger::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 7px;
  height: 7px;
  border: solid var(--link);
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-70%) rotate(45deg);
}
.selector-trigger.selector-unavailable { color: var(--muted); }
.selector-trigger.selector-unavailable > span { white-space: normal; }
.selector-options {
  visibility: hidden;
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #fff;
  border-radius: 13px;
  background: #f6faf9f5;
  color: var(--ink);
  box-shadow: 0 14px 38px #29293b26;
  backdrop-filter: blur(18px);
}
.selector-options.is-positioned { visibility: visible; }
.selector-options button {
  display: flex;
  justify-content: flex-start;
  width: 100%;
  min-height: 36px;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 13px;
}
.selector-options button[aria-selected="true"]:enabled { background: var(--selection); color: var(--link); }
.selector-options button:focus-visible { outline-offset: -2px; }
.selector-options button:disabled { color: #77727f; opacity: 1; }
.selector-hint { color: #9b3147; font-weight: 650; white-space: nowrap; }
.selector-options button:disabled:hover { background: transparent; }

.production-heading, .production-row, .production-total {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(110px, auto);
  align-items: center;
  gap: 12px 20px;
}
.production-heading { padding-bottom: 10px; }
.production-heading h3 { margin: 0; }
.production-heading > span { text-align: right; color: var(--muted); font-size: 12px; }
.production-row, .production-total { border-top: 1px solid var(--line); padding: 11px 0; }
.production-row .field { margin: 0; }
.production-row .selector-field { grid-template-columns: 105px minmax(0,350px); align-items: center; }
.production-price { color: var(--link); text-align: right; font-variant-numeric: tabular-nums; }
.production-total .production-price { font-size: 20px; }
.production-note { display: block; }
@media (max-width: 680px) {
  .production-heading, .production-row, .production-total { grid-template-columns: minmax(0,1fr) minmax(75px,auto); gap: 10px; }
  .production-row .selector-field { grid-template-columns: minmax(0,1fr); }
  .production-row .production-price { align-self: end; padding-bottom: 12px; font-size: 13px; }
}
.scene-timing { color: var(--link); }
.timing-notice { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.timing-notice p { margin: 0; color: var(--muted); }
@media (min-width: 801px) {
  .export-layout.has-export { grid-template-areas: "settings cut"; }
  .has-export .export-cut { grid-area: cut; }
  .has-export .export-settings { grid-area: settings; }
}
.shot-list-actions { margin-top: 12px; }
.shot-list-actions label { display: flex; align-items: center; gap: 8px; }
.shot-list-actions :is(button, input) { min-height: 38px; }
.shot-table-row { cursor: pointer; }
.shot-table-row:hover:not(.selected) { background: var(--bg); }
.shot-list-skeleton span {
  display: block;
  height: 10px;
  border-radius: 4px;
}
.shot-list-skeleton .skeleton-index { width: 14px; height: 14px; margin-top: 6px; }
.shot-list-skeleton .skeleton-still { position: relative; width: 60px; height: 38px; border-radius: 7px; }
.skeleton-still::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid #ffffffb5;
  border-radius: 4px;
}
.shot-list-skeleton .skeleton-title { width: min(110px, 75%); height: 12px; margin-bottom: 8px; }
.shot-list-skeleton .skeleton-script { width: min(240px, 100%); min-width: 90px; height: 7px; }
.shot-list-skeleton .skeleton-script + .skeleton-script { width: min(160px, 60%); min-width: 55px; margin-top: 5px; }
.shot-list-skeleton .skeleton-duration { width: 28px; margin-top: 6px; }
.shot-list-skeleton .skeleton-media { width: 44px; height: 16px; margin-top: 3px; border-radius: 999px; }
@media (max-width: 720px) {
  .shot-table-wrap { overflow: visible; }
  .shot-table, .shot-table tbody { display: block; min-width: 0; }
  .shot-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .shot-table tbody tr {
    display: grid;
    grid-template-columns: 1.25rem 3rem minmax(0, 1fr) auto;
    grid-template-areas: "index still description order" ". length media order";
    align-items: start;
    gap: 6px 8px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
  }
  .shot-table tbody tr:last-child { border-bottom: 0; }
  .shot-table tbody td { min-width: 0; padding: 0; border: 0; }
  .shot-table td:nth-child(1) { grid-area: index; }
  .shot-table td:nth-child(2) { grid-area: still; }
  .shot-table td:nth-child(3) { grid-area: description; }
  .shot-table td:nth-child(4) { grid-area: length; white-space: normal; }
  .shot-table td:nth-child(5) { grid-area: media; white-space: normal; }
  .shot-table td:nth-child(6) { grid-area: order; align-self: center; }
  .shot-table :is(.shot-thumb, .skeleton-still) { width: 100%; height: 33px; }
  .shot-table .shot-order { flex-direction: column; }
  .shot-table .shot-order button { min-width: 32px; min-height: 34px; }
  .shot-table .skeleton-script { min-width: 0; }
  .storyboard-layout .section-head { flex-wrap: wrap; }
}
.skeleton-order { display: flex; gap: 4px; }
.skeleton-order span { width: 22px; height: 17px; }
.scene-skeleton-row, .scene-skeleton-name, .scene-skeleton-script {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.scene-skeleton-row { margin-bottom: 7px; }
.scene-skeleton-name { margin-bottom: 14px; }
.scene-skeleton-script { min-height: 85px; }
.scene-skeleton-row span, .scene-skeleton-detail span {
  display: block;
  width: 70%;
  height: 12px;
  border-radius: 4px;
}
.scene-skeleton-script span + span { margin-top: 9px; }
.scene-skeleton-script span:last-child { width: 42%; }
.skeleton-source { display: none !important; }
.inline-skeleton {
  display: grid;
  align-content: start;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
}
.inline-skeleton > span { display: block; height: 10px; width: 86%; border-radius: 4px; }
.inline-skeleton > span:nth-child(3n) { width: 62%; }
.inline-skeleton > :where(span:first-child) { width: 46%; }
.skeleton-treatment { min-height: 270px; gap: 14px; }
.skeleton-text { min-height: 85px; }
.skeleton-sheet { margin-bottom: 8px; }
.story-sheet-groups > section:has(.skeleton-sheet) > .muted { display: none; }
.skeleton-audio { grid-template-columns: 18px minmax(0,1fr); align-items: center; margin-top: 8px; padding: 8px 12px; }
.skeleton-audio .skeleton-audio-button { width: 18px; height: 18px; border-radius: 50%; }
.skeleton-audio .skeleton-audio-track { width: 100%; height: 6px; }
:is(.skeleton-image, .skeleton-video, .skeleton-reference) {
  position: relative;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 16/9;
}
.skeleton-reference { aspect-ratio: 1; max-height: 360px; margin-bottom: 10px; }
.inline-skeleton .skeleton-surface { position: absolute; inset: 0; width: 100%; height: 100%; }
.shot :is(.visual, .skeleton-image, .skeleton-video) { aspect-ratio: var(--shot-aspect, 16/9); }
.inline-skeleton .skeleton-media-chip {
  position: absolute;
  inset: auto 12px 12px;
  width: 32%;
  height: 10px;
  border: 1px solid #ffffffb5;
  border-radius: 999px;
}
.skeleton-video .skeleton-media-chip { width: auto; }
.skeleton-reference small {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--link);
}
.shot-list > .skeleton-video { margin-bottom: 12px; max-height: 260px; }
#status.generation-active::after {
  content: "";
  position: absolute;
  inset: auto 12px 4px;
  height: 3px;
  border-radius: 3px;
}
:is(.shot-list-skeleton, .scene-skeleton-row, .scene-skeleton-detail, .inline-skeleton) span,
#status.generation-active::after {
  background: linear-gradient(110deg, var(--selection) 15%, #eae4f4 39%, #fff 50%, #def2ec 62%, var(--selection) 85%);
  background-size: 260% 100%;
}
@media (prefers-reduced-motion: no-preference) {
  :is(.shot-list-skeleton, .scene-skeleton-row, .scene-skeleton-detail, .inline-skeleton) span,
  #status.generation-active::after {
    animation: generation-shimmer 1.8s ease-in-out infinite;
  }
  :is(.shot-list-skeleton, .scene-skeleton-row):nth-child(3n + 2) span { animation-delay: -140ms; }
  :is(.shot-list-skeleton, .scene-skeleton-row):nth-child(3n) span { animation-delay: -280ms; }
}
@keyframes generation-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
.library-project-card { display: grid; grid-template-rows: 1fr auto; min-width: 0; }
.library-project-card .library-card { width: 100%; }
.project-actions { display: flex; gap: 5px; flex-wrap: wrap; margin: 9px 0 0; }
.project-actions button { font-size: 12px; }
.project-delete { color: #862d41; margin-left: auto; }
.key-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.key-saved { border-radius: 999px; background: #d8efe3; color: #206345; padding: 2px 8px; font-size: 12px; }

.library-project-card { position: relative; }
.can-reorder .library-card { cursor: grab; user-select: none; }
.is-editing .library-card:hover {
  transform: none;
  border-color: #fff;
  background: #ffffffb5;
}
.project-grip {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  background: #fffffff2;
  color: var(--link);
  cursor: grab;
  touch-action: none;
  font-size: 24px;
}
.is-dragging { border-radius: 19px; outline: 1px dashed #76a29d; background: #cce7e34d; }
.is-dragging > * { opacity: 0; }
.card-drag-preview {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 12;
  pointer-events: none;
  will-change: transform;
}
.card-drag-preview :is(.library-card,.shot-card,.scene-row .pick) {
  background: #fdfefd;
  border-color: #91bfb9;
  box-shadow: 0 18px 38px #29293b32;
  transform: rotate(-2deg) scale(1.025);
}
@media (prefers-reduced-motion: reduce) {
  .card-drag-preview :is(.library-card,.shot-card,.scene-row .pick) { transform: none; }
}

@media (min-width: 1001px) {
  .layout.storyboard-layout { grid-template-columns: clamp(230px,26%,300px) minmax(0,1fr); }
}
.storyboard-layout .scenes { padding: 16px; }
.scene-grid { display: grid; gap: 7px; }
.scene-grid > .scene-row { position: relative; margin: 0; }
.scene-row .pick { min-height: 42px; }
.scene-row:has(.scene-grip) .pick { padding-right: 42px; cursor: grab; user-select: none; }
.scene-grip {
  top: 50%;
  right: 5px;
  width: 33px;
  height: 33px;
  transform: translateY(-50%);
  border-color: transparent;
  background: transparent;
  font-size: 20px;
}
.shot-grid-item { position: relative; min-width: 0; }
.shot-grid-item .shot-card, .card-drag-preview .shot-card { width: 100%; height: 100%; }
.shot-grid-item:has(.shot-grip) .shot-card { cursor: grab; user-select: none; }
.shot-grip { display: grid; place-items: center; width: 34px; height: 34px; }

.automation-plan { display: grid; gap: 14px; }
.automation-header { display: grid; gap: 12px; }
.automation-header h2 { margin: 0 0 7px; }
.automation-header > div > p { margin: 0; }
.automation-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 22px;
  padding: 13px 15px;
  border-radius: 13px;
  background: var(--selection);
}
.automation-status > div:first-child { flex: 1 1 280px; }
.automation-status h3 { margin: 0 0 4px; color: var(--link); }
.automation-status p { margin: 0; }
.automation-status p.danger { margin-top: 6px; }
.automation-status[data-state="failed"] { background: #faeaee; }
.production-updates h3 { margin: 2px 0 3px; font-size: 15px; }
.production-updates ul {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 10px 12px 14px;
  list-style: none;
}
.production-update {
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  align-items: start;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fdfefde6;
  overflow-wrap: anywhere;
}
.production-update p { margin: 3px 0 0; color: var(--muted); line-height: 1.4; }
.production-update img { width: 64px; height: 40px; object-fit: cover; border-radius: 6px; }
.production-check {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--selection);
  color: var(--link);
}
#status.generation-active { background: #fdfefd; border-color: #91bfb9; }
@media (prefers-reduced-motion: no-preference) {
  .generation-arrival, #status.generation-active {
    animation: generation-arrival 350ms cubic-bezier(.2,.75,.25,1) var(--arrival-delay,0ms) backwards;
  }
}
@keyframes generation-arrival {
  0% { opacity: 0; transform: translateY(9px) rotate(-2deg) scale(.99); }
  36% { opacity: 1; transform: translateY(-3px) rotate(-1deg) scale(1.02); box-shadow: 0 18px 38px #29293b32; }
  100% { opacity: 1; transform: none; }
}
.automation-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.automation-card h3 { margin: 0 0 7px; font-size: 16px; }
.automation-card > p { color: var(--muted); line-height: 1.5; }
.automation-card > p:last-child { margin-bottom: 0; }
.automation-option {
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  align-items: start;
  gap: 9px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.automation-option:last-child { padding-bottom: 0; }
.automation-option input { margin: 3px 1px 0; }
.automation-option strong, .automation-option small { display: block; }
.automation-option small { margin-top: 3px; line-height: 1.4; }
.automation-count { max-width: 220px; }
.automation-card .automation-media-note {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 8px;
  padding: 9px 0;
  margin: 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.automation-media-note strong { color: var(--ink); }
.automation-export { grid-column: 1 / -1; }

.connection-dialog { width: min(820px,calc(100% - 24px)); }
.connection-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 15px; }
.connection-header h2 { margin: 0 0 5px; font-size: 21px; }
.connection-header p { margin: 0; }
.connection-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; align-items: start; }
.connection-stage { min-width: 0; padding: 10px 12px 3px; border: 1px solid var(--line); border-radius: 13px; background: #ffffffa8; }
.connection-stage:last-child { grid-column: 1 / -1; }
.connection-stage .connection-stage-heading { margin-bottom: 4px; }
.connection-icon-button {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 9px;
  font-size: 20px;
  line-height: 1;
  color: var(--link);
}
.connection-row { border-top: 1px solid var(--line); }
.connection-row summary { display: flex; align-items: center; gap: 8px; padding: 10px 0; color: var(--ink); }
.connection-row summary::marker { content: ""; }
.connection-row summary::-webkit-details-marker { display: none; }
.connection-row summary::before {
  content: "";
  flex: 0 0 6px;
  height: 6px;
  margin-right: 3px;
  border: solid var(--link);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg);
}
.connection-row[open] summary::before { transform: rotate(45deg); }
.connection-row summary strong { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.connection-body { padding-bottom: 10px; }
.connection-message { font-size: 13px; }
.connection-badge { flex-shrink: 0; padding: 3px 8px; border-radius: 999px; background: #efedf2; color: #554c61; font-size: 11px; }
.connection-badge[data-state="ok"] { background: #d8efe3; color: #206345; }
.connection-badge[data-state="error"], .connection-badge[data-state="missing"] { background: #faeaee; color: #862d41; }
.connection-shared { margin-top: 14px; }
.connection-footer {
  position: sticky;
  bottom: -21px;
  margin-top: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  background: #fdfdfb;
}
.connection-footer [role="status"] { color: var(--muted); }

@media (max-width: 720px) {
  .automation-grid, .connection-grid { grid-template-columns: minmax(0,1fr); }
}
