:root {
  color-scheme: dark;
  --bg: #100d15;
  --surface: #191420;
  --inset: #120e19;
  --border: #3c3048;
  --text: #f5f1ea;
  --muted: #c1b4cc;
  --lime: #d4ff63;
  --lime-ink: #1b210f;
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
h1, h2, p, figure, dl, dd { margin: 0; }
button, input, select { font: inherit; }
a { color: var(--lime); text-underline-offset: 3px; }
button, input[type="range"] { cursor: pointer; }
button:disabled, input:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 4px; }
.shell { width: min(1200px, calc(100% - 64px)); margin-inline: auto; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 3; transform: translateY(-160%); background: var(--inset); padding: 10px 16px; }
.skip-link:focus { transform: none; }

.topbar { border-bottom: 1px solid var(--border); background: #120e19; }
.topbar-inner { min-height: 62px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: .3em; color: var(--text); font-size: 18px; font-weight: 750; letter-spacing: -.045em; text-decoration: none; white-space: nowrap; }
.brand svg { color: var(--lime); margin-right: 7px; }
.brand span { color: var(--muted); font-weight: 500; }
.back, .footer a { color: var(--muted); font-size: 13px; text-decoration: none; white-space: nowrap; }
.back:hover, .footer a:hover { color: var(--lime); }

.intro { display: flex; gap: 22px; justify-content: space-between; align-items: end; padding: 48px 0 29px; }
.intro h1 { margin: 8px 0 9px; font-size: clamp(42px, 6vw, 77px); letter-spacing: -.075em; line-height: .98; }
.intro h1 span { color: var(--lime); }
.intro p { color: var(--muted); font-size: 15px; }
.eyebrow { display: flex; align-items: center; gap: 8px; color: var(--lime) !important; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: uppercase; font-size: 11px !important; line-height: 1.3; letter-spacing: .14em; }
.signal { width: 6px; height: 6px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 10px #d4ff6360; flex: none; }
.intro .privacy { border: 1px solid var(--border); border-radius: 999px; font-size: 12px; line-height: 1.2; padding: 8px 12px; white-space: nowrap; }
.privacy span[aria-hidden] { color: var(--lime); margin-right: 3px; }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 330px); gap: 18px; align-items: start; }
.editor, .sidebar { display: grid; gap: 14px; min-width: 0; }
.sidebar { position: sticky; top: 18px; }
.panel, .estimate, .example { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.panel, .estimate { padding: clamp(16px, 3.1vw, 26px); }
.panel-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.panel-head > div { flex: 1; min-width: 0; }
.panel-head h2, .estimate h2 { font-size: 23px; letter-spacing: -.045em; line-height: 1.15; }
.panel-head p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.step-number { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #2a2233; border: 1px solid #4b3a57; color: var(--lime); font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; flex: none; }
.format { border-radius: 999px; border: 1px solid var(--border); color: var(--muted); padding: 5px 10px; font-size: 11px; white-space: nowrap; }

.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; border: 1px solid #51415d; border-radius: 9px; color: var(--text); background: #251d2f; padding: 8px 14px; font-size: 13px; font-weight: 650; text-decoration: none; transition: background .18s, border-color .18s; }
.button:hover:enabled { background: #352841; border-color: #7b638b; }
.button:disabled { opacity: .5; }
.button-lime { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.button-lime:hover:enabled { background: #e0ff9b; border-color: #e0ff9b; }
.button-text { border-color: transparent; background: transparent; color: var(--muted); }
.source-controls, .trim-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.link-form { margin-top: 16px; }
.link-form > label, .role-fields label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 620; }
.link-row { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 7px; margin-block: 5px 7px; }
.cancel-import { margin-top: 4px; padding-inline: 0; }
.youtube-handoff { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 9px; }
.youtube-handoff p { flex: 1 1 185px; }
input[type="text"] { width: 100%; min-width: 0; min-height: 42px; border: 1px solid var(--border); border-radius: 9px; background: var(--inset); color: var(--text); padding: 8px 11px; font-size: 14px; }
input::placeholder { color: #a799b2; }
.fine, .notice { font-size: 12px; color: var(--muted); }
.notice { margin-top: 12px; overflow-wrap: anywhere; }
.notice.error { color: #ffc3b6; }

.screen { background: #08070b; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.screen video { display: block; width: 100%; height: auto; aspect-ratio: 16/9; max-height: 420px; object-fit: contain; }
.timeline { position: relative; height: 8px; margin-top: 16px; border-radius: 999px; background: #3b2d46; overflow: hidden; }
.timeline span { position: absolute; inset: 0 0 0 0; border-radius: inherit; background: var(--lime); }
.timeline-tip { margin-top: 7px; }
.trim-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-block: 13px 6px; }
.trim-field > span { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 8px; font-size: 12px; color: var(--muted); }
.trim-field output { color: var(--text); font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
.trim-field input { display: block; width: 100%; min-height: 34px; margin: 0; accent-color: var(--lime); }
.trim-actions { align-items: center; }
.trim-actions p { margin-left: auto; font-size: 12px; color: var(--muted); }
.trim-actions output { color: var(--lime); font-weight: 720; font-variant-numeric: tabular-nums; }
.compact-quote { color: var(--lime); font-size: 13px; margin-top: 9px; }

.cast-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
#find-cast[aria-disabled="true"] { opacity: .65; cursor: progress; }
#cast-scan-progress { display: block; width: 100%; height: 8px; margin-top: 6px; accent-color: var(--lime); }
.cast-actions + .notice { margin: 0 0 9px; }
.roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.role { border: 1px solid var(--border); border-radius: 12px; margin: 0; padding: 12px; min-width: 0; }
.role-legend { color: var(--muted); padding: 0 6px; font: 11px ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: uppercase; letter-spacing: .07em; }
.role-label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 620; }
.role-action-label { margin-top: 8px; }
.match-review, .role-incomplete { margin-top: 8px; color: #ffc3b6; }
.role-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-block: 12px; }
.role-person { display: grid; grid-template-rows: auto auto minmax(2.6em, auto) auto; gap: 5px; min-width: 0; align-content: start; }
.role-caption { color: var(--text); font-size: 12px; font-weight: 650; }
.role-person .button { padding-inline: 5px; width: 100%; min-width: 0; }
.keep-help { align-self: center; padding: 4px; }
.portrait { aspect-ratio: 4/3; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--inset); overflow: hidden; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }
.portrait-empty { font-size: 24px; color: #b7a0c9; }
.source-preview[data-demo-slot] { background-image: url("./assets/demo-source.webp"); background-size: 400% auto; background-repeat: no-repeat; }
.source-preview[data-demo-slot="dispatcher"] { background-position: 20% 14%; }
.source-preview[data-demo-slot="courier"] { background-position: 84% 20%; }
.role .button { min-height: 36px; font-size: 12px; }
.reference-filename { overflow-wrap: anywhere; }
.role-options { display: grid; gap: 8px; align-items: start; border-top: 1px solid var(--border); padding-top: 10px; }
.role-label select { width: 100%; min-width: 0; min-height: 40px; border: 1px solid var(--border); border-radius: 8px; background: var(--inset); color: var(--text); padding-inline: 8px; }
.custom-clothing, .accessory-fields { display: grid; gap: 8px; }
.accessory-options { border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13px; }
.accessory-options summary { cursor: pointer; }
.accessory-fields { margin-top: 8px; }
.ref-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.ref-row .reference-preview { display: block; object-fit: cover; border-radius: 5px; }
.ref-row .reference-filename { flex-basis: 100%; }
.role .remove-role { margin-top: 5px; padding-inline: 0; }

.match-dialog { width: min(580px, calc(100% - 24px)); max-height: min(650px, calc(100% - 24px)); overflow: auto; border: 1px solid #665272; border-radius: var(--radius); padding: clamp(13px, 3vw, 20px); color: var(--text); background: var(--surface); }
.match-dialog::backdrop { background: #08070bd9; }
.match-dialog.embedded-match { position: fixed; left: 0; right: 0; bottom: auto; margin: 0 auto; }
.match-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.match-head h2 { font-size: 23px; margin-top: 3px; }
.match-frame { position: relative; width: fit-content; max-width: 100%; overflow: hidden; border-radius: 8px; margin-block: 10px; background: var(--inset); cursor: crosshair; }
.match-frame canvas { display: block; max-width: 100%; height: auto; }
#match-box { position: absolute; border: 2px solid var(--lime); box-shadow: 0 0 0 900px #08070b76; pointer-events: none; }
.match-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-block: 8px; }
.match-controls label { display: grid; align-content: start; gap: 4px; font-size: 11px; color: var(--muted); }
.match-controls input { width: 100%; min-height: 36px; margin: 0; accent-color: var(--lime); }

.estimate { background: linear-gradient(145deg, #221a2c, #17121e 70%); }
.estimate h2 { margin: 7px 0 4px; }
.quote { display: grid; margin: 19px 0 12px; border-block: 1px solid var(--border); }
.quote > div { display: grid; gap: 4px; padding: 10px 0; }
.quote > div + div { border-top: 1px solid var(--border); }
.quote dt, .budget-meta { color: var(--muted); font-size: 13px; }
.quote dd { font-size: clamp(25px, 4vw, 36px); font-weight: 750; line-height: 1.1; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.quote > div:last-child dd { color: var(--lime); }
.estimate details { margin-block: 15px; color: var(--muted); font-size: 12px; }
.estimate summary { color: var(--text); cursor: pointer; }
.estimate details p { margin-top: 8px; }
.save-plan { width: 100%; justify-content: space-between; margin-bottom: 8px; }
.pilot-styling { margin: 9px 0 12px; }
.render-job { margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--border); }
.render-job h3 { margin: 0; font-size: 14px; }
.render-job .notice { margin-top: 4px; }
.render-job .fine { margin-top: 4px; overflow-wrap: anywhere; }
.render-job-actions, .render-confirm-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.render-job-actions .button-text { padding-inline: 0; }
.render-confirm { max-width: 415px; }
.render-confirm p + p { margin-top: 8px; }
.render-confirm-actions { justify-content: flex-end; margin-top: 14px; }
.example { overflow: hidden; }
.example img { display: block; width: 100%; height: auto; aspect-ratio: 16/9; object-fit: cover; background: var(--inset); }
.example figcaption { display: grid; gap: 2px; padding: 10px 13px; font-size: 12px; }
.example figcaption span, .footer { color: var(--muted); }
.footer { display: flex; justify-content: space-between; gap: 10px; margin-block: 35px 0; padding-block: 18px 24px; border-top: 1px solid var(--border); font-size: 13px; }

.walkthrough { min-width: 0; }
.walkthrough .topbar, .walkthrough .intro, .walkthrough .footer, .walkthrough .example { display: none; }
.walkthrough main.shell { width: 100%; }
.walkthrough .sidebar { position: static; }

@media (max-width: 930px) {
  .roles { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .shell { width: min(650px, calc(100% - 32px)); }
  .intro { padding-top: 34px; align-items: flex-start; flex-direction: column; gap: 12px; }
  .editor-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .roles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .shell { width: calc(100% - 24px); }
  .roles { grid-template-columns: 1fr; }
  .source-controls .button { flex: 1 1 auto; }
  .format { display: none; }
  .trim-fields { gap: 9px; }
  .panel-head { gap: 8px; }
  .panel-head .button { padding-inline: 7px; }
}
@media (pointer: coarse) {
  .button, .role .button, .trim-field input, .match-controls input { min-height: 44px; }
  input[type="text"] { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
