:root {
  /* layout: fixed sidebar on desktop, bottom tab bar on phones; content in one readable column of cards */
  --bg: #f4f1fb; --surface: #ffffff; --sunk: #ebe6f8; --ink: #1a1433; --muted: #5d5678; --line: #dcd4ee;
  --accent: #6a2be0; --accent-ink: #ffffff; --accent-soft: #ece2ff;
  --teal: #0a8376; --cobalt: #2a55d6; --coral: #c93d22; --amber: #8f5b00; --good: #177a3c;
  --side: #1a0f3d; --side-ink: #e9e2ff; --side-muted: #a99bd6;
  --display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --script: "Courier Prime", "Courier New", monospace;
  --r: 14px; --shadow: 0 1px 2px rgba(26, 15, 61, .06), 0 6px 20px rgba(26, 15, 61, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark;
    --bg: #100c20; --surface: #1a1532; --sunk: #231c42; --ink: #efeaff; --muted: #a9a1c8; --line: #32295a;
    --accent: #a685ff; --accent-ink: #150f2b; --accent-soft: #2c2157;
    --teal: #35d3bf; --cobalt: #86a6ff; --coral: #ff8d75; --amber: #f2b84b; --good: #5ed88a;
    --side: #0b0818; --side-ink: #e9e2ff; --side-muted: #8f84b8; --shadow: none; }
}
:root[data-theme="dark"] { color-scheme: dark;
  --bg: #100c20; --surface: #1a1532; --sunk: #231c42; --ink: #efeaff; --muted: #a9a1c8; --line: #32295a;
  --accent: #a685ff; --accent-ink: #150f2b; --accent-soft: #2c2157;
  --teal: #35d3bf; --cobalt: #86a6ff; --coral: #ff8d75; --amber: #f2b84b; --good: #5ed88a;
  --side: #0b0818; --side-ink: #e9e2ff; --side-muted: #8f84b8; --shadow: none; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--body); }
h1 { font: 700 clamp(26px, 4vw, 36px)/1.1 var(--display); margin: 4px 0 16px; text-wrap: balance; letter-spacing: -.01em; }
h2 { font: 700 20px/1.2 var(--display); margin: 28px 0 12px; }
h2.flat { margin-top: 0; }
h3 { font: 600 16px/1.3 var(--body); margin: 16px 0 8px; }
p { margin: 0 0 10px; max-width: 70ch; }
a { color: inherit; }
ul { margin: 0 0 10px; padding-left: 20px; } li { margin-bottom: 6px; max-width: 70ch; }
ul.plain { list-style: none; padding: 0; }
.small { font-size: 14px; } .muted { color: var(--muted); } .mono { font-family: var(--script); }
.lead { font-size: 18px; color: var(--muted); }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: .02em; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 12px; top: 12px; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.boot { padding: 48px 24px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side { background: var(--side); color: var(--side-ink); padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; height: 100dvh; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand div { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font: 700 18px var(--display); } .brand span { font-size: 13px; color: var(--side-muted); }
.logo { width: 36px; height: 36px; border-radius: 10px; background: url(icons/icon-192.png) center/cover; flex: none; }
.brand.mobile { display: none; } .brand.big { margin-bottom: 8px; } .brand.big span { color: var(--muted); }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.navlink { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--side-ink); font-weight: 500; min-height: 44px; }
.navlink:hover { background: rgba(255, 255, 255, .08); }
.navlink.on { background: var(--accent); color: var(--accent-ink); }
:root:not([data-theme="dark"]) .side .navlink.on { background: #7b3df0; color: #fff; }
.navlink em { margin-left: auto; font-style: normal; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; border: 1px solid currentColor; opacity: .7; }
.sidefoot { margin-top: auto; color: var(--side-muted); padding: 0 12px; }
.tabbar { display: none; }
.content { min-width: 0; }
.top { display: flex; justify-content: flex-end; align-items: center; padding: 12px 28px 0; min-height: 40px; }
main { padding: 8px 28px 80px; max-width: 1080px; outline: none; }
.demo { margin: 8px 28px 0; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; }
.savestate { font-size: 13px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.savestate::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.savestate.busy::before { background: var(--amber); } .savestate.err { color: var(--coral); } .savestate.err::before { background: var(--coral); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.pad { padding: 18px 20px; } .pad.muted { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.two.tight { margin: 12px 0 4px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; } .row.between { justify-content: space-between; } .row.end { justify-content: flex-end; }
.row.wrap, .wrap { flex-wrap: wrap; } .gap { gap: 10px; } .grow { flex: 1 1 200px; min-width: 0; }
section { margin-bottom: 8px; } section.card, form.card, details.card { margin: 16px 0; }
.epcard { display: flex; flex-direction: column; gap: 8px; padding: 18px 20px; text-decoration: none; border-top: 4px solid var(--accent); transition: transform .12s ease; }
.epcard:hover { transform: translateY(-2px); } .epcard h3 { font: 700 20px/1.2 var(--display); margin: 0; }
.meter { display: flex; flex-direction: column; gap: 4px; }
.bar { appearance: none; -webkit-appearance: none; width: 100%; height: 8px; border: 0; border-radius: 99px; background: var(--sunk); overflow: hidden; display: block; margin-top: 6px; }
.bar::-webkit-progress-bar { background: var(--sunk); } .bar::-webkit-progress-value { background: var(--accent); border-radius: 99px; } .bar::-moz-progress-bar { background: var(--accent); }
.bar.teal::-webkit-progress-value { background: var(--teal); } .bar.teal::-moz-progress-bar { background: var(--teal); }
.pill { display: inline-flex; align-items: center; border-radius: 99px; padding: 2px 10px; font-size: 13px; font-weight: 600; border: 1.5px solid currentColor; white-space: nowrap; color: var(--muted); }
.pill.big { font-size: 14px; padding: 5px 14px; }
.pill.good { color: var(--good); } .pill.warn { color: var(--coral); } .pill.info, .pill.cobalt { color: var(--cobalt); } .pill.teal { color: var(--teal); }
.pill.accent { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.list { overflow: hidden; }
.listrow { display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-decoration: none; border-bottom: 1px solid var(--line); min-height: 48px; }
.listrow:last-child { border-bottom: 0; } a.listrow:hover { background: var(--sunk); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; } .dot.warn { background: var(--coral); } .dot.info { background: var(--cobalt); }
.task.done .grow { text-decoration: line-through; color: var(--muted); }
.link, .linkbtn { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn { background: none; border: 0; padding: 6px 0; cursor: pointer; font: inherit; font-weight: 600; }
.crumbs a { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; min-height: 36px; }
.empty { text-align: center; padding: 40px 20px; border: 1.5px dashed var(--line); border-radius: var(--r); grid-column: 1 / -1; }
.empty h3 { font: 700 20px var(--display); margin: 0 0 8px; } .empty p { margin: 0 auto 14px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--accent); color: var(--accent-ink); border: 1.5px solid var(--accent); border-radius: 10px; padding: 9px 16px; font: 700 15px var(--body); min-height: 44px; cursor: pointer; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent); } .btn.warn { background: var(--coral); border-color: var(--coral); color: var(--surface); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: 14px; } .btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 9px; padding: 8px 10px; min-height: 42px; max-width: 100%; }
textarea { width: 100%; resize: vertical; } input[type=checkbox] { min-height: 0; width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
input[type=file] { border-style: dashed; width: 100%; padding: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.chk { flex-direction: row; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; color: var(--ink); }
.formrow { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; } .formrow .full { flex-basis: 100%; margin-bottom: 0; }
.formrow input, .formrow select { width: 100%; }
.note { width: 100%; font-size: 14px; }
select.st-approved { border-color: var(--good); } select.st-needs_redo { border-color: var(--coral); } select.st-in_progress { border-color: var(--cobalt); }

.tabs { display: flex; gap: 4px; margin: 20px 0 16px; border-bottom: 1.5px solid var(--line); overflow-x: auto; }
.tab { padding: 10px 14px; text-decoration: none; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1.5px; white-space: nowrap; min-height: 44px; }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 0; position: sticky; top: 0; background: var(--bg); z-index: 4; }
.scenegroup { margin-top: 20px; }
.scenehead { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; border-left: 5px solid var(--accent); padding: 4px 0 4px 12px; margin-bottom: 8px; }
.slug { font: 700 15px var(--script); } .scenehead .btn { margin-left: auto; }
.scene .bar { margin-top: 10px; }
.chunk, .clip { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 12px 20px; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-top: 10px; }
.chunk.req, .clip.req { border-left-color: var(--teal); } .chunk.opt, .clip.opt { border-left-color: var(--cobalt); } .chunk.nos { border-style: dashed; border-left-style: solid; }
.chunk.removed, .chunk.no_clip, .clip.retired { opacity: .7; } .chunk.approved { background: transparent; }
.chunktop { margin-bottom: 6px; }
.script { font: 400 16px/1.5 var(--script); margin: 0 0 8px; max-width: 62ch; overflow-wrap: anywhere; } .script.act { color: var(--muted); }
.flag { font-size: 14px; margin: 4px 0 0; padding-left: 10px; border-left: 3px solid var(--coral); } .flag.long { border-color: var(--amber); } .flag.combine { border-color: var(--cobalt); }
.chunkctl, .clipctl { display: flex; flex-direction: column; gap: 8px; } .chunkctl select, .clipctl select { width: 100%; }
.clipcode { font: 700 15px var(--script); color: var(--accent); text-decoration: none; background: var(--accent-soft); padding: 2px 8px; border-radius: 6px; }
.cliptitle { display: block; margin-top: 6px; text-decoration: none; } .cliptitle:hover { text-decoration: underline; }
.sug summary, details summary { cursor: pointer; font-weight: 600; min-height: 32px; } .sugrow { padding: 10px 0; border-top: 1px solid var(--line); gap: 10px; }
.covered { border-bottom: 1px solid var(--line); padding: 10px 0; } .covered:first-of-type { padding-top: 0; }
.checks { list-style: none; padding: 0; } .checks li { padding: 4px 0; }
.take { border-top: 1px solid var(--line); padding: 12px 0; } .attempt { border-top: 1px solid var(--line); padding-top: 4px; margin-top: 8px; }
.danger { border-color: var(--coral); }
.scripttext { font: 14px/1.45 var(--script); white-space: pre-wrap; overflow-x: auto; background: var(--sunk); padding: 14px; border-radius: 10px; max-height: 60vh; overflow-y: auto; }
.preview { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--sunk); } .preview.bad { border: 1.5px solid var(--coral); }
.actionbar { position: sticky; bottom: 12px; margin-top: 16px; background: var(--side); color: var(--side-ink); border-radius: var(--r); padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; z-index: 5; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); }
.actionbar .btn.ghost { color: var(--side-ink); border-color: var(--side-muted); } .actionbar .btn:not(.ghost) { background: #35d3bf; border-color: #35d3bf; color: #0b0818; }
.overlay { position: fixed; inset: 0; background: rgba(10, 6, 30, .6); display: grid; place-items: center; padding: 16px; z-index: 20; }
.dialog { background: var(--surface); border-radius: var(--r); padding: 22px; width: min(680px, 100%); max-height: 90vh; overflow: auto; }
.splitter { line-height: 2.4; max-width: none; }
.cut { background: var(--accent-soft); color: var(--accent); border: 0; border-radius: 6px; padding: 4px 9px; margin: 0 3px; font-weight: 700; cursor: pointer; min-height: 32px; }
.cut:hover { background: var(--accent); color: var(--accent-ink); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 40; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--side); color: var(--side-ink); padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); }
.toast.error { background: var(--coral); color: #fff; }
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; max-width: none; background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent), var(--bg); }
.authcard { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.authcard input { width: 100%; } .authmsg { background: var(--accent-soft); padding: 10px 12px; border-radius: 9px; font-size: 14px; margin: 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .brand.mobile { display: flex; margin-right: auto; } .brand.mobile .logo { width: 28px; height: 28px; border-radius: 8px; }
  .top { padding: calc(10px + env(safe-area-inset-top)) 16px 0; justify-content: space-between; }
  main { padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); } .demo { margin: 8px 16px 0; }
  .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
  .tabbar .navlink { flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); padding: 6px 4px; justify-content: center; }
  .tabbar .navlink.on { background: transparent; color: var(--accent); }
  .chunk, .clip { grid-template-columns: 1fr; }
  .actionbar { bottom: calc(76px + env(safe-area-inset-bottom)); } #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .filters select { flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
