:root {
  --bg: #0a0a0c;          /* viewport (matches the renderer clear colour) */
  --panel: #121110;      /* = site --ground */
  --panel-2: #1b1917;
  --line: #2c2825;
  --line-2: #3a3530;
  --text: #ece6dc;
  --muted: #9a9184;
  --dim: #857d72;        /* 4.5:1 on the panel */
  --amber: #f2b441;
  --amber-ink: #1a1305;
  --amber-soft: rgba(242, 180, 65, .14);
  --blue: #8db8ff;
  --red: #ff7a66;
  --green: #9fd38a;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --sans: Inter, "Segoe UI Variable Text", "Segoe UI", "SF Pro Text", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.45 var(--sans); }
body { display: flex; overflow: hidden; }
[hidden] { display: none !important; }
kbd { font: 11px var(--mono); padding: 0 4px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 3px; background: var(--panel-2); color: var(--text); margin: 0 1px; }

/* ---------------------------------------------------------------- controls */
button { font: 12px var(--sans); color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 5px; padding: 5px 10px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: #5a5249; background: #24211e; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
button:disabled { cursor: default; border-color: var(--line); background: var(--panel-2); color: #6f675d; }
button.primary { background: #2a2622; color: var(--text); border-color: #4a433b; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #332e29; border-color: #5a5249; }
.step.current button.primary, #btnGenerate, .empty-card button.primary { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.step.current button.primary:hover:not(:disabled), #btnGenerate:hover:not(:disabled), .empty-card button.primary:hover:not(:disabled) { background: #ffc65c; border-color: #ffc65c; }
#btnGenerate:disabled { background: var(--panel-2); border-color: var(--line); color: #6f675d; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { color: var(--text); background: var(--panel-2); border-color: var(--line-2); }
button.danger:hover:not(:disabled) { color: var(--red); }
button.small { padding: 2px 7px; font-size: 11.5px; }
button.icon { padding: 2px 7px; font-family: var(--mono); min-width: 24px; }
input[type=number], input:not([type]), select { font: 12px var(--mono); color: var(--text); background: #0e0d0c; border: 1px solid var(--line-2); border-radius: 4px; padding: 4px 6px; min-width: 0; }
select { font-family: var(--sans); }
input[type=checkbox] { accent-color: var(--amber); margin: 0; }
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 18px; margin: 0; min-width: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: var(--line-2); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; background: var(--amber); border: 2px solid var(--bg); }
input[type=range]::-moz-range-track { height: 3px; background: var(--line-2); }
input[type=range]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--amber); border: 2px solid var(--bg); }
label { display: flex; align-items: center; gap: 6px; margin: 5px 0; color: var(--muted); }
label > input[type=number], label > input:not([type]), label > select { flex: 1; color: var(--text); }
label.check { color: var(--text); cursor: pointer; }
.unit { font: 11px var(--mono); color: var(--dim); }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.row.center { justify-content: center; }

/* ---------------------------------------------------------------- sidebar */
#side { width: 330px; flex: none; height: 100%; overflow-y: auto; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
#head { padding: 8px 10px 8px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { font-size: 15px; font-weight: 650; margin: 0; letter-spacing: .01em; }
#status { font: 11.5px var(--mono); color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
#status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
#status.ok::before { background: var(--green); }
#status.err { color: var(--red); }
#status.err::before { background: var(--red); }

.step { border-bottom: 1px solid var(--line); }
.step > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 11px 16px; cursor: pointer; user-select: none; }
.step > summary::-webkit-details-marker { display: none; }
.step > summary::after { content: "▸"; color: var(--dim); font-size: 10px; margin-left: 4px; transition: transform .15s; }
.step[open] > summary::after { transform: rotate(90deg); }
.step > summary:hover { background: #171615; }
.num { font: 600 11px var(--mono); width: 20px; height: 20px; display: grid; place-items: center; border-radius: 4px; border: 1px solid var(--line-2); color: var(--muted); flex: none; }
.step.done .num { border-color: #6b5a33; color: var(--amber); }
.step.current .num { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.step-title { font-size: 13.5px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step.done .step-body > .hint { display: none; }
.badge { font: 11.5px var(--sans); font-variant-numeric: tabular-nums; color: var(--muted); }
.step-body { padding: 0 16px 14px; }
.step.locked .step-body > :not(.locked-hint) { display: none; }
.locked-hint { display: none; }
.step.locked .locked-hint { display: block; color: var(--dim); }
.hint { color: var(--muted); margin: 0 0 8px; font-size: 12px; }
.sub { display: block; color: var(--dim); font-size: 11.5px; margin-top: 3px; }
.settings { flex-direction: column; align-items: stretch; gap: 6px; }
.settings label { margin: 0; }
.settings label > :first-child { flex: 1; }
.settings label > input[type=number] { flex: none; width: 80px; }
.opts { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--line); }
.opts label > input[type=number] { flex: none; width: 64px; }
.recipe { margin: 0 0 8px; padding: 0; list-style: none; counter-reset: r; }
.recipe li { counter-increment: r; position: relative; padding: 4px 0 6px 24px; color: var(--muted); font-size: 12px; }
.recipe li::before { content: counter(r, lower-alpha); position: absolute; left: 0; top: 4px; font: 11px var(--mono); color: var(--dim); width: 16px; text-align: center; }
.recipe li button { margin-top: -2px; }
.note { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 8px; border: 1px solid #6b5a33; background: var(--amber-soft); border-radius: 5px; font-size: 12px; margin: 4px 0 8px; }
.note.err { border-color: #7a3a30; background: rgba(255, 122, 102, .1); color: #ffb3a6; }
.size label { margin: 0; }
.size label > input { width: 64px; flex: none; }
.times { color: var(--dim); font-family: var(--mono); }
.field-error { color: var(--red); font-size: 11.5px; margin: -2px 0 4px; }
.status-line { font: 11.5px var(--mono); color: var(--muted); word-break: break-all; }
.status-line.ok { color: var(--green); }
.status-line.err { color: var(--red); }
.progress { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 6px 0; }
.progress i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .15s; }
.progress.indeterminate i { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

/* lists: input views and keyframes */
.list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; background: #0f0e0d; border: 1px solid var(--line); }
.item:hover, .item.hover { border-color: #5a4d33; }
.item.sel { border-color: var(--amber); background: #1a160f; }
.item.off { opacity: .55; }
.item .tag { font: 600 11px var(--mono); min-width: 22px; height: 18px; padding: 0 4px; border-radius: 3px; display: grid; place-items: center; background: var(--amber); color: var(--amber-ink); flex: none; }
.item.key .tag { background: var(--blue); color: #0b1424; }
.thumbwrap { position: relative; flex: none; display: block; line-height: 0; }
.thumbwrap .tag { position: absolute; left: -4px; top: -4px; }
.item img, .item .thumb { width: 64px; height: 36px; object-fit: cover; border-radius: 3px; flex: none; background: #000; border: 1px solid var(--line); }
.item.key .thumb { cursor: pointer; }
.item .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .info { font: 11px var(--mono); color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .acts { display: flex; gap: 1px; flex: none; }
.item .acts button { padding: 2px 5px; font-size: 12px; background: transparent; border-color: transparent; color: var(--muted); }
.item .acts button:hover { color: var(--text); background: var(--panel-2); border-color: var(--line-2); }
.item .acts button.on { color: var(--amber); }
.item .acts button[data-a=del]:hover { color: var(--red); }
.item input[type=number]::-webkit-inner-spin-button, .item input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.item input[type=number] { -moz-appearance: textfield; width: 58px; padding: 2px 4px; font-size: 11px; }
.item .info2 { display: flex; align-items: center; gap: 8px; }
.item .info2 .info { flex: none; }
.item .scale { display: flex; align-items: center; gap: 3px; font: 11px var(--mono); color: var(--dim); }

/* ---------------------------------------------------------------- viewport */
#main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; }
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#canvas { width: 100%; height: 100%; display: block; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; font: 600 11px var(--mono); padding: 1px 5px; border-radius: 3px; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer; white-space: nowrap; box-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.lbl.view { background: var(--amber); color: var(--amber-ink); }
.lbl.key { background: var(--blue); color: #0b1424; }
.lbl.hover, .lbl:hover { outline: 2px solid #fff; }
.lbl.sel { outline: 2px solid var(--amber); }

#hud .val { color: var(--text); min-width: 28px; }
#hud label.check { color: var(--muted); }

#activity { position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: min(520px, 46%); padding: 8px 8px 8px 12px; background: rgba(19, 18, 17, .92); border: 1px solid var(--line-2); border-left: 3px solid var(--amber); border-radius: 6px; z-index: 5; }
#activity .act-body { flex: 1; min-width: 0; }
#activity .act-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#activity .act-detail { color: var(--muted); font-size: 11.5px; }
#activity .act-detail:empty { display: none; }
#activity .progress { margin: 5px 0 1px; }
#activity .act-time { font: 11px var(--mono); color: var(--muted); }
#activity .spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--amber); animation: spin .8s linear infinite; flex: none; }
#activity.done { border-left-color: var(--green); }
#activity.done .spin { animation: none; border-color: var(--green); background: radial-gradient(var(--green) 35%, transparent 40%); }
#activity.err { border-left-color: var(--red); border-color: #7a3a30; }
#activity.err .spin { animation: none; border-color: var(--red); background: radial-gradient(var(--red) 35%, transparent 40%); }
#activity.err .act-detail { color: #ffb3a6; white-space: normal; }
#activity:not(.running) .progress { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }


#pip { position: absolute; border: 1px solid rgba(242, 180, 65, .7); border-radius: 2px; cursor: pointer; box-shadow: 0 4px 20px rgba(0, 0, 0, .5); }
#pip:hover { border-color: var(--amber); }
#pipLabel { position: absolute; left: -1px; bottom: 100%; margin-bottom: 4px; font: 600 11px var(--sans); color: var(--amber); white-space: nowrap; pointer-events: none; }
#safeFrame { position: absolute; border-radius: 6px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .7); pointer-events: none; }
#safeLabel { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); white-space: nowrap; font: 600 12px var(--sans); font-variant-numeric: tabular-nums; color: var(--text); background: rgba(19, 18, 17, .85); border: 1px solid var(--line-2); padding: 4px 12px; border-radius: 999px; }


/* empty state */
#empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 40%, rgba(242, 180, 65, .06), transparent 60%); overflow: auto; }
.empty-card { width: min(1040px, 100%); margin: 0 auto; }
.empty-card h2 { font-size: 26px; font-weight: 650; margin: 0 0 8px; letter-spacing: -.01em; }
.lede { color: var(--muted); font-size: 14px; margin: 0 0 18px; max-width: 60ch; }
.drop { border: 1.5px dashed #5a4d33; border-radius: 10px; padding: 26px 20px 20px; text-align: center; background: rgba(242, 180, 65, .03); transition: background .15s, border-color .15s; }
.drop.over { border-color: var(--amber); background: var(--amber-soft); }
.drop-title { font-size: 16px; font-weight: 600; }
.drop-sub { color: var(--muted); margin: 2px 0 12px; }
#emptyError { margin-top: 12px; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 22px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.steps li { counter-increment: s; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 8px; }
.steps li b { color: var(--text); font-size: 13px; }
.steps li b::before { content: counter(s); font: 600 11px var(--mono); color: var(--amber); margin-right: 6px; }

#dropOverlay { position: absolute; inset: 0; display: flex; gap: 16px; padding: 24px; background: rgba(10, 10, 12, .75); z-index: 8; }
#dropOverlay .zone { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px dashed var(--line-2); border-radius: 12px; font-size: 18px; text-align: center; padding: 16px; }
#dropOverlay .zone.over { border-color: var(--amber); background: var(--amber-soft); }
#dropOverlay .zone.disabled { opacity: .35; }
.zone-sub { font-size: 12.5px; color: var(--muted); max-width: 36ch; }

/* ---------------------------------------------------------------- timeline */
#timeline { flex: none; display: flex; align-items: center; gap: 14px; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--line); font: 12px var(--sans); font-variant-numeric: tabular-nums; }
#timeline label { margin: 0; font: 12px var(--sans); }
#timeline label > input[type=number] { flex: none; width: 56px; }
#timeline .toggle { color: var(--muted); }
.play { width: 32px; height: 28px; font-size: 13px; padding: 0; background: #2a2622; color: var(--text); border-color: #4a433b; }
.play:hover:not(:disabled) { background: #332e29; border-color: #5a5249; }
#scrub { position: relative; flex: 1; min-width: 160px; height: 58px; display: flex; align-items: flex-end; padding: 0 20px; }
#scrub input[type=range] { width: 100%; height: 14px; }
#ticks { position: absolute; left: 20px; right: 20px; top: 0; height: 34px; }
.tick { position: absolute; top: 0; transform: translateX(-50%); padding: 0; border-radius: 5px; background: #000; border: 1.5px solid var(--blue); cursor: pointer; min-width: 0; width: 44px; height: 28px; overflow: hidden; }
.tick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tick span { position: absolute; left: 2px; top: 2px; font: 700 9px/1 var(--sans); padding: 1px 3px; border-radius: 3px; background: var(--blue); color: #0b1424; }

.tick.sel { border-color: var(--amber); }
.tick.sel span { background: var(--amber); color: var(--amber-ink); }

#tlEmpty { position: absolute; inset: 0; display: none; align-items: center; color: var(--dim); font-family: var(--sans); font-size: 12px; white-space: nowrap; overflow: hidden; }
#timeline.empty #tlEmpty { display: flex; }
#timeline.empty #frame, #timeline.empty #ticks { visibility: hidden; }
#timeline.empty .play { opacity: .4; }
.readout { min-width: 120px; color: var(--text); white-space: nowrap; display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; }
.readout .dim { color: var(--dim); font-size: 11px; }
#timeline.empty .readout { visibility: hidden; }
.dim { color: var(--dim); }

/* ---------------------------------------------------------------- help overlay */
#help { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 20; }
.help-card { background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 16px 20px 18px; width: min(760px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.help-card h2 { font-size: 15px; margin: 0; }
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 10px; }
.help-cols dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; align-items: baseline; }
.help-cols dt { color: var(--text); white-space: nowrap; font-size: 12px; }
.help-cols dd { margin: 0; color: var(--muted); font-size: 12px; }

details.advanced { margin-top: 10px; }
details.advanced summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.step-title + .opt { margin-left: 6px; }
.mobile-note { display: none; }
@media (max-width: 900px) {
  #empty { place-items: start center; }
  .mobile-note { display: block; font-size: 13px; color: var(--amber); margin: 0 0 12px; }
  .steps { grid-template-columns: 1fr 1fr; }
  #timeline { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; transition: none !important; }
}

/* ---------------------------------------------------------------- ViewNext: account line and the Generate step */
h1 a { color: inherit; text-decoration: none; }
h1 a:hover { color: var(--amber); }
.results a:not(.button) { color: var(--amber); text-decoration: none; }
label.stack { flex-direction: column; align-items: stretch; gap: 4px; }
label.stack .sub { display: inline; margin: 0; }
input[type=password] { font: 12px var(--mono); color: var(--text); background: #0e0d0c; border: 1px solid var(--line-2); border-radius: 4px; padding: 5px 6px; }
textarea { font: 12px/1.45 var(--sans); color: var(--text); background: #0e0d0c; border: 1px solid var(--line-2); border-radius: 4px; padding: 6px; resize: vertical; }
textarea:focus-visible, input[type=password]:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
#estimate { display: inline; margin: 0 0 0 4px; }
.results { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.result { border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel-2); padding: 8px; }
.result-head { display: flex; justify-content: space-between; font: 11.5px var(--mono); color: var(--muted); margin-bottom: 6px; }
.result-title { color: var(--text); }
.result video { width: 100%; border-radius: 4px; background: #000; display: block; }
.result details { margin-top: 4px; color: var(--muted); font-size: 11.5px; }
.result summary { cursor: pointer; }
a.button { font: 600 12px var(--sans); color: var(--amber-ink); background: var(--amber); border-radius: 5px; padding: 5px 10px; text-decoration: none; }
.row.more { margin-top: 10px; }

/* ---------------------------------------------------------------- examples on the empty screen */
.examples { margin-top: 22px; text-align: left; }
.ex-head { font-weight: 600; margin-bottom: 10px; }
.ex-head .sub { display: inline; margin-left: 6px; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ex-card { display: flex; flex-direction: column; gap: 3px; padding: 0 0 8px; text-align: left; white-space: normal; border-radius: 7px;
           background: var(--panel-2); overflow: hidden; }
.ex-card:hover { border-color: var(--amber); }
.ex-media { position: relative; display: block; aspect-ratio: 4 / 3; background: #000; }
.ex-media img, .ex-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ex-media video { opacity: 0; transition: opacity .15s; }
.ex-media video.on { opacity: 1; }
.ex-title { font-weight: 600; font-size: 12.5px; padding: 0 9px; }
.ex-desc { color: var(--muted); font-size: 11.5px; padding: 0 9px; line-height: 1.35; }
#exampleSelect { max-width: 150px; }
.ex-card { position: relative; }
.ex-tag { position: absolute; z-index: 1; top: 8px; left: 8px; font: 600 11px var(--sans); padding: 1px 6px; border-radius: 4px; background: var(--amber); color: var(--amber-ink); }

/* ---------------------------------------------------------------- app bar and menus */
.appbar { display: flex; align-items: center; gap: 6px; height: 36px; }
.appbar h1 { font-size: 15px; font-weight: 700; margin: 0 6px 0 0; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.appbar .logo { display: inline-flex; align-items: center; gap: 7px; }
.appbar .logo::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.appbar .product { color: var(--muted); font-weight: 500; }
.appbar .spacer { flex: 1; }
.sign-in { font-weight: 600; color: var(--amber-ink); background: var(--amber); padding: 5px 12px; border-radius: 999px; text-decoration: none; font-size: 12px; }
.credit-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 10px; border-radius: 999px; border: 1px solid var(--line-2);
  color: var(--text); text-decoration: none; font: 600 12px var(--sans); font-variant-numeric: tabular-nums; }
.credit-pill b { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); color: var(--amber); font-size: 13px; }
.credit-pill:hover { border-color: #5a5249; }
.avatar { width: 28px; height: 28px; border-radius: 50%; padding: 0; font: 700 12px var(--sans); background: #3a3027; color: var(--amber); border-color: #5a4a33; }
.menu { position: relative; }
.menu-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 220px; padding: 6px; background: #1d1b19; border: 1px solid var(--line-2);
  border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .5); display: flex; flex-direction: column; }
.menu-pop.right { left: auto; right: 0; }
.menu-pop > button, .menu-pop > a { text-align: left; background: transparent; border: 0; border-radius: 6px; padding: 7px 10px; color: var(--text); font-size: 12.5px; text-decoration: none; }
.menu-pop > button:hover:not(:disabled), .menu-pop > a:hover { background: #2a2622; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 5px 2px; }
.menu-who { padding: 6px 10px 8px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- render bar (step 4), pinned to the panel's bottom */
.render-bar { position: sticky; bottom: 0; margin-top: auto; z-index: 2; padding: 12px 14px 10px; background: #161412; border-top: 1px solid var(--line-2);
  box-shadow: 0 -10px 24px rgba(0, 0, 0, .35); display: flex; flex-direction: column; gap: 8px; }
.rb-head { display: flex; align-items: center; gap: 10px; }
.rb-head b { font-size: 13.5px; flex: 1; }
.render-bar .hint { margin: 0; }
.seg-row { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: #0e0d0c; border: 1px solid var(--line-2); }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 4px 8px; border-radius: 6px; display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; }
.seg button[aria-checked="true"] { background: #2a2622; color: var(--text); }
.seg .ar { display: inline-block; width: calc(var(--w) / max(var(--w), var(--h)) * 12px); height: calc(var(--h) / max(var(--w), var(--h)) * 12px);
  border: 1.5px solid currentColor; border-radius: 2px; }
details.describe summary { cursor: pointer; font-size: 12px; color: var(--muted); }
details.describe summary .sub { display: inline; margin-left: 4px; }
details.describe textarea { width: 100%; margin-top: 6px; }
button.wide { width: 100%; height: 38px; font-size: 13.5px; border-radius: 8px; }
#estimate { display: block; margin: -2px 0 0; text-align: center; }
.render-bar .powered { margin: 2px 0 0; font-size: 10.5px; color: var(--dim); text-align: center; }

/* ---------------------------------------------------------------- renders panel and lightbox */
.renders { position: absolute; top: 10px; right: 10px; bottom: 10px; width: 300px; z-index: 6; display: flex; flex-direction: column;
  background: rgba(19, 18, 17, .94); backdrop-filter: blur(10px); border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; }
.renders-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 8px 14px; border-bottom: 1px solid var(--line); }
.renders .results { flex: 1; overflow-y: auto; padding: 10px; margin: 0; gap: 12px; }
.result { border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel-2); padding: 0; overflow: hidden; }
.r-media { position: relative; aspect-ratio: 16 / 9; background: #000; cursor: zoom-in; }
.r-media img, .r-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.r-media img { filter: blur(2px) brightness(.6); }
.r-media video { opacity: 0; transition: opacity .5s; }
.r-media video.on { opacity: 1; }
.r-state { position: absolute; top: 8px; left: 8px; z-index: 1; font: 600 10.5px var(--sans); padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .6); color: var(--text); }
.r-state.busy::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); margin-right: 5px; vertical-align: 1px; animation: pulse 1.2s infinite; }
.r-state.done { color: var(--green); }
.r-state.err { color: var(--red); }
@keyframes pulse { 50% { opacity: .3; } }
.r-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .1); }
.r-bar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width 1s linear; }
.r-info { padding: 8px 10px 10px; }
.r-title { font-weight: 600; }
.r-meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.r-meta details { margin-top: 4px; }
.r-actions { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.r-actions:empty { display: none; }
.r-actions .button, .r-actions button { font-size: 11.5px; padding: 3px 9px; }
.r-link { color: var(--muted); font-size: 11.5px; margin-left: auto; }
#lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .86); display: grid; place-items: center; padding: 40px; }
#lightbox video { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
#lightbox .lb-close { position: absolute; top: 16px; right: 16px; font-size: 16px; }

/* ---------------------------------------------------------------- opening an example */
.opening { position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; background: #000; transition: opacity .4s; }
.opening::before { content: ""; position: absolute; inset: -20px; background: var(--poster) center / cover; filter: blur(14px) brightness(.45); }
.opening.out { opacity: 0; }
.opening-card { position: relative; width: min(360px, 80%); padding: 18px 20px; border-radius: 12px; background: rgba(19, 18, 17, .8); border: 1px solid var(--line-2); text-align: center; }
.opening-title { font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.opening-card .progress { height: 4px; }
.opening-detail { margin-top: 8px; font: 11.5px var(--mono); color: var(--muted); }

/* ---------------------------------------------------------------- phones and narrow windows: one scrolling column */
@media (max-width: 900px) {
  body { flex-direction: column; overflow: auto; height: auto; min-height: 100%; }
  #side { display: contents; }   /* its parts join the page column: header, canvas, steps, render bar */
  #head { order: 0; position: sticky; top: 0; z-index: 8; border-bottom: 1px solid var(--line); }
  #main { order: 1; height: min(60vh, 520px); flex: none; }
  #side > .step { order: 2; background: var(--panel); }
  .render-bar { order: 3; }
  body.no-scene #side > .step, body.no-scene .render-bar, body.no-scene #timeline, body.no-scene #canvas, body.no-scene #hintKeys { display: none; }
  body.no-scene #main { height: auto; }
  body.no-scene #stage { overflow: visible; }
  body.no-scene #empty { position: static; overflow: visible; padding: 16px; }
  body.no-scene .empty-card { max-height: none; }
  .ex-grid { grid-template-columns: 1fr 1fr !important; }
  .renders { top: auto; left: 8px; right: 8px; width: auto; height: 46%; }
}
@media (pointer: coarse) { button, select, .seg button { min-height: 40px; } .menu-pop > button, .menu-pop > a { padding: 11px 12px; } }

/* ---------------------------------------------------------------- icons (SVG sprite in index.html) */
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
button.icon { font-family: var(--sans); display: inline-grid; place-items: center; }
.item .acts button { width: 26px; height: 26px; padding: 0; display: grid; place-items: center; border-radius: 6px; }
.item .acts .i { width: 15px; height: 15px; }
.play .i { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- canvas tool bar (bottom centre) */
.tools { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5; display: flex; gap: 4px; padding: 4px;
  border-radius: 999px; background: rgba(19, 18, 17, .78); backdrop-filter: blur(12px); border: 1px solid var(--line-2); }
.tool { height: 36px; min-width: 36px; padding: 0 10px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.tool:hover:not(:disabled) { background: #2a2622; color: var(--text); border: 0; }
.tool.on { background: var(--amber); color: var(--amber-ink); }
.tool .i { width: 17px; height: 17px; }
.tool-menu { position: relative; }
.tool-pop { position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); width: 260px; padding: 10px 12px; border-radius: 12px;
  background: #1d1b19; border: 1px solid var(--line-2); box-shadow: 0 12px 32px rgba(0, 0, 0, .5); }
.tool-pop label { display: grid; grid-template-columns: 90px 1fr 34px; align-items: center; gap: 8px; margin: 6px 0; font-size: 12px; color: var(--muted); }
.tool-pop label.check { display: flex; color: var(--text); }
.tool-pop .val { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- toasts (top centre, stacked) */
.toasts { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 9; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: min(520px, 80vw); padding: 7px 8px 7px 14px; border-radius: 12px;
  background: rgba(29, 27, 25, .96); border: 1px solid var(--line-2); box-shadow: 0 8px 24px rgba(0, 0, 0, .45); font-size: 12.5px; animation: toast-in .16s ease-out; }
.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }
.toast.out { opacity: 0; transform: translateY(-6px); transition: opacity .16s, transform .16s; }
.toast .t-act { font-weight: 600; background: var(--amber); color: var(--amber-ink); border: 0; border-radius: 999px; padding: 4px 10px; }
.toast .t-x { background: transparent; border: 0; color: var(--dim); padding: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------------------------------------------------------------- preview (look through the path camera) */
body.preview #labels, body.preview #pip { opacity: 0; transition: opacity .2s; }
body.preview #renders { display: none; }

/* ---------------------------------------------------------------- timeline: seconds ruler and length presets */
#ruler { position: absolute; left: 20px; right: 20px; top: 36px; height: 8px; pointer-events: none; }
#ruler i { position: absolute; bottom: 0; width: 1px; height: 4px; background: var(--line-2); }
#ruler i.major { height: 7px; background: var(--dim); }
#ruler i[data-t]::after { content: attr(data-t); position: absolute; left: 4px; bottom: -1px; font: 10px var(--sans); color: var(--dim); }
#segLength button { padding: 3px 8px; }
.frames-custom input { width: 52px !important; }
#timeline.empty #ruler, #timeline.empty #segLength { visibility: hidden; }

/* ---------------------------------------------------------------- example grid in the empty state */
.ex-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important; gap: 14px !important; }
.ex-card { position: relative; padding: 0 !important; border-radius: 12px !important; overflow: hidden; text-align: left; }
.ex-media { aspect-ratio: 16 / 10 !important; }
.ex-card .ex-title { position: absolute; left: 12px; right: 12px; bottom: 30px; color: #fff; font-size: 14px; text-shadow: 0 1px 6px rgba(0, 0, 0, .7); z-index: 1; }
.ex-card .ex-desc { position: absolute; left: 12px; right: 12px; bottom: 10px; color: rgba(255, 255, 255, .8); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 1; }
.ex-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgba(0, 0, 0, .78)); pointer-events: none; }
.ex-card:hover { transform: translateY(-2px); }
body.no-scene .render-bar, body.no-scene #step2, body.no-scene #step3 { display: none; }
#timeline.empty .frames-custom { visibility: hidden; }
.ex-card .ex-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.preview .tools { opacity: .35; transition: opacity .2s; }
body.preview .tools:hover { opacity: 1; }

/* ---------------------------------------------------------------- image mode */
.mode-switch { display: flex; width: 100%; }
.mode-switch button { flex: 1; justify-content: center; font-size: 12.5px; padding: 6px 8px; }
.r-media.stills { cursor: zoom-in; }
.r-stills { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #000; }
.r-stills img { position: static; width: 100%; height: 100%; object-fit: cover; filter: none; }
.r-more { position: absolute; right: 8px; bottom: 8px; font: 600 11px var(--sans); padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .65); color: #fff; }
#lightbox .lb-gallery { display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; max-width: 100%; max-height: 100%; padding: 4px; }
#lightbox .lb-gallery figure { margin: 0; flex: none; scroll-snap-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#lightbox .lb-gallery img { max-height: 78vh; max-width: 86vw; border-radius: 8px; }
#lightbox .lb-gallery figcaption { color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- renders: dock, list, detail */
.renders-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-weight: 600;
  background: #221f1b; border-color: #5a4d33; color: var(--text); }
.renders-btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.renders-btn .count { font: 600 11px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.renders-btn.busy { border-color: var(--amber); }
.renders-btn.busy .dot { background: var(--amber); animation: pulse 1.2s infinite; }
.renders-btn.busy .count { color: var(--amber); }
.renders-btn.fresh { border-color: var(--green); background: rgba(159, 211, 138, .12); }
.renders-btn.fresh .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }

.dock { position: absolute; top: 10px; right: 10px; z-index: 6; display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; max-width: 340px;
  border-radius: 14px; background: rgba(19, 18, 17, .9); backdrop-filter: blur(12px); border: 1px solid var(--line-2); box-shadow: 0 8px 28px rgba(0, 0, 0, .45); text-align: left; }
.dock:hover { background: rgba(30, 28, 25, .95); border-color: #5a5249; }
.dock-thumb { position: relative; width: 72px; height: 44px; flex: none; border-radius: 9px; overflow: hidden; background: #000; }
.dock-thumb img, .dock-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.dock-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0, 0, 0, .55); }
.dock-bar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width 1s linear; }
.dock-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.dock-text b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-text span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.dock-count { font: 600 11px var(--mono); min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--muted); }
.dock.busy { border-color: rgba(242, 180, 65, .65); }
.dock.busy .dock-thumb::after { content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: pulse 1.2s infinite; }
.dock.busy .dock-thumb img { filter: brightness(.65) saturate(.7); }
.dock.fresh { border-color: var(--green); animation: dock-glow 1.8s ease-in-out infinite; }
.dock.fresh .dock-text b { color: var(--green); }
.dock.fresh .dock-text b::before { content: "● "; font-size: 10px; vertical-align: 1px; }
.dock.err { border-color: #7a3a30; }
.dock.err .dock-text b { color: var(--red); }
@keyframes dock-glow { 50% { box-shadow: 0 0 0 4px rgba(159, 211, 138, .18), 0 8px 28px rgba(0, 0, 0, .45); } }
body.preview .dock { display: none; }

.renders-head { gap: 6px; }
.renders-head .spacer { flex: 1; }
.renders-head b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result.fresh { border-color: var(--green); box-shadow: 0 0 0 1px rgba(159, 211, 138, .35); }
.r-media .r-poster { filter: blur(2px) brightness(.55); }
.r-media.playable { cursor: pointer; }
.r-media.playable video, .r-media.playable .r-stills { opacity: 1; }
.r-media video { opacity: 1; }
.r-open { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; z-index: 1; pointer-events: none;
  background: rgba(0, 0, 0, .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z' fill='white'/%3E%3C/svg%3E") 55% 50% / 20px no-repeat;
  border: 1px solid rgba(255, 255, 255, .35); opacity: 0; transition: opacity .15s; }
.r-media.playable:not(.stills) .r-open { opacity: .9; }
.result:hover .r-media.playable .r-open { opacity: 0; }
.r-other { position: absolute; top: 8px; right: 8px; z-index: 1; font: 600 10.5px var(--sans); padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .6); color: var(--muted); }
.r-state.done { color: var(--green); }
button.accent { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); font-weight: 600; }
button.accent:hover { background: #ffc65c; border-color: #ffc65c; }
.lbl.res { background: var(--green); color: #0c1a0e; }
.lbl.res.sel { background: var(--amber); color: var(--amber-ink); transform-origin: bottom; }

.renders.detail { width: clamp(420px, 46%, 780px); }
.viewer { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px 12px 14px; }
.v-media { position: relative; background: #000; border-radius: 10px; overflow: hidden; flex: none; }
.v-media video { display: block; width: 100%; max-height: 58vh; background: #000; }
.v-still { position: relative; display: grid; place-items: center; }
.v-still img { display: block; max-width: 100%; max-height: 58vh; cursor: zoom-in; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 22px; line-height: 1;
  background: rgba(0, 0, 0, .55); border-color: rgba(255, 255, 255, .25); color: #fff; opacity: 0; transition: opacity .15s; }
.v-nav.prev { left: 10px; } .v-nav.next { right: 10px; }
.v-still:hover .v-nav { opacity: 1; }
.v-count { position: absolute; left: 10px; bottom: 10px; font: 600 11px var(--mono); padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .6); color: #fff; }
.v-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; flex: none; }
.v-thumb { position: relative; flex: none; width: 92px; height: 56px; padding: 0; border-radius: 7px; overflow: hidden; border: 2px solid transparent; background: #000; }
.v-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .75; }
.v-thumb span { position: absolute; left: 4px; top: 4px; font: 700 10px/1 var(--mono); padding: 2px 4px; border-radius: 3px; background: var(--green); color: #0c1a0e; }
.v-thumb:hover img, .v-thumb.sel img { opacity: 1; }
.v-thumb.sel { border-color: var(--amber); }
.v-thumb.sel span { background: var(--amber); color: var(--amber-ink); }
.v-scene { display: flex; flex-direction: column; gap: 8px; padding: 9px 10px; border-radius: 9px; background: rgba(127, 216, 160, .07); border: 1px solid rgba(127, 216, 160, .28); font-size: 12px; }
.v-scene .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.v-note { color: var(--muted); }
.v-note .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--green); margin-right: 6px; vertical-align: 0; }
.v-scene .blend { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--muted); font-size: 11.5px; }
.v-scene .blend input { width: 90px; }
.v-info .r-actions { margin-top: 8px; }
@media (max-width: 900px) {
  .renders.detail { width: auto; height: 70%; }
  .dock { max-width: 230px; padding: 4px 10px 4px 4px; }
  .dock-thumb { width: 52px; height: 34px; }
}
#stage .tools, #stage .toasts { margin-left: calc(-1 * var(--view-offset, 0px)); }
.renders .result { flex: none; }
.r-stills { grid-template-rows: repeat(2, minmax(0, 1fr)); }
.r-stills img { min-height: 0; }
.r-actions .button { white-space: nowrap; }
