:root {
  --board: #F7F8FA;
  --paper: #FFFFFF;
  --ink: #1D2433;
  --ink-2: #4A5468;
  --ink-3: #7B8497;
  --rule: #D9DEE6;
  --red: #E63946;
  --blue: #118AB2;
  --yellow: #FFD166;
  --green: #0E9F6E;
  --font-head: "Baloo Bhaijaan 2", system-ui, sans-serif;
  --font-body: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--board);
  color: var(--ink);
  font: 400 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .4em; font-weight: 700; }
h1 { font-size: clamp(30px, 4.4vw, 44px); }
h2 { font-size: 26px; }
h3 { font-size: 19px; }
p { margin: 0 0 1em; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- top bar */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: var(--paper); border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
  font: 800 21px var(--font-head); }
.brand svg { width: 30px; height: 30px; }
.brand rect { fill: var(--ink); }
.brand path { stroke: var(--yellow); stroke-width: 3; fill: none; stroke-linecap: round; }
nav { display: flex; gap: 4px; }
nav a { text-decoration: none; color: var(--ink-2); padding: 6px 12px; border-radius: var(--r-sm); font-weight: 500; }
nav a:hover { color: var(--ink); background: var(--board); }
nav a.on { color: var(--ink); background: linear-gradient(transparent 62%, var(--yellow) 62%, var(--yellow) 90%, transparent 90%); }
.top-end { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.usage { font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.usage b { color: var(--ink); }

main { max-width: 860px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 40px) 96px; outline: none; }
main.wide { max-width: 1120px; }

/* ---------- buttons & inputs */
button, .btn {
  font: 600 15px var(--font-body); cursor: pointer; border-radius: var(--r-md);
  padding: 11px 20px; border: 2px solid var(--ink); background: var(--ink); color: #fff;
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; line-height: 1.2;
}
button:hover, .btn:hover { background: #2C3650; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary, .btn.secondary { background: var(--paper); color: var(--ink); }
button.secondary:hover, .btn.secondary:hover { background: var(--board); }
button.ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
button.ghost:hover { color: var(--ink); background: var(--board); }
button.danger { background: var(--paper); color: var(--red); border-color: var(--red); }
button.small { padding: 6px 12px; font-size: 14px; }
button.big { padding: 15px 28px; font-size: 17px; }
label { display: block; font-weight: 600; margin: 0 0 6px; }
.hint { color: var(--ink-3); font-size: 14px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; font: 400 16px/1.5 var(--font-body); color: var(--ink);
  padding: 11px 14px; border: 1.5px solid var(--rule); border-radius: var(--r-md); background: var(--paper);
}
input:focus, textarea:focus, select:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(17,138,178,.18); }
textarea { resize: vertical; min-height: 80px; }
.field { margin-bottom: 20px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > .field { flex: 1 1 200px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 28px; }

/* chips: one choice from a short set */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 8px 16px; border: 1.5px solid var(--rule); border-radius: 999px;
  background: var(--paper); font-weight: 500; }
.chip input:checked + span { border-color: var(--ink); background: var(--ink); color: #fff; }
.chip input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- the storyboard strip (signature) */
.story {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 0 0 36px;
}
.frame {
  position: relative; aspect-ratio: 16 / 10; border-radius: var(--r-md);
  border: 2px dashed var(--rule); background: transparent; padding: 10px 12px;
  display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden;
  text-align: start; color: var(--ink-3); font: inherit; cursor: default;
}
.frame small { font-size: 12px; color: var(--ink-3); }
.frame strong { font: 700 15px/1.2 var(--font-head); color: var(--ink); overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.frame.done { border: 2px solid var(--ink); background: var(--paper); cursor: pointer; }
.frame.done:hover { background: var(--board); }
.frame.now { border: 2px solid var(--blue); background: var(--paper); }
.frame.now strong { color: var(--blue); }
.frame .num { position: absolute; top: 8px; inset-inline-start: 10px; font: 700 13px var(--font-head); color: var(--ink-3); }
.frame.done .num { color: var(--ink); }
.frame.done::after { /* marker tick drawn in */
  content: ""; position: absolute; top: 9px; inset-inline-end: 10px; width: 18px; height: 10px;
  border-inline-start: 3px solid var(--red); border-bottom: 3px solid var(--red);
  transform: rotate(-45deg); transform-origin: center; animation: tick .35s ease-out both;
}
[dir=rtl] .frame.done::after { transform: rotate(45deg) scaleX(-1); }
@keyframes tick { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (max-width: 640px) {
  .story { grid-template-columns: repeat(5, minmax(96px, 1fr)); overflow-x: auto; padding-bottom: 6px; }
}

.step-title { margin-bottom: 4px; }
.step-sub { color: var(--ink-2); margin-bottom: 26px; }

/* ---------- option cards (style / voice / camera) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  position: relative; text-align: start; background: var(--paper); color: var(--ink);
  border: 2px solid var(--rule); border-radius: var(--r-lg); padding: 16px; font-weight: 400;
  display: flex; flex-direction: column; gap: 6px; cursor: pointer;
}
.card:hover { background: var(--paper); border-color: var(--ink-3); }
.card.on { border-color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }
[dir=rtl] .card.on { box-shadow: -4px 4px 0 var(--ink); }
.card h3 { margin: 4px 0 0; }
.card p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.card .thumb { border-radius: var(--r-md); background: var(--board); display: block; width: 100%; height: auto; }
.card[disabled] { opacity: .5; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--board); color: var(--ink-2); align-self: flex-start; }
.badge.free { background: #DDF5EC; color: #0B6E4D; }
.badge.paid { background: #FFF1CC; color: #7A5600; }

/* ---------- panels */
.panel { background: var(--paper); border: 1.5px solid var(--rule); border-radius: var(--r-lg); padding: 22px; margin-bottom: 20px; }
.panel h2 { font-size: 22px; }
.panel.quiet { background: transparent; }

/* script review: scene list */
.scenes { counter-reset: sc; display: flex; flex-direction: column; gap: 12px; }
.scene { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; }
.scene .n { counter-increment: sc; font: 800 22px var(--font-head); color: var(--ink-3); text-align: center; padding-top: 8px; }
.scene .n::before { content: counter(sc); }
.scene textarea { min-height: 72px; }
.scene .board { font-size: 14px; color: var(--ink-2); margin-top: 6px; padding-inline-start: 2px; }
.scene .board b { color: var(--ink); font-weight: 600; }

/* teleprompter */
.prompter { background: var(--ink); color: #fff; border-radius: var(--r-lg); padding: 24px 28px;
  font: 500 22px/1.7 var(--font-body); max-height: 360px; overflow: auto; white-space: pre-wrap; }

/* upload drop zone */
.drop { border: 2px dashed var(--ink-3); border-radius: var(--r-lg); padding: 28px; text-align: center; background: var(--paper); }
.drop.over { border-color: var(--blue); background: #EAF6FB; }
.drop input { display: none; }
.bar { height: 12px; border-radius: 999px; background: var(--rule); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--blue); width: 0; transition: width .4s ease; }
.bar.ink > i { background: var(--ink); }

/* progress (render) */
.render-stage { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 6px 0 12px; }
.render-stage strong { font: 700 22px var(--font-head); }
.render-stage span { font: 700 34px var(--font-head); }
.pen { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--red); margin-inline-end: 8px;
  animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
details summary { cursor: pointer; color: var(--ink-2); font-size: 14px; margin-top: 14px; }
pre.log { background: var(--board); border-radius: var(--r-md); padding: 12px; font-size: 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; direction: ltr; text-align: left; }

/* downloads */
.player { width: 100%; max-height: 70vh; background: #000; border-radius: var(--r-lg); display: block; margin-bottom: 18px; }
.files { list-style: none; padding: 0; margin: 0; }
.files li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--rule); }
.files li:first-child { border-top: 0; }
.files .what { flex: 1; min-width: 0; }
.files .what b { display: block; }
.files .what small { color: var(--ink-3); overflow-wrap: anywhere; }
.expiry { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: #FFF1CC; color: #7A5600; font-size: 14px; }

/* jobs list */
.jobs { list-style: none; margin: 0; padding: 0; }
.jobs li a { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 16px 4px; text-decoration: none; color: var(--ink); border-top: 1px solid var(--rule); }
.jobs li:first-child a { border-top: 0; }
.jobs li a:hover { background: var(--paper); }
.jobs .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobs .m { color: var(--ink-3); font-size: 14px; }
.status { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; align-self: center; grid-row: span 2; white-space: nowrap; }
.s-done { background: #DDF5EC; color: #0B6E4D; }
.s-rendering, .s-queued, .s-scripting { background: #E1F1F8; color: #0B5F7C; }
.s-script_ready, .s-awaiting_upload { background: #FFF1CC; color: #7A5600; }
.s-failed { background: #FDE4E6; color: #B4202D; }
.s-expired, .s-draft { background: var(--board); color: var(--ink-3); }

/* auth */
.auth { max-width: 420px; margin: 6vh auto 0; }
.auth h1 { margin-bottom: 8px; }
.auth .lede { color: var(--ink-2); margin-bottom: 28px; }
.auth .switch { margin-top: 18px; color: var(--ink-2); }
.auth .switch button { padding: 0; border: 0; background: none; color: var(--blue); font-weight: 600; text-decoration: underline; }

/* admin */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: start; padding: 10px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
th { color: var(--ink-3); font-weight: 600; }
td input[type=number] { width: 80px; padding: 6px 8px; }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.scroll-x { overflow-x: auto; }

.error-box { background: #FDE4E6; color: #8E1A24; border-radius: var(--r-md); padding: 12px 16px; margin: 12px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note { background: var(--board); border-radius: var(--r-md); padding: 12px 16px; color: var(--ink-2); font-size: 14px; }

#toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: var(--r-md); font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); }
[dir=rtl] #toast { transform: translateX(50%); }
#toast.show { opacity: 1; }
#toast.bad { background: var(--red); }

.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty h2 { color: var(--ink); }

@media (max-width: 640px) {
  .top { gap: 10px; flex-wrap: wrap; }
  nav { order: 3; width: 100%; overflow-x: auto; }
  .usage { display: none; }
  .scene { grid-template-columns: 28px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::after { animation: none !important; transition: none !important; }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- brand kit editor + preview */
.story { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 640px) { .story { grid-template-columns: repeat(6, minmax(96px, 1fr)); } }
.frame.skip { opacity: .45; border-style: dotted; }
.brand-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.brand-side { position: sticky; top: 84px; }
@media (max-width: 760px) { .brand-grid { grid-template-columns: 1fr; } .brand-side { position: static; } }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border: 1.5px solid var(--rule);
  border-radius: var(--r-md); background: var(--paper); font-weight: 500; margin: 0; cursor: pointer; }
.swatch input { width: 34px; height: 34px; border: 0; padding: 0; background: none; cursor: pointer; }
.swatch code { font-size: 12px; color: var(--ink-3); }
.logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-box { width: 64px; height: 64px; border: 1.5px dashed var(--rule); border-radius: var(--r-md); display: grid; place-items: center;
  background: repeating-conic-gradient(#f0f2f5 0% 25%, #fff 0% 50%) 0 0/12px 12px; overflow: hidden; }
.logo-box img { max-width: 56px; max-height: 56px; }
.logo-box .hint { font-size: 11px; text-align: center; background: var(--paper); padding: 2px; }
.pv { position: relative; border-radius: var(--r-md); overflow: hidden; box-shadow: 0 0 0 1.5px var(--rule); }
.pv-169 { aspect-ratio: 16 / 9; }
.pv-916 { aspect-ratio: 9 / 16; max-width: 200px; margin: 0 auto; display: flex; flex-direction: column; }
.pv-logo { max-height: 22px; max-width: 60px; object-fit: contain; vertical-align: middle; }
.pv-wb { padding: 14px 16px; color: #1d2433; }
.pv-wb .pv-h { font-size: 21px; line-height: 1.15; max-width: 82%; }
.pv-wb .pv-u { height: 4px; width: 44%; border-radius: 4px; margin: 6px 0 12px; }
.pv-wb .pv-row { display: flex; align-items: center; gap: 10px; font-size: 14px; max-width: 75%; }
.pv-wb .pv-pill { position: absolute; bottom: 8px; inset-inline-start: 10px; display: inline-flex; gap: 6px; align-items: center;
  background: #1d2433; color: #fff; font-size: 10px; padding: 3px 8px; border-radius: 99px; }
.pv-wb .pv-pill .pv-logo { max-height: 14px; }
.pv-wb .pv-face { position: absolute; right: 10px; bottom: 10px; width: 46px; height: 46px; border-radius: 50%; border: 3px solid;
  background: radial-gradient(circle at 50% 38%, #8a5a3c 0 26%, transparent 27%), radial-gradient(circle at 50% 110%, #8a5a3c 0 45%, #e9d3c1 46%); }
.pv-916 .pv-top { flex: 0 0 44%; display: grid; place-items: center; text-align: center; font-size: 17px; padding: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(0,0,0,.18)); }
.pv-916 .pv-band { background: #F4EFE6; color: #1b1b1b; padding: 8px; text-align: center; display: flex; flex-direction: column; gap: 2px; align-items: center; }
.pv-916 .pv-band b { font-size: 15px; } .pv-916 .pv-band span { font-size: 10px; color: #555; } .pv-916 .pv-band small { font-size: 8px; color: #777; }
.pv-916 .pv-cap { padding: 14px 10px; text-align: center; font-size: 14px; }
.pv mark { color: #1b1b1b; padding: 0 3px; border-radius: 3px; }
.pv-pod { display: grid; grid-template-columns: 1fr 0.8fr 1fr; gap: 8px; padding: 12px; }
.pv-pod .pv-panel { background: #F4EFE6; color: #1b1b1b; border-radius: 6px; padding: 8px; font-size: 11px; }
.pv-pod .pv-panel.dim { opacity: .7; }
.pv-pod .pv-mid { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; color: #ddd; }
.pv-pod .pv-mid b { font-size: 13px; } .pv-pod .pv-mid small { font-size: 8px; }
.pv-pod .pv-mid span { display: flex; gap: 6px; } .pv-pod .pv-mid i { width: 16px; height: 16px; border-radius: 50%; display: block; }
.kits { list-style: none; margin: 0; padding: 0; }
.kits li { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.kits li:first-child { border-top: 0; }
.kit-logo { width: 44px; height: 44px; border-radius: var(--r-sm); background: var(--paper); border: 1px solid var(--rule); display: grid; place-items: center; overflow: hidden; }
.kit-logo img { max-width: 40px; max-height: 40px; }
.kit-what { flex: 1; min-width: 160px; } .kit-what small { display: block; color: var(--ink-3); }
.kit-sw { display: flex; gap: 4px; } .kit-sw i { width: 22px; height: 22px; border-radius: 50%; box-shadow: 0 0 0 1px var(--rule); display: block; }
.kit-act { display: flex; gap: 6px; }
/* six frames: tighter type so two lines fit */
.frame { padding: 8px 10px; }
.frame small { padding-inline-end: 22px; line-height: 1.3; }
.frame strong { font-size: 14px; }
/* checkbox chips read as checkboxes, not buttons */
.chip input[type=checkbox] + span { padding-inline-start: 38px; position: relative; }
.chip input[type=checkbox] + span::before { content: ""; position: absolute; inset-inline-start: 12px; top: 50%; width: 16px; height: 16px;
  margin-top: -8px; border: 2px solid var(--ink-3); border-radius: 4px; background: var(--paper); }
.chip input[type=checkbox]:checked + span { background: var(--paper); color: var(--ink); border-color: var(--ink); }
.chip input[type=checkbox]:checked + span::before { background: var(--ink); border-color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--paper); }
.frame small { position: absolute; top: 8px; inset-inline-start: 26px; inset-inline-end: 30px; padding: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ---------- reel layouts */
.card .thumb.tall { width: auto; height: 150px; margin: 0 auto; background: none; }
.layouts { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.rv { position: relative; background: #A9B4C2; color: #fff; }
.rv .rv-person { position: absolute; left: 50%; top: 30%; width: 44%; aspect-ratio: 1; transform: translateX(-50%);
  border-radius: 50%; background: radial-gradient(circle at 50% 40%, #8a5a3c 0 30%, transparent 31%), radial-gradient(circle at 50% 120%, #3a4a63 0 52%, transparent 53%); }
.rv-full .rv-person { width: 70%; top: 22%; }
.rv .rv-bug { position: absolute; top: 15.6%; inset-inline-start: 5.5%; display: inline-flex; gap: 4px; align-items: center;
  background: rgba(10,14,22,.6); border-radius: 99px; font-size: 9px; padding: 2px 7px; }
.rv .rv-bug .pv-logo { max-height: 12px; }
.rv .rv-head { position: absolute; top: 15.6%; left: 5.5%; right: 5.5%; border-radius: 8px; padding: 7px; text-align: center; font-size: 13px; line-height: 1.2; }
.rv-full .rv-head + .rv-bug { top: 28%; }
.rv .rv-cap { position: absolute; left: 6%; right: 6%; top: 62%; text-align: center; font-size: 15px; font-weight: 800;
  text-shadow: 0 0 3px #000, 0 0 3px #000; }
.rv .rv-bar { position: absolute; left: 0; top: 74.8%; height: 3px; width: 45%; }
.rv .rv-lt { position: absolute; top: 52.6%; inset-inline-start: 5.5%; width: 78%; background: #fff; color: #1d2433; border-radius: 6px;
  padding: 4px 8px; border-inline-start: 4px solid; display: flex; flex-direction: column; }
.rv .rv-lt b { font-size: 12px; } .rv .rv-lt small { font-size: 9px; color: #4a5468; }
.rv .rv-fhead { position: absolute; top: 15.6%; left: 5.5%; right: 5.5%; text-align: center; font-size: 12px; line-height: 1.2; }
.rv .rv-square { position: absolute; top: 23%; left: 8.3%; width: 83.4%; aspect-ratio: 1; border-radius: 8px; background: #A9B4C2; overflow: hidden; }
.rv .rv-square .rv-person { top: 18%; width: 60%; }
.rv .rv-square .rv-cap { top: 76%; font-size: 12px; }
.rv .rv-row { position: absolute; top: 70.5%; left: 0; right: 0; display: flex; gap: 6px; justify-content: center; align-items: center; font-size: 9px; }
.rv .rv-row .pv-logo { max-height: 14px; }
