/* video-kit studio. Tokens match the preview site (preview/index.html): cream field, Inter, rust accent, dark mode. */
:root {
  --field: #f1ece1; --ink: #181512; --muted: #6b645b; --accent: #c13b12; --rule: #d8d0c2; --card: #fbf8f2;
  --sunk: #e9e2d4; --ok: #2f6b3a; --bad: #b3261e; --bad-bg: #f7e1dc; --on-ink: #f1ece1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --field: #121110; --ink: #f1ece1; --muted: #a39a8d; --accent: #ffcb3d; --rule: #2c2925; --card: #1a1917;
    --sunk: #0c0b0a; --ok: #8fd19e; --bad: #ff8a7a; --bad-bg: #3a1a15; --on-ink: #121110;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --field: #121110; --ink: #f1ece1; --muted: #a39a8d; --accent: #ffcb3d; --rule: #2c2925; --card: #1a1917;
  --sunk: #0c0b0a; --ok: #8fd19e; --bad: #ff8a7a; --bad-bg: #3a1a15; --on-ink: #121110;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--field); color: var(--ink); font: 15px/1.5 Inter, system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, textarea#json-text { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
[hidden] { display: none !important; }

/* header */
.top { max-width: 1480px; margin: 0 auto; padding: 28px 24px 8px; }
.brandline { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.kicker { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); text-decoration: none; letter-spacing: .02em; }
.kicker::before { content: ""; width: 28px; height: 3px; background: var(--accent); }
.kicker:hover { color: var(--ink); }
.kicker-sep { color: var(--rule); }
.kicker-here { font-weight: 700; letter-spacing: -.01em; font-size: 22px; }
.wip { margin-left: 4px; padding: 2px 10px; border: 1px solid var(--rule); border-radius: 999px; font-size: 12px; color: var(--muted); }
.lead { color: var(--muted); max-width: 640px; margin: 8px 0 0; }

/* page grid: controls beside the preview on desktop, stacked on phones */
.studio { max-width: 1480px; margin: 0 auto; padding: 16px 24px 64px; display: grid; gap: 24px;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr); align-items: start; }
.side { position: sticky; top: 0; max-height: 100vh; overflow-y: auto; padding: 4px 2px 24px; display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); align-items: start; scrollbar-width: thin; }
.controls { display: grid; gap: 16px; min-width: 0; }

.panel { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 16px; min-width: 0; }
.panel h2, .report h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; font-weight: 700; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.start { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 12px; }
.start-label { font-weight: 700; }
.start .hint { grid-column: 1 / -1; margin: 0; }

/* fields */
.field { margin: 0 0 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.label { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 6px; text-transform: capitalize; }
.label .count { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 12px; text-transform: none; }
.label .count.over { color: var(--bad); font-weight: 700; }
.wave { font-size: 11px; text-transform: none; padding: 1px 7px; border-radius: 999px; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.hint.bad { color: var(--bad); }
output.readonly { display: block; padding: 8px 10px; border: 1px dashed var(--rule); border-radius: 8px; font-variant-numeric: tabular-nums; }
.err { font-size: 12.5px; color: var(--bad); margin: 6px 0 0; white-space: pre-wrap; }
.err:empty { display: none; }
.has-err > input, .has-err > textarea, .has-err > select, .has-err > .item-row input { border-color: var(--bad); background: var(--bad-bg); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; margin-bottom: 14px; }
.grid2 > .field { margin-bottom: 0; }
.grid2 > .wide { grid-column: 1 / -1; }

input[type="text"], input[type="number"], select, textarea {
  width: 100%; min-width: 0; background: var(--field); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; outline: none; }
textarea { resize: vertical; min-height: 44px; line-height: 1.4; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
select { appearance: none; padding-right: 28px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }

/* segmented buttons */
.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--sunk); border-radius: 10px; }
.seg button { flex: 1 1 auto; border: 0; background: transparent; border-radius: 7px; padding: 6px 10px; cursor: pointer; white-space: nowrap;
  font-size: 13.5px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg button:hover:not(:disabled) { background: var(--card); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); font-weight: 600; }
.seg button:disabled { color: var(--muted); opacity: .6; cursor: not-allowed; }
.seg small { font-size: 10.5px; padding: 0 5px; border: 1px solid var(--rule); border-radius: 999px; }

.accent { display: grid; grid-template-columns: 40px 1fr auto; gap: 8px; align-items: center; }
.accent input[type="color"] { width: 40px; height: 38px; padding: 2px; border: 1px solid var(--rule); border-radius: 8px; background: var(--field); cursor: pointer; }
.accent input[type="text"] { text-transform: uppercase; font-variant-numeric: tabular-nums; }

.btn { border: 1px solid var(--rule); background: var(--card); border-radius: 999px; padding: 8px 16px; cursor: pointer; font-size: 14px; font-weight: 600; }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #121110; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #121110; } }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { border: 0; background: none; padding: 4px 2px; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 600; }
.link:disabled { color: var(--muted); opacity: .6; cursor: default; }
.icon { width: 30px; height: 30px; border: 1px solid transparent; background: none; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; }
.icon:hover:not(:disabled) { border-color: var(--rule); color: var(--ink); background: var(--field); }
.icon:disabled { opacity: .3; cursor: default; }

details.more { border-top: 1px dashed var(--rule); margin-top: 14px; padding-top: 10px; }
details.more summary { cursor: pointer; font-weight: 600; font-size: 13.5px; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+"; display: inline-block; width: 16px; color: var(--accent); font-weight: 700; }
details.more[open] summary::before { content: "−"; }
details.more summary .hint { font-weight: 400; margin: 0; }
.more-body { padding-top: 12px; }
.group .checks { display: flex; gap: 16px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 4px; font-size: 13.5px; }
.group .sub { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: center; font-size: 13.5px; margin-bottom: 6px; }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--sunk); border-radius: 999px; }
.tabs button { border: 0; background: none; padding: 4px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--on-ink); font-weight: 600; }
textarea#json-text { min-height: 420px; line-height: 1.45; white-space: pre; tab-size: 2; }

/* scene list */
.scene-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
#scenes, #json, .scene, .scene-body { min-width: 0; }
.scene { border: 1px solid var(--rule); border-radius: 10px; background: var(--field); }
.scene.open { border-color: var(--ink); }
.scene.has-err { border-color: var(--bad); }
.scene > .err { margin: 0 12px 8px; }
.scene-head { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 4px; }
.scene-toggle { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 8px; cursor: pointer; text-align: left; border-radius: 8px; }
.scene-toggle .num { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); font-size: 12px; font-weight: 700; }
.scene.now .scene-toggle .num { background: var(--accent); color: #fff; }
.scene-toggle .beat { flex: none; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.scene-toggle .sum { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.scene-toggle .into { flex: none; font-size: 11.5px; color: var(--muted); border: 1px solid var(--rule); border-radius: 999px; padding: 1px 8px; }
.tools { display: flex; flex: none; }
.scene-body { padding: 4px 12px 14px; border-top: 1px solid var(--rule); padding-top: 14px; }
.show { margin-bottom: 14px; }
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; counter-reset: it; }
.items li { counter-increment: it; }
.item-row { display: grid; grid-template-columns: 22px 1fr 30px; gap: 6px; align-items: center; }
.item-row::before { content: counter(it); font-size: 12px; color: var(--muted); text-align: right; }
.add { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.add .hint { margin: 0 4px 0 0; }

/* preview */
.preview > * { min-width: 0; }
.preview { min-width: 0; display: grid; gap: 10px; justify-items: center; }
.screen-wrap { width: 100%; display: flex; justify-content: center; }
.screen { position: relative; overflow: hidden; border-radius: 10px; background: #000; box-shadow: 0 0 0 1px var(--rule), 0 12px 40px -18px rgba(0,0,0,.45);
  width: 360px; aspect-ratio: 9 / 16; }
.screen iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; background: transparent; pointer-events: none; }
.screen iframe.loading { visibility: hidden; }
.status { position: absolute; z-index: 2; left: 10px; right: 10px; bottom: 10px; padding: 7px 12px; border-radius: 8px; font-size: 13px;
  background: rgba(24,21,18,.86); color: #f1ece1; backdrop-filter: blur(6px); }
.status:empty, .status.ok { display: none; }
.status.building { left: auto; right: 10px; bottom: auto; top: 10px; }
.status.invalid, .status.error { background: var(--bad); color: #fff; }
.status.warn { background: #8a5a00; color: #fff; }
.now-line { font-size: 13px; color: var(--muted); min-height: 20px; text-align: center; }

.transport { width: 100%; max-width: 620px; display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; }
.play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--ink); color: var(--on-ink); cursor: pointer; display: grid; place-items: center; }
.play svg { width: 16px; height: 16px; fill: currentColor; }
.play .i-pause, .play.on .i-play { display: none; }
.play.on .i-pause { display: inline; }
.time { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 92px; text-align: right; }
.track { position: relative; height: 34px; }
.lanes { position: absolute; inset: 6px 0; border-radius: 6px; overflow: hidden; background: var(--sunk); }
.lane { position: absolute; top: 0; bottom: 0; border-right: 2px solid var(--field); background: var(--card); }
.lane span { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); font-size: 10.5px; font-weight: 700; color: var(--muted); }
.lane.bad { background: var(--bad-bg); }
.lane.bad span { color: var(--bad); }
.join { position: absolute; bottom: 0; height: 4px; background: var(--accent); opacity: .85; }
.join.cut { width: 2px !important; height: 100%; opacity: .5; }
.track input[type="range"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer; }
.track input[type="range"]::-webkit-slider-runnable-track { height: 100%; background: transparent; }
.track input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 3px; height: 34px; background: var(--ink); border-radius: 2px; box-shadow: 0 0 0 2px var(--field); }
.track input[type="range"]::-moz-range-thumb { width: 3px; height: 34px; background: var(--ink); border: 0; border-radius: 2px; }
.track input[type="range"]::-moz-range-track { background: transparent; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.render-panel { min-width: 0; overflow: hidden; width: 100%; max-width: 620px; background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.render-panel p { margin: 0 0 8px; }
.render-panel pre { margin: 0 0 10px; max-height: 220px; overflow: auto; background: var(--sunk); border-radius: 8px; padding: 10px; white-space: pre; }
.rendered { width: 100%; max-height: 60vh; border-radius: 8px; background: #000; }

/* report */
.report { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 14px; font-size: 13.5px; min-width: 0; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.report-head h2 { margin: 0; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pill { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--rule); font-size: 12.5px; white-space: nowrap; }
.pill.ok { border-color: var(--ok); color: var(--ok); font-weight: 600; }
.pill.bad { border-color: var(--bad); color: var(--bad); font-weight: 600; background: var(--bad-bg); }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rows li { border-top: 1px solid var(--rule); padding-top: 8px; }
.rows li.nofit { border-left: 3px solid var(--bad); padding-left: 8px; }
.row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-head .num { width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--sunk); font-size: 11.5px; font-weight: 700; cursor: pointer; }
.row-head .num:hover { background: var(--ink); color: var(--on-ink); }
.tag { font-size: 11.5px; padding: 0 8px; border-radius: 999px; }
.tag.ok { color: var(--ok); border: 1px solid var(--ok); }
.tag.bad { color: #fff; background: var(--bad); }
.right { margin-left: auto; }
.muted { color: var(--muted); }
.detail { margin: 3px 0 0 30px; color: var(--ink); overflow-wrap: anywhere; }
.note { border-radius: 8px; padding: 8px 10px; background: var(--sunk); margin-bottom: 10px; }
.note.bad { background: var(--bad-bg); color: var(--ink); }
.note ul { margin: 6px 0 0; padding-left: 18px; }

/* narrower desktops: report under the preview */
@media (max-width: 1240px) {
  .side { grid-template-columns: minmax(0, 1fr); }
}
/* phones and tablets: one column, preview first */
@media (max-width: 959px) {
  .top { padding: 20px 16px 4px; }
  .studio { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 48px; gap: 16px; }
  .side { display: contents; }
  .preview { order: -1; }
  .report { order: 1; }
  .grid2 { grid-template-columns: 1fr; gap: 14px; }
  .scene-toggle .into { display: none; }
  .lead { font-size: 14px; }
  textarea#json-text { min-height: 320px; }
}
