:root {
  --bg: #0d0b1c; --panel: #16132c; --panel2: #1d1938; --line: #2b2752; --text: #edebff; --muted: #9b98c6; --dim: #6e6a9e;
  --holo: #00f5d4; --pink: #f72585; --yellow: #fee440; --crimson: #ff3d71; --blue: #6aa6ff; --cream: #ffe2c4; --gold: #ffc23d;
  --radius: 14px; --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
body { display: grid; grid-template-columns: 220px 1fr; }
a { color: var(--holo); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; letter-spacing: .2px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .pad { padding: 24px; } .small { font-size: 12px; }
.ok { color: var(--holo); } .bad { color: var(--crimson); } .warn { color: var(--yellow); }

/* sidebar */
.side { background: linear-gradient(180deg, #151231, #0f0d22); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--cream); font-size: 17px; font-weight: 600; }
.brand img { width: 32px; height: 32px; } .brand b { color: var(--gold); font-weight: 600; } .brand:hover { text-decoration: none; }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a { color: var(--muted); padding: 9px 12px; border-radius: 10px; font-weight: 500; }
.side nav a:hover { background: var(--panel2); color: var(--text); text-decoration: none; }
.side nav a.active { background: rgba(0, 245, 212, .1); color: var(--holo); }
.side-foot { margin-top: auto; font-size: 12px; color: var(--dim); }
.side-foot .run { color: var(--holo); }
/* the current style, a tap away from the landing page */
.style-pill { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); font-weight: 600; min-width: 0; }
.style-pill:hover { border-color: #3d3874; text-decoration: none; }
.style-pill .style-name { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.style-pill .sw-hint { color: var(--dim); font-size: 12px; font-weight: 500; }
.topbar, .tabbar, .mobile-start { display: none; }

main { padding: 26px 32px 60px; min-width: 0; overflow-wrap: anywhere; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 4px; }

/* surfaces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); }
.cols-auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 24px; font-weight: 600; margin-top: 2px; }
.kpi .l { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 12px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* forms */
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; font-weight: 500; }
.field { margin-bottom: 14px; }
input, select, textarea { width: 100%; background: #100e24; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--holo); box-shadow: 0 0 0 3px rgba(0, 245, 212, .12); }
textarea { resize: vertical; min-height: 80px; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--holo); }
input[type=color] { padding: 2px; height: 38px; }
input[type=range] { padding: 0; accent-color: var(--holo); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 13px; margin: 6px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hint { color: var(--dim); font-size: 12px; margin-top: 4px; }

button, .btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { border-color: #3d3874; text-decoration: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--holo); color: #071a17; border-color: var(--holo); font-weight: 600; }
.primary:hover { background: #4dffe5; border-color: #4dffe5; }
.danger { color: var(--crimson); }
.ghost { background: transparent; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--muted); }
.seg button.on { background: rgba(0, 245, 212, .14); color: var(--holo); }

/* chips and badges */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
.chip.holo { color: var(--holo); border-color: rgba(0, 245, 212, .35); }
.chip.pink { color: var(--pink); border-color: rgba(247, 37, 133, .4); }
.chip.yellow { color: var(--yellow); border-color: rgba(254, 228, 64, .35); }
.chip.red { color: var(--crimson); border-color: rgba(255, 61, 113, .4); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* video cards */
.vcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: transform .12s, border-color .12s; color: var(--text); display: block; }
.vcard:hover { transform: translateY(-2px); border-color: #3d3874; text-decoration: none; }
.thumb { aspect-ratio: 16 / 9; background: radial-gradient(circle at 50% 40%, #241f4d, #0f0c22); position: relative; display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.tall img { object-fit: contain; }
.thumb .badge { position: absolute; bottom: 8px; right: 8px; background: rgba(0, 0, 0, .7); padding: 1px 7px; border-radius: 6px; font-size: 12px; }
.thumb .fmt { position: absolute; top: 8px; left: 8px; }
.thumb .ph { color: var(--dim); font-size: 13px; }
.vbody { padding: 12px 14px 14px; }
.vbody .t { font-weight: 600; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 40px; }
.vbody .m { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* progress */
.bar { height: 6px; background: #100e24; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--holo), var(--blue)); border-radius: 99px; transition: width .3s; }
.stages { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin: 6px 0 4px; }
.stages span { height: 6px; border-radius: 4px; background: #232044; }
.stages span.done { background: var(--holo); }
.stages span.now { background: var(--yellow); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.stage-names { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; font-size: 10px; color: var(--dim); text-align: center; overflow-wrap: normal; }
.stage-now { display: none; font-size: 12px; color: var(--muted); }

/* jobs */
.jobs { display: grid; gap: 10px; margin-bottom: 22px; }
.job { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--holo); border-radius: 12px; padding: 12px 14px; }
.job.review { border-left-color: var(--yellow); } .job.failed, .job.interrupted, .job.canceled { border-left-color: var(--crimson); } .job.queued { border-left-color: var(--blue); }
.job .tail { font-family: Consolas, monospace; font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* log */
pre.log { background: #090817; border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 340px; overflow: auto; font-size: 12px; color: #b9b6e3; margin: 0; white-space: pre-wrap; word-break: break-word; }

/* video detail */
.player { width: 100%; border-radius: 12px; background: #000; max-height: 70vh; display: block; }
.player.tall { max-height: 72vh; width: auto; max-width: 100%; margin: 0 auto; }
.sheet { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.scene-row { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.scene-row:last-child { border-bottom: 0; }
.scene-row .n { color: var(--dim); font-family: Consolas, monospace; padding-top: 9px; }
.scene-row textarea { min-height: 54px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 10px 14px; }
.tabs button.on { color: var(--holo); border-bottom-color: var(--holo); }

/* voices */
.voices { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; max-height: 420px; overflow: auto; }
.voice { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--panel2); }
.voice.on { border-color: var(--holo); }
.voice .nm { font-weight: 600; }

/* lists */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
.ideas .idea { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ideas .idea:last-child { border-bottom: 0; }
.palettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 12px; }
.pal { display: block; width: 100%; padding: 0; overflow: hidden; text-align: left; white-space: normal; border-radius: 12px; }
.pal.on { border-color: var(--holo); box-shadow: 0 0 0 1px var(--holo); }
.pal img { display: block; width: 100%; aspect-ratio: 16 / 9; }
.pal .pb { padding: 8px 10px 10px; }
.pal .n { font-weight: 700; font-size: 13px; }
.pal .m { font-size: 12px; color: var(--muted); margin: 2px 0 6px; line-height: 1.35; }
.sw { display: inline-flex; gap: 3px; vertical-align: middle; }
.sw i { display: inline-block; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* toasts */
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--holo); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; }
.toast.error { border-left-color: var(--crimson); }

/* cards that fold away (closed on phones) */
.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary h2 { margin: 0; flex: 1; }
.fold > summary::after { content: '▾'; color: var(--dim); transition: transform .15s; }
.fold:not([open]) > summary::after { transform: rotate(-90deg); }
.fold[open] > summary { margin-bottom: 14px; }

/* landing page: the styles */
body.landing { grid-template-columns: 1fr; }
body.landing .side, body.landing .topbar, body.landing .tabbar { display: none; }
.landing-page { max-width: 1120px; margin: 0 auto; padding-top: 12px; }
.landing-head { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.landing-head img { width: 56px; height: 56px; }
.landing-head h1 { font-size: 30px; }
.landing-head .sub { color: var(--muted); margin-top: 4px; }
.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.style-card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; color: var(--text); transition: transform .12s, border-color .12s, box-shadow .12s; }
a.style-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 12px 34px rgba(0, 0, 0, .4); text-decoration: none; }
.style-card.soon { opacity: .72; cursor: default; }
.style-art { aspect-ratio: 16 / 9; background: #0f0c22; overflow: hidden; display: grid; place-items: center; }
.style-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.style-art.mosaic { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; place-items: stretch; }
.style-art.mosaic img:first-child { grid-row: span 2; }
.style-art.blank span { color: var(--text); font-weight: 700; font-size: 18px; opacity: .8; }
.style-body { padding: 14px 16px 16px; border-top: 3px solid var(--accent); }
.style-body .nm { font-size: 18px; }
.style-body .kind { color: var(--accent); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; margin-top: 4px; }
.style-body p { margin: 8px 0 12px; }
.style-body .m { display: flex; gap: 6px; flex-wrap: wrap; }
.card.live { margin-bottom: 18px; }
.live-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.live-row:last-child { border-bottom: 0; }
.live-row .t { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.landing-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 26px; color: var(--muted); }
.landing-foot .row { gap: 18px; }

@media (max-width: 1100px) { .cols-2 { grid-template-columns: 1fr; } }
/* too narrow for 13 step labels: the current step's name instead */
@media (max-width: 1000px) { .stage-names { display: none; } .stage-now { display: block; margin-top: 2px; } }
/* phones: a top bar with the style, a tab bar at the bottom, one column, bigger tap targets */
@media (max-width: 760px) {
  body { display: block; padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  body.landing { padding-bottom: env(safe-area-inset-bottom); }
  .side { display: none; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 40; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: rgba(13, 11, 28, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .topbar .brand img { width: 30px; height: 30px; display: block; }
  .topbar .style-pill { flex: 1; padding: 7px 12px; }
  .tb-run { font-size: 12px; font-weight: 600; }
  .tb-run .run { color: var(--holo); } .tb-run .warn { color: var(--yellow); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(15, 13, 34, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; color: var(--muted); font-size: 11px; font-weight: 500; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a.active { color: var(--holo); }
  main { padding: 16px max(16px, env(safe-area-inset-left)) 32px; }
  h1 { font-size: 21px; }
  .landing-head h1 { font-size: 24px; }
  .landing-head img { width: 44px; height: 44px; }
  .styles { grid-template-columns: 1fr; gap: 14px; }
  .head { margin-bottom: 16px; gap: 12px; }
  .head > .btn, .head > button { width: 100%; justify-content: center; }
  .head .add-row { width: 100%; flex-wrap: nowrap; } .head .add-row input { flex: 1; min-width: 0; }
  .two, .three { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; } .kpi .v { font-size: 20px; }
  .card { padding: 15px; }
  /* iOS zooms into inputs with text under 16 px */
  input, select, textarea { font-size: 16px; }
  button, .btn { min-height: 42px; }
  .seg button { min-height: 38px; }
  .job { grid-template-columns: 1fr; }
  .job > .row > * { flex: 1; justify-content: center; }
  .palettes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; min-height: 44px; }
  .player.tall { max-height: 78vh; }
  .ideas .idea { grid-template-columns: 1fr; }
  .voices { grid-template-columns: 1fr; }
  /* the activity table becomes one card per job */
  .jobs-table thead { display: none; }
  .jobs-table tr { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "title title" "chan status" "when open"; gap: 4px 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .jobs-table td { border: 0; padding: 0; }
  .jobs-table .c-title { grid-area: title; font-weight: 600; } .jobs-table .c-chan { grid-area: chan; } .jobs-table .c-status { grid-area: status; justify-self: end; }
  .jobs-table .c-when { grid-area: when; } .jobs-table .c-open { grid-area: open; justify-self: end; }
  /* New video: the start button stays above the tab bar */
  .mobile-start { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 35; padding: 10px 16px; background: rgba(22, 19, 44, .97); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(0, 0, 0, .35); }
  .mobile-start button { padding: 10px 22px; }
  .has-mobile-start { padding-bottom: 70px; }
  #toasts { left: 12px; right: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
}

/* sign-in page */
body.login { display: grid; place-items: center; min-height: 100vh; grid-template-columns: 1fr; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { margin-bottom: 22px; }
