:root {
  --bg: #0a0a0b;
  --panel: #141416;
  --panel-2: #1b1b1e;
  --line: #2a2a2f;
  --ink: #f5f5f4;
  --muted: #9a9aa2;
  --yellow: #ffd400;
  --yellow-dim: #d9b400;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(255, 212, 0, .10), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 11, .8);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  height: 30px;
  padding: 5px 9px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 0 18px rgba(255, 212, 0, .18);
}

.tagline {
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: 11px;
  color: var(--muted);
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.on { color: var(--yellow); border-color: rgba(255, 212, 0, .4); background: rgba(255, 212, 0, .08); }

main { max-width: 1180px; margin: 0 auto; padding: 40px 24px 72px; }
main:has(#step-clips:not([hidden])) { max-width: 1560px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px;
}
.panel.wide { padding: 24px; }

h1 { font-size: 40px; line-height: 1.1; font-weight: 900; margin: 0 0 10px; letter-spacing: -.02em; }
.hl { color: var(--yellow); }
.sub { color: var(--muted); margin: 0 0 26px; font-size: 15px; }
h2 { font-size: 20px; margin: 0 0 6px; font-weight: 700; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 26px 0 12px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }

input[type=url], textarea {
  flex: 1;
  min-width: 260px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
}
input[type=url]:focus, textarea:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 212, 0, .12);
}
textarea { width: 100%; resize: vertical; margin-top: 10px; font-size: 13px; line-height: 1.6; }

.btn {
  background: var(--yellow);
  color: #0a0a0b;
  border: none;
  border-radius: 12px;
  padding: 14px 26px;
  font-weight: 800;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.btn:hover { background: #ffe14d; transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: progress; transform: none; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: var(--muted); background: transparent; }
.btn.small { padding: 10px 18px; font-size: 13px; width: 100%; margin-top: 16px; }

.error { color: #ff6b6b; font-size: 14px; margin: 14px 0 0; }

.videohead { display: flex; gap: 18px; align-items: center; }
.videohead img { width: 168px; aspect-ratio: 16/9; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.meta { color: var(--muted); font-size: 13px; margin: 0; }

.counts { display: flex; gap: 10px; flex-wrap: wrap; }
.count {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
}
.count:hover { border-color: var(--muted); }
.count.active { background: var(--yellow); color: #0a0a0b; border-color: var(--yellow); }

.advanced { margin: 24px 0; border-top: 1px solid var(--line); padding-top: 18px; }
.advanced summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
.advanced summary:hover { color: var(--yellow); }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 12px 0 0; }
.hint code { background: var(--panel-2); padding: 2px 6px; border-radius: 5px; color: var(--yellow-dim); }

/* ---- Results grid ---- */

.results-head { display: flex; align-items: center; gap: 16px; padding: 6px 6px 18px; }
.results-head h2 { font-size: 22px; font-weight: 600; margin: 0; }
.sortbox { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.sortbox select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  padding: 8px 12px;
  font: 500 13px/1 Inter, sans-serif;
  cursor: pointer;
}

.bulkbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.bulkhint { color: var(--muted); font-size: 14px; margin-right: auto; }
.bulkbtn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  padding: 9px 15px;
  font: 600 13px/1 Inter, sans-serif;
  cursor: pointer;
}
.bulkbtn:not(:disabled):hover { color: var(--ink); border-color: var(--muted); }
.bulkbtn:disabled { opacity: .45; cursor: not-allowed; }
.bulkbtn.accent:not(:disabled) { color: var(--yellow); border-color: rgba(255, 212, 0, .45); }

.tabs { display: flex; align-items: center; gap: 8px; padding: 20px 4px 14px; border-bottom: 1px solid var(--line); }
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 10px 14px;
  font: 600 14px/1 Inter, sans-serif;
  cursor: pointer;
}
.tab.active { color: var(--ink); border-bottom-color: var(--yellow); }
.tab:hover { color: var(--ink); }
.tab.right { margin-left: auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  padding: 22px 2px 4px;
}

.card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card.picked { border-color: var(--yellow); }

.card header { display: flex; align-items: center; gap: 10px; padding: 13px 14px; }
.card header input { accent-color: var(--yellow); width: 15px; height: 15px; flex: none; cursor: pointer; }
.cardtitle.editing {
  outline: none;
  border-bottom: 1px solid var(--yellow);
  white-space: normal;
  cursor: text;
}
.cardtitle {
  font: 600 14px/1.3 Inter, sans-serif;
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media { position: relative; aspect-ratio: 16/9; background: #000; }
.media img { object-fit: cover; display: block; }
/* One frame cropped out of the video's scrubber sprite sheet. */
.media .frame, .media > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: cover;
  z-index: 1;
}
.media .brand {
  position: absolute;
  z-index: 2;
  top: 9px;
  left: 9px;
  font: 800 8px/1.15 Inter, sans-serif;
  letter-spacing: .04em;
  color: #0a0a0b;
  background: var(--yellow);
  border-radius: 4px;
  padding: 4px 5px;
  text-align: center;
}
.media .range {
  position: absolute;
  z-index: 2;
  top: 9px;
  right: 9px;
  font: 600 12px/1 Inter, sans-serif;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: rgba(0, 0, 0, .65);
  border-radius: 6px;
  padding: 5px 8px;
}
.media .play {
  position: absolute;
  z-index: 2;
  inset: 0;
  margin: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, .82);
  color: #0a0a0b;
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .12s ease;
}
.media .play:hover { transform: scale(1.08); background: #fff; }
.media .slot, .media .slot > * { width: 100%; height: 100%; display: block; }
.media iframe { width: 100%; height: 100%; display: block; border: 0; }

.actions { display: flex; align-items: center; gap: 4px; padding: 10px 12px; }
.score { font: 700 13px/1 Inter, sans-serif; color: var(--yellow); margin-right: auto; }
.score small { color: var(--muted); font-weight: 500; }
.icon {
  background: transparent;
  border: none;
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon:hover { color: var(--yellow); background: rgba(255, 212, 0, .1); }

.desc {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
  margin: 0;
  padding: 0 14px 15px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.srcpill {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  margin-left: 6px;
}

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--yellow);
  color: #0a0a0b;
  font: 700 13px/1 Inter, sans-serif;
  padding: 12px 22px;
  border-radius: 999px;
  z-index: 50;
}

@media (max-width: 900px) {
  h1 { font-size: 30px; }
  .grid { grid-template-columns: 1fr; }
  .bulkhint { width: 100%; margin-bottom: 4px; }
  .videohead { flex-direction: column; align-items: flex-start; }
}

.playoverlay {
  position: absolute;
  inset: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
  padding: 14px 28px;
  border: none;
  border-radius: 999px;
  background: var(--yellow);
  color: #0a0a0b;
  font: 800 15px/1 Inter, sans-serif;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}

.trimbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 12px 12px;
}
.trimbar label { color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 5px; }
.trimbar input {
  width: 64px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  padding: 6px 8px;
  font: 500 12px/1 Inter, sans-serif;
}
.trimbar .btn.small { width: auto; margin: 0; padding: 7px 14px; font-size: 12px; }

.countcustom {
  width: 96px;
  height: 58px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  padding: 0 14px;
  font: 800 16px/1 Inter, sans-serif;
  text-align: center;
}
.countcustom:focus { outline: none; border-color: var(--yellow); }
.countcustom::placeholder { font-weight: 500; font-size: 12px; color: var(--muted); }

/* Per-clip transport. Times and seeking are scoped to the clip, so the rest
   of the source video is never exposed. */
.clipbar { display: flex; align-items: center; gap: 9px; padding: 10px 12px 2px; }
.clipbar .toggle, .clipbar .sound { flex: none; }
.clipbar .toggle { color: var(--yellow); }
.clipbar .sound.on { color: var(--yellow); }
.cliptrack {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  overflow: hidden;
  touch-action: none;
}
.clipfill { height: 100%; width: 0; background: var(--yellow); border-radius: 999px; }
.cliptime {
  flex: none;
  font: 600 11px/1 Inter, sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* Clicks reach the embed so playback starts from a gesture inside the frame,
   which is what browsers require. controls: 0 keeps the scrubber hidden, so
   there is still no way to reach the rest of the video. */
.media iframe { border: 0; }

/* While a clip is starting up, the still frame stays visible but lets clicks
   through to the embed underneath. */
.media.starting .frame,
.media.starting .thumb,
.media.starting .play { pointer-events: none; }

/* ---- Projects & data page ---- */

.topnav { display: flex; gap: 4px; margin-left: 18px; }
.navlink {
  background: transparent;
  border: none;
  color: var(--muted);
  font: 600 13px/1 Inter, sans-serif;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.navlink:hover { color: var(--ink); }
.navlink.active { color: var(--yellow); background: rgba(255, 212, 0, .1); }

.crumb {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
}
.crumb strong { color: var(--yellow); }

input[type=text] {
  flex: 1;
  min-width: 260px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
}
input[type=text]:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 212, 0, .12);
}

.namestate { font-size: 13px; margin: 12px 0 0; color: var(--muted); min-height: 18px; }
.namestate.free { color: #4ade80; }
.namestate.taken { color: #ff6b6b; }

.recent { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  padding: 12px 16px;
  font: 600 14px/1.3 Inter, sans-serif;
  cursor: pointer;
  text-align: left;
}
.chip:hover { border-color: var(--yellow); }
.chip small { display: block; color: var(--muted); font-weight: 500; margin-top: 4px; font-size: 11px; }

.projrow {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  margin-bottom: 10px;
  overflow: hidden;
}
.projrow > summary {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 18px;
  cursor: pointer;
  list-style: none;
}
.projrow > summary::-webkit-details-marker { display: none; }
.projrow[open] > summary { border-bottom: 1px solid var(--line); }
.projname { font-weight: 700; font-size: 15px; }
.projmeta { color: var(--muted); font-size: 12.5px; }
.projdate { margin-left: auto; color: var(--muted); font-size: 12px; }
.icon.del:hover { color: #ff6b6b; background: rgba(255, 107, 107, .12); }
.icon.del[data-armed] { color: #ff6b6b; width: auto; padding: 0 8px; font-size: 11px; font-weight: 700; }

.projbody { padding: 6px 18px 18px; }
.runblock { margin-top: 16px; }
.runblock h4 { font-size: 14px; margin: 0 0 10px; font-weight: 600; }
.runblock h4 small { color: var(--muted); font-weight: 500; font-size: 11px; }

.cliptable { width: 100%; border-collapse: collapse; font-size: 13px; }
.cliptable th {
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 6px 10px 6px 0;
  font-weight: 700;
}
.cliptable td { padding: 8px 10px 8px 0; border-top: 1px solid var(--line); vertical-align: top; }
.cliptable .mono { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.cliptable a { color: var(--yellow); text-decoration: none; }
.cliptable a:hover { text-decoration: underline; }

/* ---- Cast & hooks ---- */

.caststrip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 18px 2px 0; }
.castlabel {
  font: 700 10px/1 Inter, sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}
.castchip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font: 600 12px/1 Inter, sans-serif;
  cursor: default;
}
.castchip small { color: var(--muted); font-weight: 500; margin-left: 6px; }

.media .speaker {
  position: absolute;
  left: 9px;
  bottom: 9px;
  z-index: 2;
  font: 700 11px/1 Inter, sans-serif;
  color: #0a0a0b;
  background: var(--yellow);
  border-radius: 6px;
  padding: 5px 8px;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hook {
  margin: 0;
  padding: 12px 14px 0;
  font: 500 13px/1.5 Inter, sans-serif;
  color: var(--ink);
  border-left: 2px solid var(--yellow);
  margin-left: 14px;
  padding-left: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.desc { padding-top: 8px; }

/* Saved runs open into the same card grid as a fresh generation. */
.runcard {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}
.runcard:hover { border-color: var(--yellow); }
.runcard img {
  width: 120px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 8px;
  flex: none;
  background: #000;
}
.runinfo { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.runinfo strong {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.runinfo small { color: var(--muted); font-size: 11.5px; }
.runopen { margin-left: auto; color: var(--yellow); font-size: 12px; font-weight: 700; white-space: nowrap; }

.tab:disabled { opacity: .7; cursor: progress; }

/* A tab with no run yet says so, rather than looking inert. */
.runhint {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #0a0a0b;
  background: var(--yellow);
  border-radius: 999px;
  padding: 3px 7px;
  margin-left: 6px;
  vertical-align: middle;
}

.modetag {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 8px;
  margin-right: 8px;
  vertical-align: middle;
}
.modetag.viral { color: var(--yellow); border: 1px solid rgba(255, 212, 0, .45); }
.modetag.roster { color: #7dd3fc; border: 1px solid rgba(125, 211, 252, .45); }

/* ---- Overlays: fullscreen clip viewer and the re-run dialog ---- */

body.locked { overflow: hidden; }

.overlay[hidden] { display: none; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .78);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 28px;
}

.lightbox {
  width: min(1100px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
}
.lightbox header { display: flex; align-items: center; gap: 12px; padding: 2px 2px 14px; }
.lightbox h3 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; min-width: 0; }
.lbspeaker {
  font: 700 11px/1 Inter, sans-serif;
  color: #0a0a0b;
  background: var(--yellow);
  border-radius: 6px;
  padding: 6px 9px;
  flex: none;
}
.lbrange { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; flex: none; }
.lbclose {
  flex: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
}
.lbclose:hover { color: #ff6b6b; border-color: #ff6b6b; }

.lbstage { aspect-ratio: 16/9; background: #000; border-radius: 12px; overflow: hidden; }
.lbstage > *, .lbstage iframe { width: 100%; height: 100%; display: block; border: 0; }
.lbbar .clipbar { padding: 14px 2px 4px; }
.lbhook {
  margin: 10px 2px 0;
  padding-left: 12px;
  border-left: 2px solid var(--yellow);
  font: 500 14px/1.6 Inter, sans-serif;
}

.dialog {
  position: relative;
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
}
.dialog .lbclose { position: absolute; top: 16px; right: 16px; }
.dialog h3 { margin: 0 0 8px; font-size: 19px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--ink); }
.dialoghint { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin: 0 0 18px; }
.dialog textarea { width: 100%; margin-bottom: 16px; }

/* The paste box promotes itself when captions cannot be fetched. */
.advanced.needed {
  border: 1px solid rgba(255, 212, 0, .45);
  border-radius: 12px;
  padding: 16px 18px;
  background: rgba(255, 212, 0, .05);
}
.advanced.needed summary { color: var(--yellow); }

.warn {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 12px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--yellow);
}

.linkbtn {
  background: none;
  border: none;
  color: var(--yellow);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

/* Several notices can apply to one run (an ignored paste, a sampled
   transcript, a weaker signal), so they stack instead of overwriting. */
#genError2 .note {
  display: block;
}

#genError2 .note + .note {
  margin-top: 6px;
}

.badge.warn {
  margin-left: 8px;
  background: #4a1d1d;
  color: #ffb4b4;
  border-color: #6b2a2a;
}
