:root {
  --bg: #0e0e10;
  --panel: #17171b;
  --panel-2: #1e1e24;
  --line: #2a2a32;
  --text: #ececf0;
  --muted: #9a9aa6;
  --accent: #9b6dff;
  --accent-dim: #6f4fd8;
  --blue: #4da3ff;
  --green: #46c46a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

/* scrollbars: thin, dark, on-theme */
* { scrollbar-width: thin; scrollbar-color: #33333d transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #2f2f38;
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #45454f; background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Segoe UI", system-ui, sans-serif;
}

#app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 6px var(--preview-w, 620px);
  height: 100vh;
}

#splitter {
  background: var(--line);
  cursor: col-resize;
}
#splitter:hover, #splitter.drag { background: var(--accent); }

/* Sidebar */
#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Preview column (always visible, own scroll) */
#preview {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 20px;
}
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
#preview .actions { margin: 0; }
/* live preview stage - 9:16, sized to the column/viewport, no black bars */
#pv-stage {
  position: relative;
  width: min(100%, calc((100vh - 200px) * 9 / 16));
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  container-type: size;   /* overlays size in cqh/cqw so they scale with the stage */
}
/* carousel face: the stage is a 4:5 still surface (1080x1350) instead of 9:16 */
#pv-stage.carousel-mode {
  width: min(100%, calc((100vh - 200px) * 4 / 5));
  aspect-ratio: 4 / 5;
}
/* headless export: pin the stage to a true 1080x1920 surface for frame capture */
.render-mode { overflow: hidden; }
.render-mode #pv-stage {
  position: fixed; left: 0; top: 0; margin: 0;
  width: 1080px; height: 1920px; max-width: none; aspect-ratio: auto;
  border-radius: 0; z-index: 999999;
}
.render-mode #pv-stage.carousel-mode { width: 1080px; height: 1350px; }
/* slide 1 video: the reel lyric overlay (+ glyph bookends) rides ABOVE the
   carousel aura/label layer (which is z-index 50) instead of below it */
.slide1-mode #pv-overlay { z-index: 60; }
#pv-stage video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 50%;
  display: block; margin: 0; border-radius: 0;
  max-height: none; background: #000;
}
/* b-roll layer: a pool of per-clip videos, all preloaded and stacked; only the
   active clip is shown (opacity), so crossing clips never reloads = no black gap.
   The look grade is a static GPU filter on this layer (cheap, no per-frame blend). */
#pv-broll { position: absolute; inset: 0; z-index: 1; background: #000; }
.pv-broll-vid { opacity: 0; z-index: 1; }
.pv-broll-vid.show { opacity: 1; }
#out-video { z-index: 2; }
#pv-stage #out-video[hidden], #pv-stage #pv-broll[hidden] { display: none; }
#pv-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
/* glitch: a canvas that redraws the active b-roll frame corrupted (pillar-style),
   pulsed on the hits. Sibling to the wash but stacked UNDER it and above b-roll. */
#pv-glitch { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; opacity: 0; }
#pv-look { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
/* datamosh melt: the outgoing clip's frozen frame smears/melts into the incoming
   clip across a cut. Above the b-roll + glitch, below the grade + overlays. */
#pv-datamosh { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; opacity: 0; }
/* CRT scanlines: an independent, controllable layer (period + alpha are set from
   the Scanlines controls). Sized in cqh so density matches preview and export. */
#pv-scan { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
#pv-wash { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
/* fade-to-black outro: ramps over the end-card window, under the text/song card */
#pv-fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 3; }
.pv-ov { position: absolute; }
/* ID rules below set display:flex, which out-specifies [hidden]; force-hide */
.pv-ov[hidden] { display: none !important; }

/* lyric band - text only (moved up ~50px). The glyph bookends are a separate
   always-on layer, present whether or not a lyric line is showing. */
#pv-lyric {
  left: 0; right: 0; top: 68.75cqh; height: 15cqh; transform: translateY(-50%);
}
#pv-lyric .pv-lyric-text {
  /* nudged up ~0.22cqh (~4px at export) so the text is optically centered with
     the glyph bookends, not just line-box centered. Wider side padding (26cqw)
     tightens the measure so lines wrap a touch sooner. */
  position: absolute; top: 50%; left: 0; right: 0; transform: translateY(calc(-50% - 0.22cqh));
  text-align: center; padding: 0 26cqw;
  color: rgba(255,255,255,0.65); font-weight: 600; font-size: 2.4cqh; line-height: 1.16;
}
/* placeholder: tiny, tracked, glitchy chromatic-split transmission tag */
#pv-lyric .pv-ph-text {
  position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%);
  text-align: center; padding: 0 20cqw;
  color: #dff6ff; font-family: "Consolas", "Courier New", monospace; font-weight: 700;
  font-size: 1.5cqh; letter-spacing: 0.42em; text-transform: uppercase; line-height: 1.5;
  text-shadow: -0.12cqh 0 rgba(255,0,64,.9), 0.12cqh 0 rgba(0,224,255,.9);
  animation: ph-glitch 1.4s steps(2, jump-none) infinite;
}
@keyframes ph-glitch {
  0%, 100% { transform: translateY(-50%) translateX(0); opacity: .9; }
  46% { transform: translateY(-50%) translateX(0.35cqw); opacity: .6; }
  50% { transform: translateY(-50%) translateX(-0.4cqw); opacity: 1; text-shadow: 0.12cqh 0 rgba(255,0,64,.9), -0.12cqh 0 rgba(0,224,255,.9); }
  54% { transform: translateY(-50%) translateX(0.2cqw); opacity: .8; }
}
/* "song about" line - a single always-on line at a fixed spot between the caption
   zone and the lyric band. translateY(-50%) centers the (possibly multi-line) text
   on `top`; the +1.04cqh in the transform nudges it down ~20px at the 1920px export
   height (expressed in cqh so the nudge holds at any preview scale). */
#pv-about {
  left: 0; right: 0; top: 55.63cqh; transform: translateY(calc(-50% + 5.99cqh));
  text-align: center; padding: 0 20cqw;
  color: rgba(255,255,255,0.82); font-weight: 500; font-size: 2cqh; line-height: 1.22;
  letter-spacing: 0.02em; text-shadow: 0 0.18cqh 0.6cqh rgba(0,0,0,0.55);
}

.pv-glyph { position: absolute; top: 68.75cqh; transform: translateY(-50%); height: 3cqh; width: auto; }
#pv-glyph-l { left: 12cqw; }
#pv-glyph-r { right: 12cqw; }
/* slide 1 (carousel 4:5): the reel band's default 68.75cqh lands on the label's
   WARNING row, so drop it into the empty lower third clear of the card. */
.slide1-mode #pv-lyric { top: 90cqh; }
.slide1-mode .pv-glyph { top: 90cqh; }

/* narrative caption - centered in the frame on both axes, so it stays centered
   no matter how many lines the text wraps to. Tighter measure, stroked, no shadow.
   The -1.30cqh transform lifts the whole block (every caption + the song-card morph
   it dissolves into) up ~25px at the 1920px export height - a global default nudge. */
#pv-caption {
  inset: 0; transform: translateY(-1.30cqh);
  display: flex; align-items: center; justify-content: center;
  text-align: center;
}
/* frosted-glass card behind the caption (chadworks hero glass, inverted dark).
   Its width/height are set per-frame in JS so the box MORPHS between the outgoing
   and incoming caption sizes; the two text layers crossfade inside it. */
.pv-cap-glass {
  position: relative; overflow: hidden;
  border-radius: 2.2cqh;
  background: linear-gradient(160deg, rgba(20,20,28,0.72) 0%, rgba(34,29,52,0.55) 100%);
  -webkit-backdrop-filter: blur(1.1cqh) saturate(1.15);
  backdrop-filter: blur(1.1cqh) saturate(1.15);
  border: 0.1cqh solid rgba(255,255,255,0.14);
  box-shadow: 0 1.8cqh 5cqh rgba(0,0,0,0.4), inset 0 0.12cqh 0 rgba(255,255,255,0.14);
}
/* the two crossfading text layers + an offscreen measurer share one box model so
   the measured size equals the rendered layer size (drives the box morph). */
.pv-cap-layer, .pv-cap-measure {
  box-sizing: border-box; width: max-content; max-width: 70cqw;
  padding: 2cqh 3.8cqw;
  color: #f4f5fc; font-weight: 600; font-size: 2.72cqh; line-height: 1.19;
}
.pv-cap-layer {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  white-space: normal; will-change: opacity, filter;
}
.pv-cap-measure { position: absolute; left: -9999px; top: 0; visibility: hidden; pointer-events: none; }
/* the song card, rendered INSIDE the caption glass so the last caption morphs
   into it (box grows, text dissolves into the card content) */
.pv-cap-layer.is-card, .pv-cap-measure.is-card {
  display: flex; flex-direction: column; align-items: center; gap: 1.1cqh;
  padding: 3.4cqh 6cqw;
}
.pv-cap-layer.is-card .pvec-kick, .pv-cap-measure.is-card .pvec-kick { font-size: 1.7cqh; font-weight: 600; letter-spacing: .5em; color: #b8b8c6; }
.pv-cap-layer.is-card .pvec-title, .pv-cap-measure.is-card .pvec-title { font-size: 3.6cqh; font-weight: 700; color: #fff; line-height: 1.12; }
.pv-cap-layer.is-card .pvec-by, .pv-cap-measure.is-card .pvec-by { font-size: 2cqh; color: #c2c2ce; }

/* psyche facts label card - upper area */
#pv-label {
  left: 7cqw; right: 7cqw; top: 10cqh;
  background: rgba(14,14,16,.93); border-radius: 2.4cqh;
  padding: 2.4cqh 2.8cqw; color: #fff;
}
#pv-label .pvl-kick { font-size: 1.7cqh; font-weight: 700; letter-spacing: .12em; color: #b4b4be; margin-bottom: .8cqh; }
#pv-label .pvl-title { font-size: 3cqh; font-weight: 700; margin-bottom: .6cqh; }
#pv-label .pvl-tierrow { display: flex; justify-content: space-between; align-items: baseline; font-size: 2cqh; font-weight: 600; margin-bottom: 1.4cqh; }
#pv-label .pvl-field { font-size: 1.7cqh; font-weight: 700; letter-spacing: .06em; color: #9a9aa4; margin-top: 1.1cqh; }
#pv-label .pvl-val { font-size: 1.7cqh; color: #ececef; line-height: 1.3; }

/* ---- carousel slides: the stark "Psyche Facts / Drug Facts" panel, ported
   from the chadlewine site's SongLabel.css, on the world's dark ground. Sizes
   in cq units so it scales identically in the preview and at 1080x1350. ---- */
#pv-carousel {
  position: absolute; inset: 0; z-index: 50;
  background:
    radial-gradient(120% 90% at 50% 0%, #17171d 0%, #0c0c0f 62%, #08080a 100%);
  font-family: "Consolas", "Courier New", ui-monospace, monospace;
}
#pv-carousel[hidden] { display: none; }
/* aura background sits behind the slide content (slide 1 only); pure fn of t */
#pv-caura { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
#pv-caura.on { display: block; }
/* the slide content layer (padding + layout live here so the aura canvas is not
   wiped when the slide html re-renders) */
#pv-cslide {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: stretch; justify-content: center;
  padding: 6cqh 6cqw;
}
/* one slide fills the stage; the label slide pins the panel up top and the
   lyrics in the bottom spot, prose slides just center their panel. */
.csl-slide { width: 100%; display: flex; flex-direction: column; }
.csl-slide--label { justify-content: space-between; }
.csl-slide--prose { justify-content: center; }
/* lyrics: xy-centered in the lower half, quiet under the label */
.csl-lyrics {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.6cqh; text-align: center; padding: 2cqh 2cqw;
}
.csl-lyric-line {
  font-size: 3cqh; line-height: 1.32; color: #e7e7ee;
  letter-spacing: .01em; text-wrap: balance;
}
.csl-panel {
  width: 100%;
  border: 0.28cqh solid #ececef;
  background: rgba(19, 19, 24, var(--csl-panel-alpha, 1));
  color: #ececef;
  --csl-line: #3a3a44;
}
/* prose slides float a centered card so the generative field reads as the
   background around it (it replaces the old b-roll) */
.csl-slide--prose .csl-panel { width: auto; max-width: 82cqw; margin: 0 auto; }
/* slide 4: closing song card in the SAME frosted glass as the narrative caption
   (.pv-cap-glass gives the blur/gradient/border/shadow; this adds the card layout
   + the pvec-* typography, matched to .pv-cap-layer.is-card) */
.csl-slide--card { justify-content: center; align-items: center; }
.csl-cardglass {
  display: flex; flex-direction: column; align-items: center; gap: 2.4cqh;
  padding: 8cqh 8cqw; width: 84cqw; text-align: center;
}
.csl-cardglass .pvec-kick { font-size: 3cqh; font-weight: 600; letter-spacing: .5em; text-transform: uppercase; color: #b8b8c6; }
.csl-cardglass .pvec-title { font-size: 7cqh; font-weight: 800; color: #fff; line-height: 1.08; }
.csl-cardglass .pvec-by { font-size: 3.4cqh; color: #c2c2ce; }
.csl-head { padding: 2.4cqh 3cqw; border-bottom: 0.7cqh solid #ececef; }
.csl-kick { display: block; font-size: 3.6cqh; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; line-height: 1.02; }
.csl-track { display: block; margin-top: .5cqh; font-size: 1.7cqh; color: #9a9aa4; text-transform: uppercase; letter-spacing: .09em; }
.csl-active { padding: 2cqh 3cqw 2.4cqh; border-bottom: 0.7cqh solid #ececef; }
.csl-active > * + * { margin-top: 1.4cqh; padding-top: 1.4cqh; border-top: 0.14cqh solid var(--csl-line); }
.csl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 3cqw; }
.csl-k { text-transform: uppercase; letter-spacing: .06em; font-size: 1.9cqh; color: #9a9aa4; white-space: nowrap; }
.csl-v { font-weight: 700; font-size: 2.3cqh; text-align: right; }
.csl-sum { margin: 0; font-size: 2cqh; font-style: italic; line-height: 1.4; color: #b8b8c2; }
.csl-field { padding: 1.7cqh 3cqw; border-bottom: 0.14cqh solid var(--csl-line); }
.csl-field:last-child { border-bottom: 0; }
.csl-flabel { display: block; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; font-size: 1.8cqh; color: #9a9aa4; margin-bottom: .8cqh; }
.csl-body { font-size: 2.2cqh; line-height: 1.5; color: #ececef; }
.csl-body.is-prose { font-size: 2.2cqh; line-height: 1.6; white-space: pre-wrap; }

/* carousel editor block */
#carousel-block .csl-toggle button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#carousel-block .csl-note { margin: 8px 0 4px; }
#carousel-block .csl-field { display: block; margin-top: 12px; font-size: 13px; color: var(--muted); }
#carousel-block textarea { display: block; width: 100%; margin-top: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit; resize: vertical; }
#ig-caption-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
#ig-caption-block .ig-actions { margin: 8px 0 2px; align-items: center; gap: 10px; }
#ig-caption { min-height: 240px; font-family: "Consolas", "Courier New", ui-monospace, monospace; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; }
#carousel-block .csl-actions { margin-top: 14px; align-items: center; gap: 12px; }
.csl-out { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.csl-out img { width: 132px; aspect-ratio: 4 / 5; object-fit: cover; border: 1px solid var(--line); border-radius: 6px; background: #000; }

/* end card - full wash */
#pv-endcard {
  inset: 0; background: rgba(0,0,0,.95);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: #fff;
}
#pv-endcard .pvec-kick { font-size: 1.7cqh; letter-spacing: .5em; color: #a0a0ac; margin-bottom: 1.6cqh; }
#pv-endcard .pvec-title { font-size: 3.7cqh; font-weight: 700; margin-bottom: 1.4cqh; padding: 0 8cqw; }
#pv-endcard .pvec-by { font-size: 2cqh; color: #b2b2be; }

.pv-mode.ver-toggle button { padding: 4px 12px; font-size: 12px; }
#preview #render-log { max-width: 100%; margin-top: 8px; }
/* render output destination (folder + filename) */
#out-dest { display: flex; align-items: center; gap: 10px; margin: 8px 0 2px; }
#out-dest #export-btn { padding: 7px 18px; font-weight: 600; }
/* tier/charge are pulled from Rising Compass, shown read-only */
input[readonly] { opacity: 0.8; cursor: default; }
#label-block .block-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#rc-pull { padding: 4px 10px; margin-left: auto; }
#rc-status { font-variant-numeric: tabular-nums; }
/* reserve the status line so it appears/clears without shoving the stage down */
#render-status { display: block; min-height: 17px; line-height: 17px; margin: 2px 0; }
/* live render progress bar (browser-capture export) */
#render-bar { display: flex; align-items: center; gap: 10px; margin: 4px 0 2px; }
#render-bar[hidden] { display: none; }
#render-bar-track { flex: 1; height: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
#render-bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 5px; transition: width .25s ease; }
#render-bar-label { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* snippet lock toggle: open lock by default, closed + accent when locked */
#snippet-lock .lock-closed { display: none; }
#snippet-lock.locked .lock-open { display: none; }
#snippet-lock.locked .lock-closed { display: block; }
#snippet-lock.locked { color: var(--accent); border-color: var(--accent-dim); }
#wave-wrap.locked #region { cursor: default; }
#wave-wrap.locked #region .rg-handle { opacity: 0; pointer-events: none; }
.snippet-dur { font-size: 13px; color: var(--muted); }
.snippet-dur b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

/* the timeline is the preview's transport (play / scrub / time) - see #timeline */
.side-head {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel); z-index: 2;
}
.side-head h1 { font-size: 15px; margin: 0 0 8px; letter-spacing: .3px; }
#complist { padding: 8px; }
.song-group { margin-bottom: 6px; }
.song-name { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; padding: 8px 8px 4px; }
.comp-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.comp-item:hover { background: var(--panel-2); }
.comp-item.active { background: var(--accent-dim); }
.comp-item .v { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: #333; }
.comp-item .v.A { background: #2d4a63; color: #cfe6ff; }
.comp-item .v.B { background: #3a2d63; color: #e0d4ff; }
.comp-item .dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: #444; }
.comp-item .dot.on { background: var(--green); }

/* Editor */
#editor { overflow-y: auto; padding: 24px 28px 0; }
.empty { color: var(--muted); padding: 40px; }
.editor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.comp-song { font-size: 20px; font-weight: 700; margin-right: 10px; }
.badge { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 6px; background: var(--panel-2); }
.badge.A { background: #2d4a63; color: #cfe6ff; }
.badge.B { background: #3a2d63; color: #e0d4ff; }
.comp-id { color: var(--muted); font-size: 12px; }
.head-left { display: flex; align-items: center; gap: 14px; }

/* version toggle - Label / Narrative as two shades of dark purple,
   with a depressed (pushed-in) state on the active face */
.ver-toggle { display: inline-flex; gap: 3px; padding: 3px; background: #131019; border: 1px solid var(--line); border-radius: 9px; }
.ver-toggle button {
  border: 0; border-radius: 6px; padding: 5px 16px; font-size: 13px; font-weight: 600;
  background: transparent; transition: background .12s, box-shadow .12s, color .12s, transform .05s;
}
.ver-toggle button[data-ver="label"] { color: #a794da; }
.ver-toggle button[data-ver="narrative"] { color: #8f9be0; }
.ver-toggle button[data-ver="label"].active { background: #4a3a73; color: #f0eaff; }
.ver-toggle button[data-ver="narrative"].active { background: #363a6b; color: #eaecff; }
.ver-toggle button.active { box-shadow: inset 0 2px 5px rgba(0,0,0,.6), inset 0 0 0 1px rgba(0,0,0,.35); transform: translateY(1px); }
.ver-toggle button:not(.active):hover { color: #fff; }

/* sidebar toolbar: New (menu) + reindex */
.side-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.side-tools button { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.menu-wrap { position: relative; }

/* + New dropdown menu (New song / New compilation / pick a song) */
.popmenu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 20;
  min-width: 190px; max-height: 60vh; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 5px; box-shadow: 0 10px 28px rgba(0,0,0,.5);
  animation: pop-in .12s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.popmenu .pm-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 6px 8px 4px; }
.popmenu .pm-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  color: var(--text); padding: 8px 10px; border-radius: 7px; font-size: 13px; cursor: pointer;
}
.popmenu .pm-item:hover { background: var(--accent-dim); color: #fff; }
.popmenu .pm-item.pm-alt { color: var(--muted); }
.popmenu .pm-sep { height: 1px; background: var(--line); margin: 4px 2px; }

/* song group header: name + hover actions (add compilation / delete empty) */
.song-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 4px; }
.song-head .song-name { padding: 0; flex: 1; min-width: 0; }
.song-head .sh-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 2px 5px; border-radius: 5px; line-height: 1; font-size: 15px; display: none;
}
.song-group:hover .sh-btn { display: inline-flex; }
.song-head .sh-btn:hover { background: rgba(255,255,255,.12); color: var(--text); }
.song-head .sh-del:hover { background: #5a2330; color: #ffd7de; }
.song-empty { color: #64646f; font-size: 12px; padding: 2px 12px 6px; font-style: italic; }

/* per-compilation row actions (rename / duplicate / delete) - reveal on hover */
.comp-item .comp-actions { display: none; gap: 2px; margin-left: auto; }
.comp-item:hover .comp-actions { display: inline-flex; }
.comp-item .ca-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 3px; border-radius: 5px; line-height: 0;
}
.comp-item .ca-btn:hover { background: rgba(255,255,255,.12); color: var(--text); }
.comp-item .ca-btn.ca-del:hover { background: #5a2330; color: #ffd7de; }

.block { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.block-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px; color: #c7c7d0; }
.hint { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.wave-controls { margin-top: 12px; }
/* lock the play button width so flipping Play snippet <-> Stop doesn't resize it */
#play { min-width: 124px; text-align: center; }
.icon-btn { padding: 7px 9px; display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.icon-btn svg { display: block; }
label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.grow { flex: 1; }
label.grow { display: flex; }

input[type=text], input[type=number], textarea {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%;
}
input[type=number] { width: 90px; }
textarea { resize: vertical; }

button {
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer;
}
button:hover { border-color: #3a3a44; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-dim); }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: default; }

/* Waveform */
#wave-wrap { position: relative; height: 128px; background: #0a0a0c; border-radius: 8px; overflow: hidden; user-select: none; }
#wave { width: 100%; height: 100%; display: block; }
#region {
  position: absolute; top: 0; height: 100%;
  background: rgba(155,109,255,.22); border-left: 2px solid var(--accent); border-right: 2px solid var(--accent);
  cursor: grab;
}
#region.drag { cursor: grabbing; }
.rg-handle { position: absolute; top: 0; bottom: 0; width: 12px; cursor: ew-resize; z-index: 2; }
.rg-handle.l { left: -6px; } .rg-handle.r { right: -6px; }
.rg-handle::after { content: ""; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 3px; height: 34px; border-radius: 2px; background: #fff; opacity: .7; }
#playhead { position: absolute; top: 0; height: 100%; width: 2px; background: #fff; opacity: .85; left: 0; display: none; pointer-events: none; }
/* play-from locator: a blue marker set by clicking inside the segment */
#locator { position: absolute; top: 0; height: 100%; width: 2px; background: var(--blue); left: 0; display: none; pointer-events: none; z-index: 3; box-shadow: 0 0 6px rgba(77,163,255,.8); }
#locator::before { content: ""; position: absolute; top: -1px; left: -4px; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 7px solid var(--blue); }

/* label rows */
.label-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: flex-start; }
.label-row input.field { width: 200px; }
.label-row .del { padding: 8px 10px; }

/* media */
video { width: 100%; max-height: 420px; background: #000; border-radius: 8px; margin-top: 10px; }
#broll-preview { max-height: 240px; cursor: default; }
#broll-stage { position: relative; display: inline-block; margin-top: 10px; line-height: 0; }
#broll-stage.scrubbing { cursor: ew-resize; }
#broll-stage video { margin: 0; display: block; }
/* source-time badge over the frame while scrubbing the clip */
.seg-time-badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  padding: 3px 7px; border-radius: 6px; pointer-events: none;
  background: rgba(0,0,0,.66); color: #fff; font-size: 12px; line-height: 1;
  font-variant-numeric: tabular-nums; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.seg-time-badge[hidden] { display: none; }
/* empty focal picker: nothing selected -> a placeholder, no stale clip */
#broll-stage.empty-stage #broll-preview { display: none; }
#broll-stage:not(.empty-stage) #broll-empty { display: none; }
.stage-empty {
  display: flex; align-items: center; justify-content: center;
  width: 320px; max-width: 100%; height: 180px;
  background: #0a0a0c; border: 1px dashed var(--line); border-radius: 8px;
  color: var(--muted); font-size: 13px; line-height: 1.4; text-align: center; padding: 0 20px;
}
#focal-speed { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 4px 6px; font: inherit; width: auto; }
.broll-row .bspeed-tag { font-size: 11px; color: var(--blue); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.broll-row .bpick { padding: 6px 9px; font-size: 12px; }
#focal-dot {
  position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border: 2px solid #fff; border-radius: 50%; cursor: grab;
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 8px rgba(0,0,0,.5); background: rgba(155,109,255,.35);
}
#focal-dot::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: #fff; }
#focal-dot.drag { cursor: grabbing; }
#focal-controls { margin-top: 8px; }
#focal-controls input[type=range] { accent-color: var(--accent); width: 160px; }

/* timeline */
#timeline { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #0a0a0c; cursor: pointer; }
/* scrub ruler across the top of the timeline (the transport surface) */
.tl-ruler { display: flex; align-items: stretch; height: 18px; border-bottom: 1px solid var(--line); background: #101014; }
.tl-ruler .tl-ruler-track { flex: 1; position: relative; background:
  repeating-linear-gradient(90deg, rgba(255,255,255,.10) 0, rgba(255,255,255,.10) 1px, transparent 1px, transparent 10%); }
.tl-track { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); height: 34px; }
.tl-track:last-child { border-bottom: 0; }
.tl-label { width: 74px; flex: none; display: flex; align-items: center; padding: 0 10px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; background: var(--panel); border-right: 1px solid var(--line); }
.tl-lane { position: relative; flex: 1; }
.tl-block {
  position: absolute; top: 3px; bottom: 3px; border-radius: 4px;
  font-size: 11px; color: #fff; padding: 0 6px; display: flex; align-items: center;
  overflow: hidden; white-space: nowrap; cursor: grab; user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.tl-block.broll { background: #2c3550; }
.tl-block.broll:nth-child(even) { background: #364062; }
.tl-block.lyric { background: #4a3d73; }
.tl-block.caption { background: #3a5566; }
.tl-block.endcard { background: #5a4a2d; }
.tl-block .tl-handle { position: absolute; top: 0; bottom: 0; width: 6px; cursor: ew-resize; }
.tl-block .tl-handle.l { left: 0; } .tl-block .tl-handle.r { right: 0; }
#tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; left: 74px; pointer-events: none; box-shadow: 0 0 6px rgba(255,255,255,.6); }
/* amber guide shown at the edge a dragged block is snapping to */
#tl-snap { position: absolute; top: 0; bottom: 0; width: 2px; background: #ffcf5a; left: 74px; pointer-events: none; display: none; z-index: 4; box-shadow: 0 0 7px rgba(255,207,90,.85); }

/* timeline pinned to the bottom of the editor column */
#timeline-block {
  position: sticky; bottom: 0; z-index: 3;
  margin: 8px 0 0; border-radius: 12px 12px 0 0;
  border-bottom: 0;
  /* gently contrasting edge + a soft lift so it reads as a separate surface */
  border-color: #3d3d48;
  box-shadow: 0 -8px 20px -12px rgba(0,0,0,.4);
}
.tl-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.tl-transport { display: inline-flex; align-items: center; gap: 6px; }
.tl-transport button { min-width: 0; padding: 6px 9px; display: inline-flex; align-items: center; justify-content: center; }
.tl-transport button[disabled] { opacity: .4; cursor: default; }
.tl-head .tl-time { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* lyric line CRUD rows (edit text + timing badge + delete, in one list) */
.lyric-lines { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.lyric-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 4px 8px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid transparent;
}
.lyric-row .lr-num { width: 18px; flex: none; color: var(--muted); font-size: 12px; text-align: right; }
.lyric-row .lr-text { flex: 1; background: transparent; border: 0; padding: 5px 4px; }
.lyric-row .lr-text:focus { outline: none; }
.lyric-row .lr-time { flex: none; min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.lyric-row .lr-del { flex: none; padding: 4px 9px; font-size: 12px; color: var(--muted); }
.lyric-row .lr-del:hover { color: #ff8a8a; border-color: #5a2d2d; }
.lyric-row:focus-within { border-color: var(--line); background: #23232b; }
.lyric-row.done { background: #17251b; }
.lyric-row.done .lr-time { color: var(--green); font-weight: 600; }
.lyric-row.current { background: var(--accent-dim); border-color: var(--accent); }
.lyric-row.current .lr-time { color: #fff; font-weight: 700; animation: tap-pulse 1s ease-in-out infinite; }
@keyframes tap-pulse { 0%,100% { opacity: .45; } 50% { opacity: 1; } }

.lyric-ph { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.lyric-ph input { flex: 1; }

/* tap-to-time panel (inside the lyric block) */
.tap-panel { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; }
.tap-panel.tapping { outline: 2px solid var(--accent); outline-offset: 6px; border-radius: 6px; }
.tap-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
#tap-mode.arming { background: var(--accent); border-color: var(--accent); color: #fff; }

/* narrative caption CRUD rows */
.caption-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.caption-row { display: flex; align-items: center; gap: 8px; }
.caption-row .ci { width: 18px; flex: none; color: var(--muted); font-size: 12px; text-align: right; }
.caption-row .cf { flex: 1; }
.caption-row .csize-lab { flex: none; display: inline-flex; align-items: center; gap: 3px; color: var(--muted); font-size: 12px; }
.caption-row .csize { width: 3.4em; text-align: center; }
.caption-row .cdel { flex: none; padding: 6px 10px; font-size: 12px; color: var(--muted); }
.caption-row .cdel:hover { color: #ff8a8a; border-color: #5a2d2d; }

/* b-roll list */
.broll-controls { margin-bottom: 10px; }
.broll-row { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }
.broll-row .bi { width: 20px; color: var(--muted); font-size: 12px; text-align: right; }
.broll-row .bf { flex: 1; font-size: 13px; }
.broll-row label.sm { font-size: 12px; gap: 4px; }
.broll-row label.sm input { width: 60px; }
.broll-row .end-tag { font-size: 11px; color: var(--muted); width: 60px; text-align: center; }
.broll-row button { padding: 6px 9px; font-size: 12px; }
.broll-row.active .bf { border-color: var(--accent); }

.actions { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.log { background: #000; color: #b9f5c9; padding: 12px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; max-height: 200px; overflow: auto; }

#captions-block[hidden], #label-block[hidden] { display: none; }

/* look */
.look-presets button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.wash-row { margin-top: 12px; gap: 12px; }
.wash-row .wash-title { font-size: 13px; color: #c7c7d0; }
.scan-row.off label:not(.glitch-on-lbl), .scan-row.off #scan-intensity-v, .scan-row.off #scan-density-v { opacity: .45; }
.scan-row #scan-intensity-v, .scan-row #scan-density-v { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
/* full-width segment scrubber */
.seg-scrub-row { flex-direction: column; align-items: stretch; gap: 6px; }
.seg-scrub-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); }
#seg-scrub { width: 100%; accent-color: var(--accent); }
/* datamosh clip-intersection markers (in the b-roll timeline lane) */
.dm-marker { position: absolute; top: 0; width: 16px; height: 12px; transform: translateX(-50%); z-index: 6; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.dm-marker::before { content: ""; width: 8px; height: 8px; transform: rotate(45deg); background: var(--muted); border: 1px solid var(--panel); border-radius: 2px; }
.dm-marker:hover::before { background: var(--accent); }
.dm-marker.on::before { background: #ff4dd2; box-shadow: 0 0 6px #ff4dd2; }
/* datamosh is the default at every seam; a hard cut is the flagged exception */
.dm-marker.cut::before { background: #ffb347; box-shadow: 0 0 6px #ffb347; border-radius: 0; }
#dm-modal { position: fixed; z-index: 100000; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; box-shadow: 0 14px 44px rgba(0,0,0,.6); min-width: 176px; }
#dm-modal[hidden] { display: none; }
#dm-modal .dm-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 9px; }
#dm-modal .dm-opt { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); cursor: pointer; }
#dm-modal .dm-opt input { accent-color: var(--accent); width: auto; }
#dm-modal .dm-hint { margin-top: 7px; }
.master-row { align-items: center; gap: 12px; margin-bottom: 10px; }
.master-row select { width: 100%; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 5px 8px; font: inherit; }
.wash-row input[type=color] { width: 40px; height: 30px; padding: 2px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; }
.wash-row input[type=range] { width: 150px; accent-color: var(--accent); }
.wash-row #wash-alpha-v { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.wash-row #wash-blend { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 4px 6px; font: inherit; }
.glitch-row #glitch-strength-v { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.glitch-row .glitch-on-lbl { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.glitch-row .glitch-on-lbl input { accent-color: var(--accent); width: auto; }
.glitch-row.off label:not(.glitch-on-lbl), .glitch-row.off #glitch-strength-v { opacity: .45; }
/* glitch suite (second row of per-variation controls) */
.glitch-suite { margin-top: 8px; flex-wrap: wrap; row-gap: 8px; }
.glitch-suite .gl-ctl { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.glitch-suite .gl-ctl input[type=range] { width: 96px; accent-color: var(--accent); }
.glitch-suite .gl-ctl input[type=number] { width: 58px; background: var(--panel-2); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 3px 6px; }
.glitch-suite .gl-ctl select { background: var(--panel-2); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 3px 6px; }
.glitch-suite .gl-ctl .hint { min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.glitch-suite.off { opacity: .45; pointer-events: none; }

/* stackable FX rows (generated from the FX registry into #fx-stack) */
.fx-row .glitch-on-lbl { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.fx-row .glitch-on-lbl input { accent-color: var(--accent); width: auto; }
.fx-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.fx-row input[type=range] { width: 116px; accent-color: var(--accent); }
.fx-row select { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 4px 6px; font: inherit; }
.fx-row span.hint { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.fx-row.off label:not(.glitch-on-lbl), .fx-row.off > span.hint { opacity: .45; }

/* b-roll drag-to-reorder grip + segment scrubber */
.broll-row .bgrip {
  width: 12px; height: 22px; flex: none; cursor: grab; border-radius: 3px;
  background-image: radial-gradient(circle, var(--muted) 1px, transparent 1.4px);
  background-size: 4px 5px; background-position: center; opacity: .55;
}
.broll-row .bgrip:hover { opacity: .9; }
.broll-row.dragging { opacity: .45; }
#seg-controls { margin-top: 8px; }
#seg-controls #seg-scrub { accent-color: var(--blue); }
#seg-controls #seg-scrub-v { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.look-sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; margin-top: 12px; }
.look-sliders label { display: grid; grid-template-columns: 80px 1fr 34px; align-items: center; gap: 8px; }
.look-sliders input[type=range] { width: 100%; accent-color: var(--accent); }
.look-sliders .lk-val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; text-align: right; }

/* manual clip picker modal */
#clip-picker { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 40px; }
#clip-picker[hidden] { display: none; }
.cp-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: min(760px, 100%); max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.cp-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cp-head #cp-search { flex: 1; }
.cp-head #cp-count { white-space: nowrap; }
.cp-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.cp-crumbs[hidden] { display: none; }
.cp-crumb { background: none; border: none; color: var(--muted); cursor: pointer; padding: 2px 4px; border-radius: 6px; font: inherit; }
.cp-crumb:hover { background: var(--panel-2); color: var(--text); }
.cp-crumb.current { color: var(--text); cursor: default; }
.cp-crumb.current:hover { background: none; }
.cp-crumb-sep { opacity: .5; }
.cp-results { overflow-y: auto; padding: 6px; }
.cp-row { display: flex; align-items: baseline; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.cp-row:hover { background: var(--panel-2); }
.cp-row .cp-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-row .cp-folder { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cp-row.cp-dir .cp-name { font-weight: 500; }
.cp-row .cp-ic { font-size: 13px; width: 16px; text-align: center; flex: none; }
.cp-row.cp-up { color: var(--muted); }
.cp-empty { padding: 20px; color: var(--muted); font-size: 13px; }
