/* The edit desk. A dark room where the video and the words are the bright things.
   Phone-first, right-to-left. Colours, sizes and radii come only from the tokens
   below; docs/DESIGN.md explains them. */

/* the interface typeface: IBM Plex Sans Hebrew (Hebrew + Latin), four weights */
@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url("/static/fonts/plex-hebrew-400.woff2") format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url("/static/fonts/plex-latin-400.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Plex"; font-weight: 500; font-display: swap; src: url("/static/fonts/plex-hebrew-500.woff2") format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Plex"; font-weight: 500; font-display: swap; src: url("/static/fonts/plex-latin-500.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url("/static/fonts/plex-hebrew-600.woff2") format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url("/static/fonts/plex-latin-600.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
@font-face { font-family: "Plex"; font-weight: 700; font-display: swap; src: url("/static/fonts/plex-hebrew-700.woff2") format("woff2"); unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F; }
@font-face { font-family: "Plex"; font-weight: 700; font-display: swap; src: url("/static/fonts/plex-latin-700.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2212; }
/* the caption typefaces, so the preview matches the exported video */
@font-face { font-family: "Heebo"; src: url("/fonts/Heebo_700Bold.ttf"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Assistant"; src: url("/fonts/Assistant_700Bold.ttf"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Rubik"; src: url("/fonts/Rubik_700Bold.ttf"); font-weight: 700; font-display: swap; }

:root {
  color-scheme: dark;
  /* surfaces, darkest to lightest */
  --deep: #100E17;        /* behind the video; input wells */
  --bg: #17141F;          /* the page */
  --surface: #211D2B;     /* cards, sheets */
  --raised: #2B2637;      /* buttons, chips, selected tabs */
  --line: #342E43;        /* hairlines */
  /* text */
  --ink: #EFEAE2; --muted: #A39DB0; --faint: #6F6883;
  /* the one accent: caption yellow. Dark text sits on it. */
  --accent: #FFD23F; --accent-ink: #17141F; --accent-press: #EBBE2A; --accent-soft: rgba(255, 210, 63, .13);
  /* meanings */
  --cut: #FF6B5E; --cut-soft: rgba(255, 107, 94, .14);
  --ok: #5AD19A; --ok-soft: rgba(90, 209, 154, .14);
  --warn: #FFB04A; --warn-soft: rgba(255, 176, 74, .15);
  /* shape and type */
  --r-s: 8px; --r-m: 12px; --r-l: 16px; --r-xl: 22px;
  --radius: var(--r-l);
  --ui: "Plex", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --fast: .12s; --press: .06s;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 16px;
  line-height: 1.5; -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
h1, h2, h3 { font-weight: 700; margin: 0; line-height: 1.2; }
h1 { font-size: 1.875rem; letter-spacing: -.02em; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
strong, b { font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent); color: var(--accent-ink); }
.muted { color: var(--muted); } .small { font-size: .875rem; } .err { color: var(--cut); } .ok { color: var(--ok); }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }

/* ---- page frame ---- */
.wrap { max-width: 720px; margin: 0 auto; padding: 12px 16px 96px; }
.wrap.narrow { max-width: 460px; }
.top { display: flex; align-items: center; gap: 2px; padding: 12px 16px; max-width: 720px; margin: 0 auto; }
.brand { font-weight: 700; font-size: 1.06rem; margin-inline-end: auto; text-decoration: none; color: var(--ink);
  display: inline-flex; align-items: center; gap: 9px; }
.brand .mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.navlink { padding: 7px 11px; border-radius: var(--r-s); text-decoration: none; color: var(--muted); font-size: .92rem;
  transition: color var(--fast), background-color var(--fast); }
.navlink:hover { color: var(--ink); }
.navlink.on { color: var(--ink); background: var(--raised); font-weight: 500; }
.foot { max-width: 720px; margin: 0 auto; padding: 0 16px 28px; color: var(--muted); font-size: .78rem; text-align: center; }
.lead { font-weight: 700; font-size: 1.5rem; line-height: 1.3; letter-spacing: -.01em; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.solid { fill: currentColor; stroke: none; }

/* a thin bar along the top while the server is working */
body.loading::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%;
  background-repeat: no-repeat; animation: slide 1s linear infinite; }
@keyframes slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* ---- buttons ---- */
.btn { border: 1px solid transparent; background: var(--raised); border-radius: var(--r-m); padding: 9px 16px;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  text-decoration: none; color: var(--ink); white-space: nowrap; font-weight: 500;
  transition: background-color var(--fast), border-color var(--fast), color var(--fast), transform var(--press); }
.btn:hover:not(:disabled) { background: #352F45; }
.btn:active:not(:disabled) { transform: scale(.96); background: #3B344C; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.iconbtn { gap: 5px; padding-inline: 9px; }
.btn.iconbtn .lbl { font-size: .8rem; }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #FFDA5C; }
.btn.primary:active:not(:disabled) { background: var(--accent-press); }
.btn.big { width: 100%; min-height: 56px; font-size: 1.08rem; border-radius: var(--r-l); }
.btn.ghost { background: transparent; padding-inline: 10px; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--raised); color: var(--ink); }
.btn.danger { color: var(--cut); }
.btn.danger-solid { background: var(--cut); color: #1B0C0A; font-weight: 700; }
.btn.danger-solid:hover:not(:disabled), .btn.danger-solid:active:not(:disabled) { background: #FF8176; }
.btn.sm { min-height: 36px; padding: 5px 12px; font-size: .875rem; border-radius: 10px; }
/* the pressed button while the server answers: its label fades and a spinner turns */
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy > * { visibility: hidden; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--ink); border-top-color: transparent; animation: spin .7s linear infinite; }
.btn.primary.busy::after, .btn.danger-solid.busy::after { border-color: var(--accent-ink); border-top-color: transparent; }
.btn:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .word:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- cards, chips, banners ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 16px; }
a.card { display: block; text-decoration: none; color: inherit; transition: background-color var(--fast), transform var(--press); }
a.card:hover { background: #262132; }
a.card:active { transform: scale(.99); }
/* the reel list is a list, not a pile of boxes: rows with a hairline between them */
a.card.reel { display: flex; align-items: center; gap: 14px; padding: 12px 6px; background: none; border: 0;
  border-bottom: 1px solid var(--line); border-radius: 0; margin-top: -14px; }
a.card.reel:first-child { margin-top: 0; }
a.card.reel:hover { background: var(--surface); }
a.card.reel strong { font-size: 1.02rem; }
.thumb { width: 48px; height: 85px; border-radius: var(--r-s); object-fit: cover; background: var(--raised); flex: none; }
.thumb.empty { display: grid; place-items: center; color: var(--faint); }
.empty-state { text-align: center; padding: 36px 16px; border-style: dashed; background: none; }
.chip { display: inline-flex; align-items: center; border-radius: 6px; padding: 2px 9px; font-size: .78rem; font-weight: 500;
  background: var(--raised); color: #CFC8DC; white-space: nowrap; }
.chip.gray { background: none; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.chip.red { background: var(--cut-soft); color: var(--cut); }
.chip.green { background: var(--ok-soft); color: var(--ok); }
.chip.amber { background: var(--warn-soft); color: var(--warn); }
.banner { background: var(--accent-soft); color: #F6E7AE; border-radius: var(--r-m); padding: 11px 14px; font-size: .9rem; }
.banner.amber { background: var(--warn-soft); color: #FFD9A6; }

/* ---- forms ---- */
label.field, div.field { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  border: 1px solid var(--line); background: var(--deep); border-radius: 10px; padding: 10px 12px;
  width: 100%; min-height: 46px; color: var(--ink); font-size: 1rem; transition: border-color var(--fast); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #463E59; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { min-height: 84px; resize: vertical; }
textarea.tall { min-height: 150px; font-size: .85rem; }
input[type=range] { width: 100%; accent-color: var(--accent); min-height: 28px; }
input[dir=ltr] { font-size: .92rem; }   /* addresses, model paths, keys: long Latin strings */
input[type=checkbox] { accent-color: var(--accent); }
input[type=color] { width: 44px; height: 36px; border: 1px solid var(--line); border-radius: var(--r-s); padding: 2px; background: var(--deep); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; color: var(--ink); font-size: .95rem; }
.switch input { width: 22px; height: 22px; flex: none; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { border: 1px solid transparent; background: var(--raised); border-radius: 10px; padding: 6px 14px; min-height: 40px; color: var(--ink); }
.seg button, .tabs button, .viewtabs button { transition: background-color var(--fast), color var(--fast), transform var(--press); }
.seg button:active, .tabs button:active, .viewtabs button:active { transform: scale(.96); }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--bg); font-weight: 600; }
.scale-ends { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); }   /* same direction as the slider above it */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 8px 12px; border-radius: var(--r-s); white-space: nowrap; color: var(--muted); min-height: 40px; }
.tabs button[aria-selected=true] { background: var(--raised); color: var(--ink); font-weight: 500; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }

/* ---- editor ---- */
.editor { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; height: 100dvh; }
.ed-top { display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.ed-top .title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: none; border: 0; text-align: start; padding: 6px; border-radius: var(--r-s); }
.ed-top .btn.sm { padding-inline: 8px; }
.ed-top .btn.primary.sm { padding-inline: 16px; }
@media (max-width: 520px) { .ed-top .iconbtn .lbl { display: none; } .ed-top .btn.sm.iconbtn { min-width: 40px; min-height: 40px; } }   /* icons only on a phone: the reel's name gets the room */
.left { background: var(--deep); }
.stage { display: flex; justify-content: center; padding: 12px 12px 2px; }
.player { position: relative; height: min(44dvh, 520px); aspect-ratio: 9 / 16; background: #000; border-radius: 10px;
  overflow: hidden; container-type: inline-size; touch-action: manipulation; box-shadow: 0 14px 44px rgba(0, 0, 0, .55); }
.player video, .player img.insert { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.player video.clip { object-fit: contain; }      /* shown whole, then enlarged by the zoom setting (Player.setZoom) */
.player video.clip { visibility: hidden; } .player video.clip.on { visibility: visible; }
.player .insert { z-index: 2; }
.cap { position: absolute; z-index: 3; left: 12%; right: 12%; text-align: center; direction: rtl; font-weight: 700;
  line-height: 1.22; pointer-events: none; paint-order: stroke fill; white-space: nowrap; }
.cap.bottom { bottom: 22.9%; } .cap.top { top: 13%; } .cap.middle { top: 50%; transform: translateY(-50%); }
.cap .box { display: inline-block; background: rgba(0,0,0,.69); padding: .12em .35em; }
.label-ad { position: absolute; z-index: 3; top: 8.8%; right: 5.5%; background: rgba(0,0,0,.75); color: #fff;
  font-family: "Assistant", var(--ui); font-weight: 700; font-size: 3.7cqw; padding: .2em .6em; }
.guides { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.guides i { position: absolute; border: 0 dashed rgba(255,255,255,.55); }
.guides .t { top: 13%; left: 0; right: 0; border-top-width: 1px; }
.guides .b { bottom: 22.9%; left: 0; right: 0; border-top-width: 1px; }
.guides .r { right: 12%; top: 40%; bottom: 22.9%; border-right-width: 1px; }
.bigplay { position: absolute; inset: 0; z-index: 5; background: transparent; border: 0; }
.transport { display: flex; align-items: center; gap: 12px; padding: 8px 16px 2px; direction: ltr; }
.transport .play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); flex: none;
  display: grid; place-items: center; transition: transform var(--press); }
.transport .play:active { transform: scale(.9); }
.transport input[type=range] { -webkit-appearance: none; appearance: none; height: 28px; background: none; --p: 0%; }
.transport input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) var(--p), var(--raised) var(--p)); }
.transport input[type=range]::-moz-range-track { height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) var(--p), var(--raised) var(--p)); }
.transport input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink); border: 0; margin-top: -5px; }
.transport input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 0; }
.transport .time { font-variant-numeric: tabular-nums; font-size: .82rem; color: var(--muted); white-space: nowrap; }
.tools { display: flex; gap: 2px; padding: 4px 8px 8px; }
.tools .btn { flex: 1; flex-direction: column; gap: 3px; padding: 7px 0 6px; min-height: 54px; font-size: .72rem; font-weight: 400;
  background: none; color: #CFC8DC; border-radius: var(--r-m); min-width: 0; }
.tools .btn:hover:not(:disabled) { background: var(--raised); color: var(--ink); }
.tools .btn:active:not(:disabled) { background: var(--raised); color: var(--accent); }
.lower { flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); background: var(--bg); }
.viewtabs { display: flex; align-items: center; gap: 4px; padding: 8px 12px 0; }
.viewtabs button { border: 0; background: transparent; padding: 5px 14px; min-height: 34px; border-radius: var(--r-s); color: var(--muted); font-size: .9rem; }
.viewtabs button[aria-selected=true] { background: var(--raised); color: var(--ink); font-weight: 500; }
.viewtabs .tally { margin-inline-start: auto; font-size: .78rem; color: var(--cut); font-variant-numeric: tabular-nums; }
.transcript { flex: 1; overflow-y: auto; padding: 8px 14px 32px; font-size: 1.16rem; line-height: 2.1; }
.timeline { flex: 1; overflow-y: auto; padding: 12px 14px 24px; display: flex; flex-direction: column; gap: 12px; }
.tl-scroll { overflow-x: auto; direction: ltr; border-radius: 10px; flex: none; }
.tl-strip { position: relative; height: 58px; border-radius: 10px; cursor: pointer;
  background: repeating-linear-gradient(135deg, #1E1A28 0 6px, #262132 6px 12px); }     /* hatched = removed */
.tl-strip i { position: absolute; top: 0; bottom: 0; display: block; }
.tl-clip { border-inline-start: 2px solid var(--bg); }
.tl-clip b { position: absolute; top: 2px; left: 6px; font-size: .68rem; color: var(--muted); font-weight: 500; font-style: normal; z-index: 2; }
.tl-kept { background: #B9B0D6; top: 16px !important; bottom: 7px !important; border-radius: 3px; min-width: 1px; }
.tl-bar { top: auto !important; bottom: 7px !important; height: calc(4px + var(--v) * 3.4px); z-index: 1; pointer-events: none;
  background: linear-gradient(var(--bg), var(--bg)) center / 2px 100% no-repeat; opacity: .5; }     /* a dark notch per half second, taller = louder */
.tl-sel { background: rgba(255, 107, 94, .7); top: 16px !important; bottom: 7px !important; z-index: 2; }
.tl-gap { outline: 2px solid var(--warn); outline-offset: -2px; background: var(--warn-soft); z-index: 2; border-radius: 4px; }
.tl-mark { width: 2px; background: var(--cut); z-index: 3; }
.tl-head { width: 2px; background: var(--accent); z-index: 4; pointer-events: none; }
.tl-head::before { content: ""; position: absolute; top: -1px; left: -4px; border: 5px solid transparent; border-top-color: var(--accent); }
.timeline .marks .btn { flex: 1; }
.clip-head { display: block; font-size: .76rem; color: var(--faint); margin: 12px 0 0; line-height: 1.4; }
.word { display: inline-block; padding: 0 5px; margin: 1px 0; border-radius: 6px; border: 0; background: none;
  cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; line-height: 1.55;
  transition: background-color var(--fast), color var(--fast); }
.word:hover { background: var(--surface); }
.word.cut { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--cut); text-decoration-thickness: 2px; }
.word.fixed { border-bottom: 2px dotted var(--accent); }
.word.unsure { border-bottom: 2px dotted var(--warn); }   /* the speech model was not sure of this word */
.word.nocap { color: #8C849F; font-style: italic; }       /* heard in the video, left out of the captions */
.word:active { background: var(--raised); }
.word.maybe { border-bottom: 1px dotted var(--faint); }   /* the other speech model heard something else here */
.word.now { background: var(--accent); color: var(--accent-ink); font-weight: 600; }     /* the word being spoken: lit like a caption */
.word.now.cut { background: var(--raised); color: var(--muted); font-weight: 400; }
.word.sel { background: var(--warn-soft); color: #FFD9A6; }
.word.has-insert { box-shadow: inset 0 -3px 0 var(--ok); }
.gap { display: inline-block; color: var(--faint); font-size: .8rem; padding: 0 3px; }
.pickbar { position: sticky; top: 0; z-index: 2; background: #3A2E1C; color: #FFD9A6; border-radius: 10px;
  padding: 8px 12px; font-size: .9rem; display: flex; justify-content: space-between; align-items: center; line-height: 1.4; }
.pickbar.quiet { background: var(--surface); color: var(--muted); position: static; }

/* ---- bottom sheet ---- */
.scrim { position: fixed; inset: 0; background: rgba(6, 4, 10, .62); z-index: 20; display: flex; align-items: flex-end;
  justify-content: center; animation: fade .16s ease-out; }
.sheet { background: var(--surface); width: 100%; max-width: 720px; max-height: 86dvh; overflow-y: auto;
  border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 10px 16px calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); animation: rise .2s cubic-bezier(.2, .8, .2, 1); }
.sheet::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 8px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet .card { background: var(--bg); }
.sheet .btn:not(.primary):not(.ghost):not(.danger-solid):not(.on) { background: #352F45; }
.sheet .seg button:not([aria-pressed=true]) { background: #352F45; }
.assets { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.asset { position: relative; aspect-ratio: 9 / 16; border-radius: 10px; overflow: hidden; background: var(--deep);
  border: 1px solid var(--line); display: flex; flex-direction: column; justify-content: flex-end; }
.asset img, .asset video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.asset .bar { position: relative; display: flex; gap: 4px; padding: 4px; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.asset .state { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-size: .8rem; padding: 6px; color: var(--muted); }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(8px); background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: var(--r-m); font-size: .9rem; font-weight: 500; z-index: 40; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: 92vw; text-align: center; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ---- tables and facts ---- */
table.plain { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.plain th { color: var(--muted); font-weight: 500; font-size: .8rem; }
table.plain td, table.plain th { text-align: start; padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: .92rem; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.stats .card { padding: 12px; color: var(--muted); font-size: .82rem; }
.stats b { display: block; font-size: 1.6rem; font-weight: 700; color: var(--ink); letter-spacing: -.02em; line-height: 1.2; }

/* ==== screen: auth (sign-in, sign-up, guest entry, team invitation) ==== */
/* rules for these screens only; tokens only */
.wrap.auth { display: flex; flex-direction: column; gap: 20px; padding-block-start: 20px; }
.auth-intro { max-width: 22ch; text-wrap: balance; }
.auth-side { display: flex; flex-direction: column; gap: 20px; }
.auth-form h1 { font-size: 1.2rem; letter-spacing: 0; }
.auth-form .err:empty { display: none; }
.auth-switch { font-size: .875rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.auth-switch a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 6px; font-weight: 600; }
.auth-guest { border-block-start: 1px solid var(--line); padding-block-start: 14px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.auth-guest .btn { min-height: 44px; padding-inline: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; background: none; }
.auth-guest .btn:hover:not(:disabled) { background: none; }
.guestbar { flex-wrap: nowrap; align-items: center; padding: 6px 12px; gap: 10px; font-size: .875rem; line-height: 1.35; }
.guestbar .btn { flex: none; }
@media (min-width: 900px) {
  .wrap.auth { flex-direction: row; align-items: center; justify-content: space-between; gap: 64px; min-height: 76dvh; padding-block-start: 0; }
  .wrap.auth.solo { justify-content: center; }
  .auth-intro { flex: 1; font-size: 1.875rem; line-height: 1.25; max-width: 16ch; }
  .auth-side { flex: none; width: 380px; }
}
/* ==== end: auth ==== */



/* ==== screen: home (reel list, new reel, waiting for a draft) ==== */
/* rules for these screens only; tokens only */

/* the reel list: one row per reel, thumbnail | title + quiet meta | status chip */
.reels { gap: 0; }
.reels > a.card.reel, .reels > a.card.reel:first-child { margin-top: 0; gap: 12px; padding: 12px 8px; min-height: 44px; }
.reels > a.card.reel:last-child { border-bottom: 0; }
.thumb { width: 44px; height: 78px; }
.reel-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.reel-title { font-size: 1.02rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reel-meta { font-variant-numeric: tabular-nums; }
.reel-stage { color: var(--warn); }
.reel-body progress { max-width: 9rem; margin-top: 4px; }
a.card.reel .chip { flex: none; }
.home-new .ic { width: 22px; height: 22px; }
.home-note { color: var(--faint); padding-inline: 8px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; border-style: solid; background: var(--surface); }
.empty-state p { max-width: 24rem; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 4px; border-radius: var(--r-l);
  background: var(--raised); color: var(--muted); }
.empty-icon .ic { width: 28px; height: 28px; }

/* new reel: the picker is the main event */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 176px;
  padding: 24px 20px; text-align: center; color: var(--ink); background: var(--deep); border: 2px dashed var(--faint); border-radius: var(--r-l);
  transition: background-color var(--fast), border-color var(--fast), transform var(--press); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop:active { transform: scale(.99); }
.drop strong { font-size: 1.08rem; }
.drop-icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 4px; border-radius: var(--r-m); background: var(--raised); }
.drop-icon .ic { width: 26px; height: 26px; }
.files { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.files:empty { display: none; }
.file { display: flex; align-items: center; gap: 10px; padding-inline: 14px 4px; min-height: 52px; border-bottom: 1px solid var(--line); }
.file:last-child { border-bottom: 0; }
.file > .ic { color: var(--muted); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { white-space: nowrap; }
.file .btn { min-width: 44px; padding-inline: 10px; }
.seg.fill button { flex: 1 1 auto; }
form .switch { border-top: 1px solid var(--line); padding-top: 14px; }
.formmsg:empty { margin-top: -14px; }

/* waiting for a draft, failed, needs the speech model */
.wait { gap: 18px; }
.wait-head { gap: 10px; align-items: flex-start; }
.wait h1 { overflow-wrap: anywhere; }
.wait-stage { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--deep); border-radius: var(--r-m); }
.wait-err { background: var(--cut-soft); color: var(--cut); border-radius: var(--r-m); padding: 12px 14px; }
.wait-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wait-actions .btn { flex: 1 1 auto; }
.wait-exports { display: flex; flex-direction: column; gap: 8px; }
.wait-exports:empty { display: none; }
.wait-foot { border-top: 1px solid var(--line); padding-top: 6px; }
.wait-foot .btn { padding-inline: 0; }
@media (min-width: 900px) {
  .home-new.big { width: auto; align-self: flex-start; padding-inline: 28px; }
  .wait-actions .btn { flex: 0 1 auto; }
}

/* the feedback box's way in, under the reel list */
.home-feedback { display: flex; justify-content: flex-start; padding-block-start: 4px; }
.fb-open { gap: 8px; }
.fb-open .chip { margin-inline-start: 2px; }
.sheet .err:empty { display: none; }
.banner .fb-open { margin-block-start: 8px; background: var(--raised); }
/* ==== end: home ==== */



/* ==== screen: account (teams, one team, my account) ==== */
/* rules for these screens only; tokens only */

/* sections: a heading, a line of help, then rows (not boxes) */
.sect { display: flex; flex-direction: column; gap: 10px; margin-block-start: 22px; }
.sect > p { margin: 0; }
/* rows with a hairline between them, like the reel list */
.rows { display: flex; flex-direction: column; border-block-start: 1px solid var(--line); }
.item-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; min-height: 56px; border-block-end: 1px solid var(--line); color: inherit; }
a.item-row { text-decoration: none; }
a.item-row:hover { background: var(--surface); }
.item-row.col { flex-direction: column; align-items: stretch; gap: 8px; }
.item-row .who { flex: 1 1 0; min-width: 0; }
.item-row .who > strong { font-size: 1.02rem; }
.item-row .btn { min-height: 44px; }
.item-row .who .ltr, .identity .who .ltr { overflow-wrap: anywhere; }
.iso { unicode-bidi: isolate; }
.who .ltr { width: fit-content; }
/* a member: name and email, then role and remove (they drop below the name on a phone) */
.member { flex-wrap: wrap; }
.member .who { flex-basis: 9rem; }
.member .ctl { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.role-select { width: auto; min-width: 7.5rem; }
/* destructive actions stay quiet until you reach for them */
.btn.quiet { color: var(--muted); }
.btn.quiet:hover:not(:disabled), .btn.quiet:focus-visible { color: var(--cut); background: var(--cut-soft); }
.leave-zone { margin-block-start: 28px; padding-block-start: 14px; border-block-start: 1px solid var(--line); display: flex; }
.leave-zone .btn { min-height: 44px; }
/* a read-only link beside its copy button */
.copybox { display: flex; align-items: center; gap: 8px; }
.copybox input { flex: 1 1 0; min-width: 0; text-overflow: ellipsis; }
.copybox .btn { flex: none; }
/* my account: who I am, then what I can do with it */
.identity { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; }
.identity .who { min-width: 0; }
.acct-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-block-start: 14px; border-block-start: 1px solid var(--line); }
.acct-actions .btn { min-height: 44px; }
.acct-actions .leave { margin-inline-start: auto; }
.empty-state .row { justify-content: center; }



/* ==== end: account ==== */



/* ==== screen: admin (the admin screens) ==== */
/* rules for these screens only; tokens only */
/* rules for these screens only; tokens only */
/* the five tabs stay on one row; if they ever overflow, the strip scrolls without a bar */
.adm-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 2px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.adm-tabs::-webkit-scrollbar { display: none; }
.adm-tabs button { flex: none; padding-inline: 7px; font-size: .92rem; }

/* numbers with labels, evenly sized */
.adm-stats { grid-template-columns: repeat(3, 1fr); }
.adm-stats .card { display: flex; flex-direction: column; gap: 2px; justify-content: space-between; min-height: 76px; padding: 10px 12px; }
.adm-stats > :last-child { grid-column: 1 / -1; min-height: 0; }

/* a model block: title and state on one line, then what it is, then one action */
.adm-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.adm-head h2 { min-width: 0; }
.adm-block .kv { grid-template-columns: auto minmax(0, 1fr); }
.adm-block .kv dd { overflow-wrap: anywhere; justify-self: start; }
.adm-choice { border-top: 1px solid var(--line); padding-top: 14px; }
.adm-progress { display: flex; flex-direction: column; gap: 6px; }
.adm-block .btn.ghost.danger, .adm-row .btn.ghost.danger { padding-inline: 12px; }
.btn.ghost.danger:hover:not(:disabled) { color: var(--cut); }

/* lists as rows with a hairline between them */
.adm-list { display: flex; flex-direction: column; }
.adm-row { display: flex; flex-direction: column; gap: 8px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.adm-row:first-child { padding-top: 4px; }
.adm-row:last-child { border-bottom: 0; }
.adm-row-head { display: flex; align-items: flex-start; gap: 10px; }
.adm-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.adm-email { display: block; width: fit-content; overflow-wrap: anywhere; }
.adm-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.adm-team { flex-direction: row; align-items: center; }
.adm-job-top { display: flex; align-items: center; gap: 10px; }
.adm-prompt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.adm-job .ltr { overflow-wrap: anywhere; }
.adm-row .btn.sm { min-height: 44px; }

/* forms: a section is a heading and its fields; short inputs stay short */
.adm-sec { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.adm-sec-head { display: flex; flex-direction: column; gap: 4px; }
.adm-sec.light h3 { color: var(--muted); font-weight: 500; }
.adm-form > .adm-sec:first-child { border-top: 0; padding-top: 0; }
.adm-fields { gap: 12px; }
.adm-help { font-size: .8rem; color: var(--faint); margin-top: -4px; }
.adm-form .field, .adm-form .switch { max-width: 34rem; }
.adm-form input[type=number] { max-width: 10rem; }
.adm-form select { max-width: 24rem; }
.adm-form textarea { max-width: 34rem; }
.adm-form .switch { padding: 4px 0; }
.adm-actions .btn { min-width: 0; }

@media (min-width: 900px) {
  .adm-stats { grid-template-columns: repeat(4, 1fr); }
  .adm-stats > :last-child { grid-column: auto; min-height: 76px; }
  .adm-sec { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 24px; align-items: start; }
  .adm-row .btn.sm { min-height: 36px; }
}

.fb-row { display: flex; flex-direction: column; gap: 6px; }
.fb-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
/* ==== end: admin ==== */



/* ==== screen: sheets (the editor's bottom sheets and the word sheet) ==== */
/* rules for these screens only; tokens only */

/* a titled group of controls: a hairline above, a small heading, then the controls */
.sheet .sh-group { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.sheet .stack > .sh-group:first-child { padding-top: 0; border-top: 0; }
.sheet .sh-group > h3 { color: var(--muted); font-size: .875rem; font-weight: 600; }
.sheet .sh-group .field { gap: 8px; }

/* switch rows: label (one or two lines) with a quiet help line, the checkbox at the far end */
.sheet .switch { min-height: 44px; padding: 4px 0; align-items: center; }
.sheet .sh-group .switch { padding-block: 2px; }
.sw-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; line-height: 1.35; }
.sw-help { color: var(--muted); font-size: .875rem; }

/* sliders: label and current value on one line, end labels under the track */
.slide { gap: 4px; }
.sl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; color: var(--ink); font-size: .95rem; }
.sl-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.slide .scale-ends { padding-inline: 4px; }

/* colour pickers: label and swatch on one row */
.color-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; color: var(--ink); font-size: .95rem; }
.saved { gap: 2px; }

/* the asset grid: tidy 9:16 tiles, actions along the bottom edge over a dark fade */
.assets { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.asset { border-radius: var(--r-m); }
.asset .bar { gap: 6px; padding: 24px 6px 6px; background: linear-gradient(transparent, rgba(0, 0, 0, .8)); }
.sheet .asset .bar .btn { min-height: 44px; padding-inline: 6px; }
.sheet .asset .bar .btn:not(.primary):not(.ghost):not(.danger-solid):not(.on) { background: rgba(0, 0, 0, .62); border-color: var(--line); }
.sheet .asset .bar .btn.place { flex: 1; min-width: 0; }
.sheet .asset .bar .btn.remove { flex: none; width: 44px; }
.asset .state { background: var(--deep); line-height: 1.4; }
.asset .state.err { color: var(--cut); }
.sheet .ai-block { gap: 12px; }
.ai-block textarea { min-height: 96px; }
.insert-row { display: flex; align-items: center; gap: 8px; min-height: 44px; border-bottom: 1px solid var(--line); }

/* clips: rows with a hairline, number, name and length, two 44px move buttons, the include box */
.clip-list { display: flex; flex-direction: column; }
.clip-row { display: flex; align-items: center; gap: 4px; min-height: 60px; padding-block: 6px; border-bottom: 1px solid var(--line); }
.clip-n { width: 28px; flex: none; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.clip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .clip-move { width: 44px; min-height: 44px; padding: 0; flex: none; }
.clip-on { width: 22px; height: 22px; flex: none; margin-inline: 11px; }

/* more: an action with its one-line explanation right under it; delete is last and quiet */
.act { display: flex; flex-direction: column; gap: 6px; }
.act .btn { width: 100%; }
.sh-danger { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.sh-danger .btn { width: 100%; }

/* export: finished exports as a short list of download buttons */
.sh-exports .stack { gap: 8px; }
.sh-exports .btn { justify-content: space-between; }

/* word sheet: quick actions wrap in two columns, notes stay quiet */
.sh-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sh-actions .btn { white-space: normal; text-align: center; line-height: 1.3; padding-block: 6px; }
.sh-notes { gap: 6px; }

/* ==== end: sheets ==== */



@media (min-width: 900px) {
  .top, .wrap, .foot { max-width: 820px; }
  .wrap.narrow { max-width: 460px; }
  .editor { max-width: none; display: grid; grid-template-columns: minmax(360px, 34vw) 1fr; grid-template-rows: auto 1fr; height: 100dvh; }
  .ed-top { grid-column: 1 / -1; padding-inline: 20px; }
  .left { display: flex; flex-direction: column; justify-content: center; border-inline-end: 1px solid var(--line); padding-bottom: 12px; }
  .player { height: min(66dvh, 640px); }
  .tools { max-width: 420px; margin: 0 auto; width: 100%; }
  .transport { max-width: 420px; margin: 0 auto; width: 100%; }
  .lower { border-top: 0; }
  .viewtabs { padding: 16px 28px 0; }
  .transcript { padding: 12px 28px 40px; font-size: 1.3rem; max-width: 46rem; }
  .timeline { padding: 16px 28px 24px; }
  .btn.iconbtn .lbl { font-size: .875rem; }
  .scrim { align-items: center; }
  .sheet { max-width: 520px; border-radius: var(--r-xl); border: 1px solid var(--line); }
  .sheet::before { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
