/* Vizmatic Studio. Dense, calm, and keyboard-first. The film is the brightest thing on screen. */
@font-face { font-family: Inter; src: url("assets/fonts/Inter-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Inter; src: url("assets/fonts/Inter-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("assets/fonts/JetBrainsMono-Regular.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Source Serif 4"; src: url("assets/studio/assets/fonts/SourceSerif4-24pt-Regular.ttf") format("truetype"); font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #0c0d10; --panel: #131418; --panel-2: #191a1f; --panel-3: #212329; --stage-bg: #08090b;
  --line: #24262c; --line-strong: #383b43;
  --text: #dcdde0; --text-dim: #8d9099; --text-faint: #5f626b;
  --accent: #ffd75e; --accent-ink: #191400; --accent-soft: #ffd75e1f;
  --error: #ff7b7b; --error-soft: #ff7b7b1f;
  --enter: #4fd8c4; --exit: #ff8d84; --change: #5cc4f0; --emphasis: #f2b84b; --value: #ff9d57;
  --ui: 12px/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body.studio-page { background: var(--bg); color: var(--text); font: var(--ui); overflow: hidden; -webkit-font-smoothing: antialiased; }
.studio-loading { display: grid; place-items: center; height: 100%; color: var(--text-faint); font-family: var(--mono); }
.studio-noscript { position: fixed; inset: auto 0 0 0; margin: 0; padding: 16px; background: var(--panel); }
.studio-noscript a { color: var(--accent); }
.studio-narrow { display: none; }
@media (max-width: 819px) {
  /* The editor is three panels and a timeline, which cannot fit a phone. Say so instead of overflowing. */
  #studio, .studio { display: none !important; }
  .studio-narrow { display: grid; align-content: center; gap: 16px; height: 100%; padding: 32px; box-sizing: border-box; }
  .studio-narrow h1 { margin: 0; font: 400 40px/1.1 "Source Serif 4", Georgia, serif; }
  .studio-narrow p { margin: 0; color: var(--text-dim, var(--text)); font-size: 15px; line-height: 1.5; }
  .studio-narrow a { color: var(--accent); margin-right: 16px; }
}
body.is-dragging { user-select: none; cursor: grabbing; }
body.is-resizing-row { cursor: row-resize; }
body.is-resizing-col { cursor: col-resize; }
body.is-scrubbing { cursor: ew-resize; user-select: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 1.5px solid var(--accent); outline-offset: -1px; }
kbd { font: 10px/1 var(--mono); color: var(--text-dim); background: var(--panel-3); border-radius: 3px; padding: 3px 5px; white-space: nowrap; }
.icon { display: block; flex: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border: 3px solid transparent; background-clip: padding-box; border-radius: 6px; }
::-webkit-scrollbar-corner { background: transparent; }

/* Layout */
.studio { height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: 40px minmax(0, 1fr) 0 var(--bottom-height, 252px); }
.topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 0 8px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.topbar-left, .topbar-center, .topbar-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.topbar-right { justify-content: flex-end; }
.topbar-center { gap: 8px; }
.studio-brand { display: flex; align-items: center; gap: 7px; padding: 0 8px 0 4px; color: var(--text); text-decoration: none; font-weight: 600; }
.bar-divider { width: 1px; height: 18px; background: var(--line); margin: 0 6px; flex: none; }
.project-name { background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; min-width: 60px; width: 220px; color: var(--text); text-overflow: ellipsis; }
.project-name:hover { border-color: var(--line); }
.project-name:focus { background: var(--panel-2); border-color: var(--line-strong); outline: none; }
.bar-select { height: 26px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 22px 0 8px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-size: 4px 4px, 4px 4px; background-position: right 11px center, right 7px center; background-repeat: no-repeat; }
.bar-select:disabled { opacity: .45; }
.segmented { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px; }
.segment { background: none; border: 0; padding: 3px 11px; border-radius: 3px; color: var(--text-dim); }
.segment.is-active { background: var(--panel-3); color: var(--text); }
.search-button { display: flex; align-items: center; gap: 7px; height: 26px; padding: 0 6px 0 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; color: var(--text-dim); margin-right: 4px; }
.search-button:hover { color: var(--text); border-color: var(--line-strong); }
.workspace { display: flex; min-height: 0; min-width: 0; }
.left-panel, .right-panel, .code-pane { background: var(--panel); min-height: 0; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.left-panel { flex: none; width: var(--left-width, 232px); border-right: 1px solid var(--line); }
.right-panel { flex: none; width: var(--right-width, 288px); border-left: 1px solid var(--line); }
.code-pane { display: none; flex: none; width: var(--code-width, 560px); border-right: 1px solid var(--line); }
.is-code .code-pane { display: flex; }
.is-code .left-panel, .is-code .right-panel { display: none; }
.center { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; background: var(--stage-bg); }
.resizer { position: relative; z-index: 5; flex: none; width: 0; }
.resizer.is-bottom { width: auto; height: 0; }
.resizer::after { content: ""; position: absolute; }
.resizer.is-left::after, .resizer.is-right::after, .resizer.is-code::after { inset: 0 -3px; cursor: col-resize; }
.resizer.is-bottom::after { inset: -3px 0; cursor: row-resize; }
.resizer:hover::after { background: var(--accent-soft); }
.is-code .resizer.is-left, .is-code .resizer.is-right { display: none; }
.resizer.is-code { display: none; }
.is-code .resizer.is-code { display: block; }

/* Controls */
.icon-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 26px; height: 26px; padding: 0 5px; background: none; border: 0; border-radius: 4px; color: var(--text-dim); }
.icon-button:hover:not(:disabled) { background: var(--panel-3); color: var(--text); }
.icon-button.is-active { color: var(--accent); }
.text-button { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; background: none; border: 1px solid transparent; border-radius: 4px; color: var(--text); text-decoration: none; white-space: nowrap; }
.text-button:hover { background: var(--panel-3); }
.text-button.is-primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.text-button.is-primary:hover { background: #ffe07e; }
.text-button.is-accent { color: var(--accent); }
.panel-label { margin: 0; font: 600 10px/1.2 Inter, sans-serif; letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint); }
.panel-section { padding: 10px; border-bottom: 1px solid var(--line); }
.panel-section.is-palette { flex: 0 1 auto; max-height: 56%; overflow-y: auto; }
.panel-section.is-fill { flex: 1 1 120px; min-height: 110px; display: flex; flex-direction: column; padding: 0; border-bottom: 0; }
.panel-head { padding: 10px 10px 6px; }
.empty-hint { margin: 0; padding: 8px 10px; color: var(--text-faint); line-height: 1.5; }

/* Palette */
.palette { display: flex; flex-direction: column; gap: 10px; }
.palette-group .panel-label { margin-bottom: 6px; }
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 1px; }
.palette-item { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 1px 5px; background: none; border: 0; border-radius: 4px; color: var(--text-dim); font-size: 10px; line-height: 1.1; text-align: center; touch-action: none; }
.palette-item:hover { background: var(--panel-3); color: var(--text); }
.palette-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 100; padding: 4px 8px; background: var(--panel-3); border: 1px solid var(--line-strong); border-radius: 4px; pointer-events: none; color: var(--text-dim); }
.drag-ghost.is-over { border-color: var(--accent); color: var(--text); }

/* Layers */
.layer-list { flex: 1; overflow: auto; padding-bottom: 8px; }
.layer-row { display: flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 10px; color: var(--text-dim); cursor: default; }
.layer-row:hover { background: var(--panel-2); }
.layer-row.is-selected { background: var(--accent-soft); color: var(--text); }
.layer-row.is-hidden .layer-name { opacity: .45; }
.layer-row.has-error .layer-kind { background: var(--error-soft); color: var(--error); }
.layer-kind { flex: none; width: 15px; height: 15px; display: grid; place-items: center; border-radius: 3px; background: var(--panel-3); color: var(--text-faint); font: 9px var(--mono); }
.layer-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-rename { flex: 1; min-width: 0; height: 20px; padding: 0 4px; background: var(--bg); border: 1px solid var(--accent); border-radius: 3px; outline: none; }
.layer-toggle { flex: none; display: grid; place-items: center; width: 20px; height: 20px; padding: 0; background: none; border: 0; border-radius: 3px; color: var(--text-faint); opacity: 0; }
.layer-row:hover .layer-toggle, .layer-toggle.is-on { opacity: 1; }
.layer-toggle:hover { color: var(--text); background: var(--panel-3); }
.layer-toggle.is-on { color: var(--accent); }

/* Stage */
.stage-panel { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; }
.stage-viewport { flex: 1; min-width: 0; min-height: 0; overflow: auto; display: flex; padding: 28px; }
.stage-sheet { position: relative; margin: auto; flex: none; box-shadow: 0 0 0 1px #000, 0 24px 60px #0009; background: #000; }
.stage-canvas { display: block; width: 100%; height: 100%; }
.sandbox-slot { position: absolute; inset: 0; }
.sandbox-frame { display: block; width: 100%; height: 100%; border: 0; }
.stage-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.stage-input { position: absolute; inset: -26px; cursor: default; touch-action: none; }
.is-code .stage-input { display: none; }
.stage-hud { position: absolute; right: 8px; bottom: 6px; }
.zoom-label { background: none; border: 0; font: 10px var(--mono); color: var(--text-faint); padding: 3px 5px; border-radius: 3px; }
.zoom-label:hover { color: var(--text); background: var(--panel-3); }
.select-box, .union-box { fill: none; stroke: var(--accent); stroke-width: 1; vector-effect: non-scaling-stroke; }
.select-box.is-offstage { stroke-dasharray: 4 4; }
.select-box.has-error { stroke: var(--error); }
.union-box { stroke-dasharray: 3 3; opacity: .6; }
.ghost-box { fill: none; stroke: #ffffff30; stroke-width: 1; stroke-dasharray: 3 4; }
.size-handle { fill: #fff; stroke: #3a3000; stroke-width: 1; }
.rotate-handle { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; }
.rotate-stem { stroke: var(--accent); stroke-width: 1; opacity: .7; }
.select-label { fill: var(--accent); font: 10px Inter, sans-serif; paint-order: stroke; stroke: #000a; stroke-width: 2px; }
.snap-guide { stroke: #ff6f91; stroke-width: 1; }
.marquee { fill: #ffd75e14; stroke: var(--accent); stroke-width: 1; }

/* Inspector */
.tabs { display: flex; gap: 2px; padding: 5px 8px; border-bottom: 1px solid var(--line); flex: none; }
.tab { background: none; border: 0; padding: 4px 8px; border-radius: 4px; color: var(--text-dim); }
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--panel-3); color: var(--text); }
.inspector-body { flex: 1; min-height: 0; overflow: auto; }
.inspector-code { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.inspector-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px; }
.object-title { flex: 1; min-width: 0; padding: 3px 5px; margin-left: -5px; background: none; border: 1px solid transparent; border-radius: 4px; font-size: 13px; font-weight: 600; }
.object-title:hover { border-color: var(--line); }
.object-title:focus { outline: none; background: var(--panel-2); border-color: var(--line-strong); }
.beat-name { flex: 1; font-size: 13px; }
.kind-tag { flex: none; font-size: 10px; color: var(--text-faint); }
.head-actions { display: flex; margin: -4px -4px -4px 0; }
.kind-tag.group-enter { color: var(--enter); } .kind-tag.group-exit { color: var(--exit); } .kind-tag.group-change { color: var(--change); } .kind-tag.group-emphasis { color: var(--emphasis); } .kind-tag.group-value { color: var(--value); }
.inspector-error, .field-error { margin: 0; padding: 6px 8px; font-size: 11px; line-height: 1.4; color: var(--error); background: var(--error-soft); border-radius: 3px; }
.inspector-error { margin: 0 10px 8px; overflow-wrap: anywhere; }
.field-error { margin-top: 4px; }
.inspector-section { display: flex; flex-direction: column; gap: 7px; padding: 10px; border-top: 1px solid var(--line); }
.beat-inspector { border-bottom: 2px solid var(--line-strong); }
.field-stack { display: flex; flex-direction: column; gap: 5px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
.field-grid .field { grid-template-columns: 46px minmax(0, 1fr); }
.field { display: grid; grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: 2px 6px; min-height: 24px; }
.field.is-full { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
.field-help { grid-column: 1 / -1; margin: 0; font-size: 10.5px; line-height: 1.4; color: var(--text-faint); }
.field-label { color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field-label.is-scrub { cursor: ew-resize; touch-action: none; user-select: none; }
.field-label.is-scrub:hover { color: var(--accent); }
.field-control { min-width: 0; }
.field-input { display: block; width: 100%; min-height: 24px; padding: 3px 6px; background: var(--panel-2); border: 1px solid transparent; border-radius: 3px; outline: none; }
.field-input:hover { border-color: var(--line); }
.field-input:focus { border-color: var(--accent); background: var(--bg); }
.field-input.mono, textarea.field-input.mono { font: 11.5px/1.45 var(--mono); }
.field-input.num { font: 11.5px var(--mono); font-variant-numeric: tabular-nums; }
.field-input.is-invalid { border-color: var(--error); }
textarea.field-input { resize: vertical; line-height: 1.4; }
select.field-input { appearance: none; padding-right: 18px; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-size: 4px 4px, 4px 4px; background-position: right 10px center, right 6px center; background-repeat: no-repeat; }
.switch { appearance: none; display: block; width: 26px; height: 15px; margin: 0; background: var(--panel-3); border-radius: 8px; position: relative; cursor: pointer; transition: background .12s; }
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 11px; height: 11px; border-radius: 50%; background: var(--text-dim); transition: transform .12s, background .12s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(11px); background: var(--accent-ink); }
.color-button { display: flex; align-items: center; gap: 6px; text-align: left; }
.swatch { flex: none; width: 13px; height: 13px; border-radius: 3px; box-shadow: inset 0 0 0 1px #ffffff26; }
.swatch.is-none { background: linear-gradient(135deg, transparent 45%, var(--error) 45% 55%, transparent 55%) !important; }
.color-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.color-popover { display: flex; flex-direction: column; gap: 7px; width: 186px; padding: 8px; }
.color-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.color-chip { aspect-ratio: 1; padding: 0; border: 0; border-radius: 3px; box-shadow: inset 0 0 0 1px #ffffff26; }
.color-chip:hover { outline: 1.5px solid var(--text); outline-offset: 1px; }
.color-chip.is-current { outline: 1.5px solid var(--accent); outline-offset: 1px; }
.color-chip.is-none { background: linear-gradient(135deg, var(--panel-2) 45%, var(--error) 45% 55%, var(--panel-2) 55%); }
.tex-field, .expr-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.tex-preview { display: block; width: 100%; height: auto; background: var(--bg); border-radius: 3px; }
.button-row { display: flex; flex-wrap: wrap; gap: 2px; }
.beat-list { display: flex; flex-direction: column; gap: 2px; }
.beat-chip { display: flex; justify-content: space-between; padding: 4px 7px 4px 9px; background: var(--panel-2); border: 0; border-left: 2px solid var(--change); border-radius: 2px; text-align: left; color: var(--text); }
.beat-chip:hover { background: var(--panel-3); }
.beat-chip.is-selected { background: var(--panel-3); outline: 1px solid var(--accent); }
.beat-chip.group-enter { border-left-color: var(--enter); } .beat-chip.group-exit { border-left-color: var(--exit); } .beat-chip.group-emphasis { border-left-color: var(--emphasis); } .beat-chip.group-value { border-left-color: var(--value); }
.beat-time { font: 10.5px var(--mono); color: var(--text-faint); }
.quick-beats { display: flex; flex-wrap: wrap; gap: 3px; }
.chip { padding: 3px 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 3px; color: var(--text-dim); }
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.is-more { color: var(--accent); }
.ease-button { display: flex; align-items: center; gap: 6px; text-align: left; }
.ease-curve { display: block; flex: none; }
.ease-curve polyline { fill: none; stroke: var(--accent); stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.ease-grid { display: grid; grid-template-columns: repeat(4, 66px); gap: 2px; padding: 6px; }
.ease-option { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 2px; background: none; border: 0; border-radius: 3px; color: var(--text-dim); font-size: 10px; }
.ease-option:hover { background: var(--panel-3); color: var(--text); }
.ease-option.is-current { background: var(--accent-soft); color: var(--text); }
.variable-list { display: flex; flex-direction: column; gap: 4px; }
.variable-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 4px; }
.variable-row code { font: 12px var(--mono); color: var(--accent); }
.variable-row .field { grid-template-columns: 38px minmax(0, 1fr); }

/* Popovers and menus */
.popover { position: fixed; z-index: 60; background: var(--panel-2); border: 1px solid var(--line-strong); border-radius: 6px; box-shadow: 0 14px 40px #000b; overflow: auto; max-height: calc(100vh - 16px); }
.menu { display: flex; flex-direction: column; min-width: 210px; padding: 4px; }
.menu hr { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
.menu-item { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 5px 8px; background: none; border: 0; border-radius: 3px; color: var(--text); text-align: left; text-decoration: none; }
.menu-item:hover { background: var(--panel-3); }
.marker-popover { display: flex; flex-direction: column; gap: 6px; width: 220px; padding: 8px; }
.beat-picker { width: 540px; padding: 8px 6px; columns: 2; column-gap: 8px; }
.picker-title { margin: 2px 6px 6px; font-weight: 600; column-span: all; }
.beat-picker .panel-label { margin: 8px 6px 3px; break-after: avoid; }
.beat-picker .panel-label:first-of-type { margin-top: 0; }
.picker-item { display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 4px 6px 4px 8px; background: none; border: 0; border-left: 2px solid var(--change); border-radius: 2px; text-align: left; margin-bottom: 1px; break-inside: avoid; }
.picker-item:hover { background: var(--panel-3); }
.picker-item.group-enter { border-left-color: var(--enter); } .picker-item.group-exit { border-left-color: var(--exit); } .picker-item.group-emphasis { border-left-color: var(--emphasis); } .picker-item.group-value { border-left-color: var(--value); }
.picker-name { display: flex; justify-content: space-between; color: var(--text); }
.picker-name em { font-style: normal; font-size: 10px; color: var(--accent); }
.picker-hint { font-size: 10.5px; color: var(--text-faint); }

/* Timeline */
.timeline { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-top: 1px solid var(--line); }
.tl-bar { flex: none; display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 8px; border-bottom: 1px solid var(--line); overflow: hidden; }
.tl-group { display: flex; align-items: center; gap: 2px; flex: none; }
.tl-spacer { flex: 1; }
.tl-readout { gap: 5px; font: 11.5px var(--mono); font-variant-numeric: tabular-nums; }
.tl-time { width: 66px; height: 22px; padding: 0 5px; background: var(--bg); border: 1px solid transparent; border-radius: 3px; color: var(--accent); font: inherit; outline: none; }
.tl-time:focus { border-color: var(--accent); }
.tl-sep { color: var(--text-faint); }
.tl-duration { color: var(--text-dim); }
.tl-frame { margin-left: 6px; color: var(--text-faint); font-size: 10.5px; }
.tl-select { height: 22px; background: var(--panel-2); border: 0; border-radius: 3px; padding: 0 2px; color: var(--text-dim); font: 11px var(--mono); }
.tl-zoom { width: 88px; accent-color: var(--text-dim); height: 12px; }
.play-button { color: var(--text); }
.tl-scroller { flex: 1; min-height: 0; overflow: auto; position: relative; touch-action: none; }
.tl-content { position: relative; min-width: 100%; min-height: 100%; }
.tl-ruler-row { position: sticky; top: 0; z-index: 3; display: flex; height: 28px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.tl-corner { position: sticky; left: 0; z-index: 4; flex: none; width: 164px; display: flex; align-items: center; padding: 0 10px; background: var(--panel-2); border-right: 1px solid var(--line); font: 600 10px Inter, sans-serif; letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint); }
.tl-ruler { position: sticky; left: 164px; display: block; cursor: ew-resize; touch-action: none; }
.tl-row { display: flex; border-bottom: 1px solid #1c1e23; }
.tl-row.is-selected .tl-lane { background: #ffffff05; }
.tl-name { position: sticky; left: 0; z-index: 2; flex: none; width: 164px; display: flex; align-items: center; gap: 3px; padding: 0 3px 0 4px; min-height: 24px; background: var(--panel); border-right: 1px solid var(--line); color: var(--text-dim); cursor: default; }
.tl-name.is-selected { color: var(--text); background: #1d1c16; }
.tl-grip { flex: none; width: 8px; height: 14px; cursor: grab; opacity: 0; background-image: radial-gradient(var(--text-faint) 1px, transparent 1px); background-size: 3px 3px; touch-action: none; }
.tl-name:hover .tl-grip:not(.is-empty) { opacity: 1; }
.tl-name-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 2px; }
.tl-add { flex: none; display: grid; place-items: center; width: 18px; height: 18px; padding: 0; background: none; border: 0; border-radius: 3px; color: var(--text-faint); opacity: 0; }
.tl-name:hover .tl-add { opacity: 1; }
.tl-add:hover { background: var(--panel-3); color: var(--accent); }
.tl-lane { position: relative; flex: 1; min-width: 0; }
.tl-clip { position: absolute; height: 20px; display: flex; align-items: center; overflow: hidden; background: #5cc4f02b; border-left: 2px solid var(--change); border-radius: 2px; color: #cfeefb; font-size: 10.5px; cursor: grab; touch-action: none; }
.tl-clip:hover { filter: brightness(1.2); }
.tl-clip.group-enter { background: #4fd8c426; border-left-color: var(--enter); color: #c6f5ee; }
.tl-clip.group-exit { background: #ff8d8424; border-left-color: var(--exit); color: #ffd9d5; }
.tl-clip.group-emphasis { background: #f2b84b26; border-left-color: var(--emphasis); color: #fbe6bb; }
.tl-clip.group-value { background: #ff9d5726; border-left-color: var(--value); color: #ffe0c9; }
.tl-clip.is-selected { outline: 1.5px solid var(--accent); outline-offset: -1px; z-index: 1; }
.tl-clip.has-error { outline: 1.5px solid var(--error); outline-offset: -1px; }
.tl-clip.is-readonly { cursor: default; }
.tl-clip.is-instant { width: 12px !important; background: none; border: 0; }
.tl-clip.is-instant::before { content: ""; position: absolute; left: 2px; top: 6px; width: 8px; height: 8px; background: var(--enter); transform: rotate(45deg); }
.tl-clip.is-instant.group-exit::before { background: var(--exit); }
.tl-clip-label { flex: 1; min-width: 0; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.tl-edge { position: absolute; top: 0; bottom: 0; width: 6px; cursor: ew-resize; touch-action: none; z-index: 1; }
.tl-edge.is-left { left: -2px; }
.tl-edge.is-right { right: 0; }
.tl-edge:hover { background: #ffffff30; }
.tl-playhead { position: absolute; left: 0; top: 0; width: 1px; background: var(--accent); pointer-events: none; z-index: 2; will-change: transform; }
.tl-empty { position: sticky; left: 164px; padding: 16px; color: var(--text-faint); }
.timeline.is-readonly .tl-add, .timeline.is-readonly .tl-grip, .timeline.is-readonly .edit-only { display: none; }

/* Code */
.code-bar { flex: none; display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 6px 0 10px; border-bottom: 1px solid var(--line); }
.code-note { color: var(--text-faint); font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.generated-code { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.code-editor { flex: 1; min-height: 0; display: grid; grid-template-columns: 40px minmax(0, 1fr); overflow: hidden; background: var(--bg); font: 12px/18px var(--mono); }
.code-gutter { padding: 10px 8px 10px 0; text-align: right; color: var(--text-faint); user-select: none; overflow: visible; will-change: transform; }
.code-line-number { height: 18px; font-size: 10.5px; }
.code-line-number.has-error { color: var(--accent-ink); background: var(--error); border-radius: 2px; }
.code-body { position: relative; min-width: 0; overflow: hidden; }
.code-highlight, .code-input { position: absolute; inset: 0; margin: 0; padding: 10px 12px; font: inherit; tab-size: 4; white-space: pre; }
.code-highlight { pointer-events: none; color: #d9dade; will-change: transform; right: auto; bottom: auto; min-width: 100%; }
.code-input { width: 100%; height: 100%; resize: none; border: 0; outline: none; background: transparent; color: transparent; caret-color: var(--accent); overflow: auto; }
.code-input::selection { background: #ffd75e40; }
.syntax-comment { color: #6d717b; } .syntax-keyword { color: #ffb178; } .syntax-string { color: #a8e0a0; } .syntax-literal { color: #ff9ca8; } .syntax-number { color: #ffd75e; } .syntax-tag { color: #7dd9c1; } .syntax-attribute { color: #8fd0f2; } .syntax-operator { color: #b7b9c0; } .syntax-punctuation { color: #8d9099; }
.code-problem { flex: none; padding: 7px 10px; border-top: 1px solid var(--line); background: var(--error-soft); color: var(--error); font: 11.5px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 110px; overflow: auto; }
.code-logs { flex: none; max-height: 100px; overflow: auto; font: 11px/1.5 var(--mono); }
.code-log { padding: 1px 10px; color: var(--text-dim); border-top: 1px solid #1c1e23; overflow-wrap: anywhere; }
.code-log.is-warn { color: var(--emphasis); } .code-log.is-error { color: var(--error); }
.code-paused { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 10px; background: var(--accent-soft); color: var(--text); }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: #05060799; padding: 20px; }
.modal-backdrop.is-top { place-items: start center; padding-top: 12vh; }
.modal { max-width: 100%; max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 24px 80px #000c; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 9px 8px 9px 14px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 13px; font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 6px; }
.command-palette { width: 540px; max-width: 100%; }
.command-input { width: 100%; padding: 12px 14px; background: none; border: 0; border-bottom: 1px solid var(--line); outline: none; font-size: 14px; }
.command-list { max-height: 50vh; overflow: auto; padding: 4px; }
.command-item { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; background: none; border: 0; border-radius: 3px; text-align: left; }
.command-item.is-current { background: var(--panel-3); }
.command-group { font-size: 10.5px; color: var(--text-faint); }
.shortcut-sheet { display: grid; grid-template-columns: repeat(3, 270px); gap: 16px 22px; padding: 14px; max-height: 76vh; overflow: auto; }
.shortcut-group { display: flex; flex-direction: column; gap: 3px; }
.shortcut-group .panel-label { margin-bottom: 4px; }
.shortcut-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 22px; color: var(--text-dim); }
.share-dialog { display: flex; flex-direction: column; gap: 10px; width: 480px; max-width: 100%; padding: 14px; }
.export-dialog { display: flex; flex-direction: column; gap: 12px; width: 440px; max-width: 100%; padding: 14px; }
.export-formats { display: flex; gap: 2px; background: var(--panel-2); padding: 2px; border-radius: 5px; }
.format-tab { flex: 1; padding: 5px 2px; background: none; border: 0; border-radius: 3px; color: var(--text-dim); white-space: nowrap; }
.format-tab:hover { color: var(--text); }
.format-tab.is-active { background: var(--panel-3); color: var(--text); }
.export-hint { min-height: 15px; }
.export-grid { display: flex; flex-direction: column; gap: 6px; }
.export-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 8px; }
.progress { height: 3px; background: var(--panel-3); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); }
.export-status { margin: 0; min-height: 16px; color: var(--text-dim); line-height: 1.45; overflow-wrap: anywhere; }

/* Welcome: the one place with some ceremony */
.modal-backdrop.is-welcome { background: #06070a; padding: 0; place-items: stretch; }
.is-welcome .modal { width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; background: radial-gradient(1000px 460px at 50% -120px, #1a1b22 0%, #0a0b0e 66%); box-shadow: none; }
.welcome { width: min(1180px, 100%); margin: 0 auto; padding: 64px 40px 80px; }
.welcome-head { margin-bottom: 28px; }
.welcome-title { margin: 0; font: 400 74px/1.02 "Source Serif 4", Georgia, serif; letter-spacing: -.012em; color: #f4f1e8; }
.welcome-lede { margin: 14px 0 0; max-width: 620px; font-size: 15px; line-height: 1.55; color: var(--text-dim); }
.welcome-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 44px; }
.welcome-actions .text-button { height: 30px; }
.welcome-section { margin-bottom: 40px; }
.welcome-section > .panel-label { margin-bottom: 14px; font-size: 11px; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 26px 22px; }
.template-card { display: flex; flex-direction: column; padding: 0; background: none; border: 0; text-align: left; color: var(--text); }
.template-thumb { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 3px; box-shadow: 0 0 0 1px var(--line); transition: box-shadow .12s, transform .12s; }
.template-card:hover .template-thumb { box-shadow: 0 0 0 1.5px var(--accent); }
.template-title { margin-top: 10px; font-size: 13px; font-weight: 600; }
.template-text { margin-top: 2px; color: var(--text-dim); }
.template-grid.is-films { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 22px 18px; }
.template-card.is-film .template-title { margin-top: 8px; }
.template-card.is-film .template-text { font-size: 11px; line-height: 1.4; }
.film-poster { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #000; border-radius: 3px; box-shadow: 0 0 0 1px var(--line); transition: box-shadow .12s; }
.template-card:hover .film-poster { box-shadow: 0 0 0 1.5px var(--accent); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 18px; z-index: 70; transform: translate(-50%, 8px); padding: 7px 12px; background: var(--panel-3); border: 1px solid var(--line-strong); border-radius: 5px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; max-width: 80vw; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { color: var(--error); border-color: #ff7b7b66; }

/* Presenting: the film and nothing else */
.is-presenting { position: fixed; inset: 0; z-index: 80; grid-template-rows: minmax(0, 1fr) !important; background: #000; }
.is-presenting .topbar, .is-presenting .timeline, .is-presenting .left-panel, .is-presenting .right-panel, .is-presenting .code-pane, .is-presenting .resizer { display: none !important; }
.is-presenting .center { background: #000; }
.is-presenting .stage-viewport { padding: 0; overflow: hidden; }
.is-presenting .stage-sheet { box-shadow: none; }
.is-presenting .stage-hud, .is-presenting .stage-input { display: none; }
.present-hud { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); padding: 4px 10px; font: 11px var(--mono); color: #ffffff66; pointer-events: none; white-space: pre; }

@media (max-width: 1020px) {
  .search-button span, .search-button kbd { display: none; }
  .project-name { width: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
