/* AutoVidGen Studio.
   The UI borrows the videos' own visual language: cream paper, thick ink
   outlines and hard offset shadows (the on-screen text boxes are #f6f1e2 with a
   5px ink border), with MAGENTA -- the chroma key every cutout is drawn on --
   as the accent. */
:root {
  --paper: #efe8d8;
  --paper-2: #f6f1e2;
  --card: #fbf8ef;
  --ink: #16140f;
  --ink-2: #2a2720;
  --ink-soft: #6b6456;
  --rule: #d9cfb8;
  --key: #d6338f;
  --key-deep: #a8196c;
  --ok: #2f7d4f;
  --bad: #c8321e;
  --warn: #c98a12;
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --radius: 10px;
  --f-display: "Dela Gothic One", "Arial Black", Impact, sans-serif;
  --f-body: "Instrument Sans", "Helvetica Neue", Helvetica, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; display: grid; grid-template-columns: 272px 1fr;
  background: var(--paper); color: var(--ink);
  font: 15px/1.5 var(--f-body);
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---- sidebar ---------------------------------------------------------- */
.side {
  background: var(--ink); color: var(--paper-2); padding: 22px 18px;
  display: flex; flex-direction: column; gap: 14px; height: 100vh; position: sticky; top: 0;
  overflow-y: auto;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 9px; display: grid; place-items: center;
  background: var(--key); color: var(--ink); font-size: 18px; border: 3px solid var(--paper-2);
  box-shadow: 3px 3px 0 var(--paper-2); transform: rotate(-4deg);
}
.brand-name { font-family: var(--f-display); font-size: 21px; letter-spacing: .5px; line-height: 1; }
.brand-sub { font-family: var(--f-mono); font-size: 11px; color: var(--key); text-transform: uppercase; letter-spacing: 3px; }
.side-label { font-family: var(--f-mono); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: #8d8574; margin-top: 12px; }
.plist { display: flex; flex-direction: column; gap: 6px; }
.pitem {
  text-align: left; background: transparent; border: 2px solid transparent; border-radius: 8px;
  padding: 9px 10px; cursor: pointer; color: var(--paper-2);
}
.pitem:hover { border-color: #3d3a31; }
.pitem.active { border-color: var(--paper-2); background: #221f18; }
.pitem-title { font-weight: 600; font-size: 14px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdots { display: flex; gap: 4px; margin-top: 6px; }
.pdot { width: 100%; height: 5px; border-radius: 3px; background: #3d3a31; }
.pdot.done { background: var(--paper-2); }
.pdot.running { background: var(--key); animation: pulse 1s ease-in-out infinite; }
.pdot.failed { background: var(--bad); }

/* ---- buttons ------------------------------------------------------------ */
.btn {
  border: 2.5px solid var(--ink); background: var(--card); border-radius: 8px;
  padding: 9px 16px; font-weight: 700; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .08s ease, box-shadow .08s ease, background .15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-key { background: var(--key); color: #fff; }
.btn-key:hover { background: var(--key-deep); }
.btn-stop { background: var(--bad); color: #fff; }
.btn-ghost-danger { background: transparent; color: var(--bad); border-color: var(--bad); box-shadow: 2px 2px 0 var(--bad); }
.btn-ghost-danger:hover { background: var(--bad); color: #fff; box-shadow: 3px 3px 0 var(--ink); }
.btn-block { width: 100%; }
.side .btn { border-color: var(--paper-2); box-shadow: 3px 3px 0 var(--paper-2); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-width: 2px; }
.icon { border: 0; background: transparent; cursor: pointer; font-size: 16px; color: inherit; }

/* ---- main --------------------------------------------------------------- */
.main { padding: 34px 44px 80px; min-width: 0; }
.display { font-family: var(--f-display); font-weight: 400; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.02; margin: 4px 0 8px; letter-spacing: .3px; }
.display-sm { font-family: var(--f-display); font-weight: 400; font-size: 24px; margin: 0; }
.eyebrow { font-family: var(--f-mono); font-size: 12px; color: var(--key-deep); letter-spacing: 2px; text-transform: uppercase; }
.muted, .hint { color: var(--ink-soft); }
.empty { max-width: 640px; margin: 12vh auto 0; }
.empty .display { font-size: clamp(40px, 5vw, 68px); }
.empty p { font-size: 18px; color: var(--ink-2); max-width: 520px; }

.phead { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.pmeta { font-family: var(--f-mono); font-size: 13px; color: var(--ink-soft); }
.pactions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- pipeline filmstrip ---------------------------------------------------- */
.strip {
  margin: 26px 0 14px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--ink); border-radius: var(--radius); padding: 16px 12px; gap: 8px;
  position: relative; box-shadow: var(--shadow);
}
.strip::before, .strip::after {        /* sprocket holes */
  content: ""; position: absolute; left: 12px; right: 12px; height: 5px;
  background: repeating-linear-gradient(90deg, var(--paper) 0 9px, transparent 9px 20px);
  opacity: .5; border-radius: 2px;
}
.strip::before { top: 5px; } .strip::after { bottom: 5px; }
.frame {
  background: #26231c; color: var(--paper-2); border: 2px solid #3d3a31; border-radius: 6px;
  padding: 10px 10px 9px; cursor: pointer; text-align: left; min-height: 74px;
  display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.frame:hover { border-color: var(--paper-2); }
.frame .n { font-family: var(--f-mono); font-size: 11px; color: #8d8574; }
.frame .t { font-weight: 700; font-size: 13.5px; line-height: 1.2; }
.frame .s { font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #8d8574; }
.frame.done { background: var(--paper-2); color: var(--ink); border-color: var(--paper-2); }
.frame.done .s { color: var(--ok); }
.frame.done .n { color: var(--ink-soft); }
.frame.failed { border-color: var(--bad); }
.frame.failed .s { color: #ff7a63; }
.frame.running { border-color: var(--key); }
.frame.running::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px;
  background: repeating-linear-gradient(-45deg, var(--key) 0 8px, #ff8fca 8px 16px);
  background-size: 22px 22px; animation: march .6s linear infinite;
}
.frame.running .s { color: #ff8fca; }
.frame .bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(214, 51, 143, .22);
              transition: width .6s ease; pointer-events: none; }
.frame > span:not(.bar) { position: relative; }

.alert {
  background: #fde8e3; border: 2.5px solid var(--bad); border-radius: 8px; padding: 10px 14px;
  font-weight: 500; box-shadow: var(--shadow-sm); margin-bottom: 14px;
}
.alert b { color: var(--bad); }

.drawer { background: var(--ink); color: #e8e1cf; border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow); overflow: hidden; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #3d3a31; font-family: var(--f-mono); font-size: 13px; }
.drawer-head span { flex: 1; }
.drawer-head .btn { background: var(--paper-2); color: var(--ink); }
.drawer pre { margin: 0; padding: 14px; max-height: 340px; overflow: auto; font: 12.5px/1.55 var(--f-mono); white-space: pre-wrap; word-break: break-word; }

/* ---- screen --------------------------------------------------------------- */
.screen { margin: 6px 0 30px; }
.screen-frame { background: var(--ink); padding: 12px; border-radius: 14px; box-shadow: 6px 6px 0 var(--key); max-width: 960px; }
.screen video { width: 100%; display: block; border-radius: 6px; background: #000; aspect-ratio: 16 / 9; }

/* ---- storyboard kanban -------------------------------------------------------- */
.board-head { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; margin: 10px 0 14px; }
.board-head .hint { margin: 0; font-size: 14px; }
.board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 16px; overflow-x: auto; padding-bottom: 10px; }
.col {
  background: rgba(22, 20, 15, .045); border: 2.5px dashed var(--rule); border-radius: 12px;
  padding: 12px; min-height: 220px; transition: background .15s, border-color .15s;
}
.col.over { background: rgba(214, 51, 143, .09); border-color: var(--key); }
.col.nodrop.over { background: rgba(200, 50, 30, .06); border-color: var(--bad); }
.col-head { display: flex; justify-content: space-between; align-items: center; margin: 2px 4px 12px; }
.col-title { font-family: var(--f-display); font-size: 16px; letter-spacing: .4px; }
.col-count { font-family: var(--f-mono); font-size: 12px; background: var(--ink); color: var(--paper-2); border-radius: 20px; padding: 1px 9px; }
.col[data-col="approved"] .col-title { color: var(--ok); }
.col[data-col="redo"] .col-title { color: var(--bad); }
.col[data-col="needs_assets"] .col-title { color: var(--ink-soft); }
.col-empty { font-size: 13px; color: var(--ink-soft); text-align: center; padding: 26px 8px; }

.card {
  background: var(--card); border: 2.5px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; cursor: grab;
  transform: rotate(var(--tilt, 0deg)); transition: transform .15s ease, box-shadow .15s ease;
  animation: dealIn .45s cubic-bezier(.2, .8, .3, 1.2) both; animation-delay: var(--delay, 0s);
}
.card:hover { transform: rotate(0deg) translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.card.dragging { opacity: .45; }
.card[data-status="approved"] { box-shadow: 4px 4px 0 var(--ok); }
.card[data-status="redo"] { box-shadow: 4px 4px 0 var(--bad); }

.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--paper-2) center / cover no-repeat; border-bottom: 2.5px solid var(--ink); overflow: hidden; }
.thumb.missing { background: repeating-linear-gradient(45deg, #e6dcc4 0 10px, #efe6d0 10px 20px); }
.thumb .actor { position: absolute; transform: translateX(-50%); max-width: none; filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff) drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.thumb .actor.flip { transform: translateX(-50%) scaleX(-1); }
.thumb .ghost {
  position: absolute; transform: translateX(-50%); border: 2px dashed var(--ink-soft);
  border-radius: 6px; display: grid; place-items: center; font: 600 10px var(--f-mono);
  color: var(--ink-soft); background: rgba(246,241,226,.7); padding: 2px;
}
.thumb-cap {
  position: absolute; left: 7px; top: 7px; max-width: 58%; background: #f6f1e2; border: 2px solid var(--ink);
  border-radius: 4px; padding: 2px 6px; font: 400 10px/1.15 var(--f-display); white-space: pre-line;
  box-shadow: 1px 2px 0 rgba(0,0,0,.4); z-index: 2;
}
.thumb-cap:empty { display: none; }
.card-body { padding: 10px 12px 12px; }
.card-top { display: flex; gap: 8px; align-items: center; font-family: var(--f-mono); font-size: 11.5px; }
.sid { font-weight: 600; }
.kind { text-transform: uppercase; letter-spacing: 1px; background: var(--ink); color: var(--paper-2); border-radius: 4px; padding: 0 6px; }
.tc { margin-left: auto; color: var(--ink-soft); }
.line { margin: 8px 0; font-size: 13.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.phrases { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }
.phrase { display: flex; gap: 6px; align-items: flex-start; }
.phrase label { font: 600 10.5px var(--f-mono); color: var(--ink-soft); padding-top: 6px; min-width: 22px; }
.phrase textarea {
  flex: 1; resize: none; font: 400 12.5px/1.25 var(--f-display); letter-spacing: .3px;
  border: 2px solid var(--rule); border-radius: 6px; padding: 4px 7px; background: var(--paper-2); color: var(--ink);
  min-height: 30px; field-sizing: content;
}
.phrase textarea:focus { outline: none; border-color: var(--key); background: #fff; }
.phrase textarea.saved { border-color: var(--ok); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font: 500 11px var(--f-mono); border: 1.5px solid var(--ink); border-radius: 20px; padding: 0 7px; background: #fff; }
.chip.missing { border-style: dashed; color: var(--ink-soft); background: transparent; }
.chip.generated { border-color: var(--key); color: var(--key-deep); background: #fbe3f0; }
.chip.plate { background: var(--ink); color: var(--paper-2); }
.card-actions { display: flex; gap: 6px; margin-top: 10px; }
.card[data-status="approved"] .act-approve,
.card[data-status="redo"] .act-redo { background: var(--ink); color: var(--paper-2); }

/* ---- script ---------------------------------------------------------------- */
.script { margin-top: 30px; background: var(--card); border: 2.5px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 12px 18px; }
.script summary { font-family: var(--f-display); cursor: pointer; font-size: 17px; }
.script ol { font-size: 14px; color: var(--ink-2); padding-left: 34px; }
.script li::marker { font-family: var(--f-mono); font-size: 11px; color: var(--ink-soft); }

/* ---- modal --------------------------------------------------------------- */
.modal {
  border: 3px solid var(--ink); border-radius: 14px; padding: 26px 28px; width: min(720px, 94vw);
  background: var(--paper-2); box-shadow: 8px 8px 0 var(--key); color: var(--ink);
}
.modal::backdrop { background: rgba(22, 20, 15, .55); backdrop-filter: blur(2px); }
.field { display: flex; flex-direction: column; gap: 6px; margin: 16px 0 0; border: 0; padding: 0; }
.field > span, .field legend { font-weight: 700; font-size: 13.5px; display: flex; justify-content: space-between; padding: 0; }
.field em { font: 400 12px var(--f-mono); color: var(--ink-soft); font-style: normal; }
.field input, .field textarea, .field select {
  font: inherit; border: 2.5px solid var(--ink); border-radius: 8px; padding: 9px 11px; background: #fff; color: var(--ink);
}
.field textarea {
  font-size: 14.5px; line-height: 1.55; resize: vertical;
  background: #fff repeating-linear-gradient(transparent 0 21.5px, #efe6d0 21.5px 22.5px);
  background-attachment: local;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 3px solid var(--key); outline-offset: 1px; }
.voice-row { display: flex; gap: 18px; margin-bottom: 4px; }
.radio { display: flex; gap: 6px; align-items: center; font-size: 14px; cursor: pointer; }
.radio input { accent-color: var(--key); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---- motion -------------------------------------------------------------- */
@keyframes march { to { background-position: 22px 0; } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes dealIn { from { opacity: 0; transform: translateY(14px) rotate(calc(var(--tilt, 0deg) * 4)); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 900px) {
  body { grid-template-columns: 1fr; }
  .side { height: auto; position: static; }
  .main { padding: 24px 18px 60px; }
  .strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.session-panel { margin-top: auto; padding-top: 24px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.session-name { flex: 1; font-size: 13px; overflow-wrap: anywhere; }
.session-panel p { width: 100%; color: #ffb7ac; font-size: 12px; }
:focus-visible { outline: 3px solid var(--key); outline-offset: 4px; }

/* Flow account management */
.accounts-open { margin-top: 24px; background: transparent; color: var(--paper-2); }
.accounts-modal { width: min(780px, 94vw); max-height: 90svh; overflow-y: auto; }
.accounts-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.accounts-heading .icon { padding: 10px; }
.account-list { display: flex; flex-direction: column; gap: 12px; margin: 22px 0; }
.account-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; background: var(--card); border: 2px solid var(--ink); border-radius: 9px; padding: 14px; }
.account-row.selected { border-color: var(--key-deep); box-shadow: 2px 2px 0 var(--key-deep); }
.account-info { min-width: 0; }
.account-name { font-weight: 700; overflow-wrap: anywhere; }
.account-meta { display: block; color: var(--ink-soft); font-size: 12px; margin-top: 5px; }
.account-badge { font: 10px var(--f-mono); color: var(--key-deep); display: block; margin-top: 5px; }
.account-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }
.account-import { border-top: 2px dashed var(--rule); margin-top: 26px; padding-top: 23px; }
.account-import h3 { font-size: 21px; }
.account-import > p { font-size: 13px; }
#accountFields { border: 0; padding: 0; margin: 0; min-width: 0; }
.cookie-field > label { font-weight: 700; display: flex; justify-content: space-between; font-size: 13.5px; }
.cookie-field textarea { font: 12px/1.5 var(--f-mono); background: #fff; max-height: 230px; min-width: 0; }
.cookie-field input[type=file] { font-size: 12px; width: 100%; padding: 8px; border: 1px dashed var(--ink-soft); background: transparent; }
.required-tag { color: var(--key-deep); font-size: 11px; }
.account-cookie-note { color: var(--ink-soft); font-size: 12px; margin-top: 20px; }
.accounts-error, .accounts-message { border: 2px solid var(--bad); border-radius: 8px; padding: 10px 13px; background: #fde8e3; color: #8e271a; font-size: 13px; overflow-wrap: anywhere; }
.accounts-message { border-color: var(--ok); color: #235c3b; background: #eaf4e6; }
.account-import input:read-only { background: var(--paper); color: var(--ink-soft); }
@media (max-width: 600px) {
  .accounts-modal { padding: 22px 18px; }
  .account-row { align-items: stretch; flex-direction: column; }
  .account-actions { justify-content: flex-start; }
}

.account-row { flex-wrap: wrap; }
.account-info { flex: 1 1 180px; }
.account-actions { flex: 0 1 auto; }
@media (max-width: 600px) { .account-info { flex-basis: auto; } }

.director-choice { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-top: 22px; }
.director-choice label { font-size: 13px; font-weight: 700; }
.director-choice select { font: inherit; border: 2px solid var(--ink); border-radius: 7px; padding: 7px 30px 7px 10px; background: var(--card); color: var(--ink); }
.director-choice select:disabled { opacity: .7; }
.director-choice small { font-size: 12px; }
