/* ============================================================
   ReelSync — builder (studio workbench)
   ============================================================ */

#builder {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(1000px 500px at 80% -20%, rgba(109, 40, 217, 0.12), transparent 60%),
    var(--bg-deep);
}
#builder.on { display: flex; animation: builderIn 0.45s var(--ease); }
@keyframes builderIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- top bar ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  height: 62px;
  padding: 0 1.1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 14, 36, 0.82);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}
.logo-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.35rem 0.5rem;
  transition: background 0.15s;
}
.logo-btn:hover { background: rgba(139, 92, 246, 0.1); text-decoration: none; }
.logo-btn img { width: 30px; height: 30px; }
.logo-btn .sync { color: var(--violet-hi); }

/* step rail */
.steps {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 0.25rem;
}
.steps::-webkit-scrollbar { display: none; }
.step {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.42rem 0.75rem;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--ink-3);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.step .num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  color: var(--ink-3);
  transition: all 0.2s;
}
.step .tick {
  display: none;
  font-size: 0.68rem;
  width: 20px;
  height: 20px;
  place-items: center;
}
.step:hover { color: var(--ink-2); }
.step[data-state="active"] {
  color: var(--ink);
  background: rgba(139, 92, 246, 0.13);
  border-color: var(--line-2);
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.14);
}
.step[data-state="active"] .num { border-color: var(--violet); color: var(--violet-hi); }
.step[data-state="done"] { color: var(--violet-hi); }
.step[data-state="done"] .num { display: none; }
.step[data-state="done"] .tick { display: grid; color: var(--good); }
.step-sep {
  width: 18px;
  height: 1px;
  flex-shrink: 0;
  background: linear-gradient(90deg, transparent, var(--line-2));
}

.bar-right { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }

/* ---------- workbench ---------- */
.bench {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 384px;
}

/* stage (left) */
.stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.4rem 1.8rem;
}
.stage-viewport {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-height: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: #05050f;
  border: 1px solid var(--line-2);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), 0 0 44px rgba(139, 92, 246, 0.09);
}
#stageCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* empty stage */
.stage-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  text-align: center;
  padding: 2rem;
}
.stage-empty h3 { font-size: 1.15rem; font-weight: 700; color: var(--ink-2); }
.stage-empty p { color: var(--ink-3); font-size: 0.88rem; max-width: 40ch; }
.wave-idle {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 44px;
  margin-bottom: 0.6rem;
}
.wave-idle span {
  width: 5px;
  border-radius: 99px;
  background: var(--grad-accent);
  opacity: 0.85;
  animation: idleBars 1.6s var(--ease) infinite alternate;
}
.wave-idle span:nth-child(1) { height: 30%; animation-delay: 0s; }
.wave-idle span:nth-child(2) { height: 55%; animation-delay: 0.12s; }
.wave-idle span:nth-child(3) { height: 80%; animation-delay: 0.24s; }
.wave-idle span:nth-child(4) { height: 100%; animation-delay: 0.36s; }
.wave-idle span:nth-child(5) { height: 65%; animation-delay: 0.48s; }
.wave-idle span:nth-child(6) { height: 40%; animation-delay: 0.6s; }
.wave-idle span:nth-child(7) { height: 75%; animation-delay: 0.3s; }
@keyframes idleBars {
  from { transform: scaleY(0.35); transform-origin: bottom; }
  to { transform: scaleY(1); transform-origin: bottom; }
}

/* transport */
.transport {
  width: 100%;
  max-width: 1200px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(20, 20, 44, 0.6);
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  color: #fff;
  background: var(--grad-accent);
  box-shadow: 0 4px 16px rgba(109, 40, 217, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.play-btn:not(:disabled):hover { transform: scale(1.06); box-shadow: 0 6px 24px rgba(139, 92, 246, 0.55); }
.play-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; background: #26264a; }
.transport .time {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink-2);
  white-space: nowrap;
  flex-shrink: 0;
}
.transport .range { flex: 1; min-width: 60px; }

/* ---------- panel (right) ---------- */
.panel {
  border-left: 1px solid var(--line);
  background: var(--bg-navy);
  overflow-y: auto;
  min-height: 0;
  padding: 0.55rem 0 0.8rem;
}
/* spaced rounded cards — the step buttons never touch each other */
.acc-item {
  margin: 0 0.6rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 15, 36, 0.35);
  overflow: hidden;
}
.acc-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.95rem 1.15rem;
  text-align: left;
  transition: background 0.15s;
}
.acc-head:hover { background: rgba(139, 92, 246, 0.06); }
.acc-head .chip {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--violet-hi);
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid var(--line);
}
.acc-titles { flex: 1; min-width: 0; }
.acc-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.acc-sub { font-size: 0.75rem; color: var(--ink-3); margin-top: 1px; }
.acc-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3a3a5e;
  flex-shrink: 0;
}
.acc-status[data-status="active"] { background: var(--violet); box-shadow: 0 0 10px rgba(139, 92, 246, 0.8); animation: pulseSoft 2s infinite; }
.acc-status[data-status="done"] { background: var(--good); box-shadow: 0 0 8px rgba(61, 220, 151, 0.6); }
.acc-chev {
  color: var(--ink-3);
  font-size: 0.8rem;
  transition: transform 0.3s var(--ease);
  flex-shrink: 0;
}
.acc-item.open .acc-chev { transform: rotate(180deg); color: var(--violet-hi); }

.acc-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.35s var(--ease);
}
.acc-item.open .acc-body { grid-template-rows: 1fr; }
.acc-inner {
  overflow: hidden;
  min-height: 0;
  padding: 0 1.15rem;
}
.acc-item.open .acc-inner { padding: 0.15rem 1.15rem 1.25rem; }
.acc-inner > * { margin-top: 0.9rem; }
.acc-inner > :first-child { margin-top: 0.25rem; }

/* step interiors: content wrappers are NOT direct children of .acc-inner, so the
   margin-top rhythm above never reached them; they carry their own vertical gap */
#lyricsContent, #bgPickerWrap { display: flex; flex-direction: column; gap: 0.75rem; }
#audioPickerWrap { display: flex; flex-direction: column; gap: 0.6rem; }
#bgPexelsPane { display: flex; flex-direction: column; gap: 0.6rem; }
#bgSyncSection { display: flex; flex-direction: column; gap: 0.55rem; }

/* drop zone (music etc.) */
.drop-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.6rem 1rem;
  border-radius: var(--radius-m);
  border: 1.5px dashed var(--line-2);
  background: rgba(139, 92, 246, 0.05);
  color: var(--ink-2);
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.drop-btn i { font-size: 1.6rem; color: var(--violet-hi); }
.drop-btn strong { color: var(--ink); font-size: 0.92rem; }
.drop-btn span { font-size: 0.78rem; color: var(--ink-3); }
.drop-btn:not(:disabled):hover,
.drop-btn.drag {
  border-color: var(--violet);
  background: rgba(139, 92, 246, 0.13);
  transform: translateY(-1px);
  box-shadow: var(--glow);
}
.drop-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.hint {
  font-size: 0.78rem;
  color: var(--ink-3);
  line-height: 1.5;
  display: flex;
  gap: 0.5rem;
}
.hint i { color: var(--violet); margin-top: 2px; flex-shrink: 0; }

/* ---------- bottom strip ---------- */
.bench-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 1.2rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-3);
  background: rgba(14, 14, 36, 0.7);
  flex-shrink: 0;
}
.bench-footer a { color: var(--violet-hi); }

/* ---------- loaded source cards ---------- */
.loaded-card {
  border: 1px solid var(--line-2);
  border-radius: var(--radius-m);
  background: rgba(139, 92, 246, 0.06);
  padding: 0.85rem 0.95rem;
  display: grid;
  gap: 0.7rem;
}
.loaded-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}
.loaded-head > i {
  font-size: 1.3rem;
  color: var(--violet-hi);
  flex-shrink: 0;
}
.loaded-thumb {
  width: 44px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  flex-shrink: 0;
}
.loaded-titles { min-width: 0; }
.loaded-titles strong {
  display: block;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.loaded-titles span {
  font-size: 0.72rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.loaded-actions { display: flex; gap: 0.5rem; }
.loaded-actions .btn { flex: 1; }
.mini-wave {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  background: var(--bg-inset);
  border: 1px solid var(--line);
}
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; border-radius: 9px; }
.btn-danger-ghost:not(:disabled):hover {
  border-color: var(--bad);
  color: var(--bad);
  background: rgba(255, 107, 107, 0.08);
}

/* ---------- background tabs ---------- */
.bg-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 11px;
  background: var(--bg-inset);
  border: 1px solid var(--line);
}
.bg-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink-3);
  transition: color 0.15s, background 0.15s;
}
.bg-tab:hover { color: var(--ink-2); }
.bg-tab.active {
  color: var(--ink);
  background: rgba(139, 92, 246, 0.16);
  box-shadow: inset 0 0 0 1px var(--line-2);
}

/* ---------- pexels search + grid ---------- */
.pexels-row { display: flex; gap: 0.5rem; }
.pexels-row .input { flex: 1; min-width: 0; }
.pexels-orientation { width: auto; flex-shrink: 0; }
#pexelsSearchBtn { padding: 0 0.85rem; }
#pexelsSearchBtn[data-busy] i { animation: spin 1s linear infinite; }

.pexels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.pexels-card {
  display: grid;
  gap: 0.3rem;
  text-align: left;
  border-radius: 10px;
  transition: transform 0.18s var(--ease);
}
.pexels-card:hover { transform: translateY(-2px); }
.pexels-thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  transition: border-color 0.18s, box-shadow 0.18s;
}
.pexels-card:hover .pexels-thumb {
  border-color: var(--violet);
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.25);
}
.pexels-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pexels-duration,
.pexels-quality {
  position: absolute;
  bottom: 4px;
  font-size: 0.62rem;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(5, 5, 15, 0.78);
  border: 1px solid rgba(148, 124, 246, 0.25);
  color: var(--ink-2);
}
.pexels-duration { left: 4px; }
.pexels-quality { right: 4px; }
.pexels-credit {
  font-size: 0.68rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

/* ---------- global file drag ---------- */
body.file-drag .drop-btn {
  border-color: var(--violet);
  background: rgba(139, 92, 246, 0.13);
  box-shadow: var(--glow);
}

/* ---------- form layout helpers ---------- */
.field-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.label-value { color: var(--violet-hi); float: right; font-weight: 600; }
.color-input {
  width: 100%;
  height: 38px;
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-inset);
  cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: none; border-radius: 7px; }
.color-input::-moz-color-swatch { border: none; border-radius: 7px; }

/* ---------- pill buttons (orientation etc.) ---------- */
.pill-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.4rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-inset);
  color: var(--ink-3);
  font-size: 0.8rem;
  font-weight: 600;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.pill-btn:hover { color: var(--ink-2); }
.pill-btn.active {
  color: var(--ink);
  border-color: var(--line-2);
  background: rgba(139, 92, 246, 0.14);
  box-shadow: inset 0 0 0 1px var(--line-2);
}
.check-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.85rem;
  color: var(--ink-2);
  cursor: pointer;
}
.check-row input { accent-color: var(--violet); width: 15px; height: 15px; }

/* ---------- progress ---------- */
.progress-track {
  height: 6px;
  border-radius: 99px;
  background: #232348;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--grad-accent);
  width: var(--fill, 0%);
  transition: width 0.25s var(--ease);
}
.progress-fill.indeterminate {
  width: 34%;
  animation: indeterminate 1.1s ease-in-out infinite;
}
@keyframes indeterminate {
  0% { margin-left: -34%; }
  100% { margin-left: 100%; }
}
.lyrics-progress { display: grid; gap: 0.45rem; }

/* ---------- lyric editor ---------- */
.lyric-toolbar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.lyric-toolbar .btn { flex: 1; }
.lyric-count {
  font-size: 0.7rem;
  color: var(--ink-3);
  display: block;
}
.lyric-list {
  display: grid;
  gap: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}
.lyric-row {
  display: grid;
  grid-template-columns: 16px 52px 1fr 26px 26px;
  gap: 0.4rem;
  align-items: center;
  padding: 0.3rem 0.4rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-inset);
  transition: border-color 0.15s;
}
/* focused line — gold to match its block on the lyrics timeline, so the
   glow reads as "this line ↔ that block". The keyframe gives a one-shot
   ping when focus lands (e.g. clicking a timeline block). */
.lyric-row:focus-within {
  border-color: rgba(232, 182, 76, 0.65);
  box-shadow: 0 0 0 1px rgba(232, 182, 76, 0.3), 0 0 18px rgba(232, 182, 76, 0.1);
}
.lyric-time:focus,
.lyric-text:focus {
  outline: none;
  border-radius: 5px;
  background: rgba(232, 182, 76, 0.06);
  box-shadow: 0 0 12px rgba(232, 182, 76, 0.16);
}
@media (prefers-reduced-motion: no-preference) {
  .lyric-row:focus-within { animation: lyric-focus-in 0.45s var(--ease); }
}
@keyframes lyric-focus-in {
  from { box-shadow: 0 0 0 3px rgba(232, 182, 76, 0.5), 0 0 26px rgba(232, 182, 76, 0.28); }
}
.lyric-time {
  font-size: 0.72rem;
  color: var(--violet-hi);
  background: transparent;
  border: none;
  padding: 2px 0;
  width: 100%;
}
.lyric-time:focus { outline: none; }
.lyric-text {
  font-size: 0.85rem;
  background: transparent;
  border: none;
  color: var(--ink);
  padding: 2px 0;
  min-width: 0;
}
.lyric-text:focus { outline: none; }
.lyric-text::placeholder { color: var(--ink-3); }
.lyric-row .icon-btn { width: 26px; height: 26px; font-size: 0.8rem; border-radius: 7px; }
.lyric-del:hover { color: var(--bad); background: rgba(255, 107, 107, 0.1); }
.lyric-play { color: var(--good); }
.lyric-play:hover { background: rgba(61, 220, 151, 0.1); }

/* drag-to-reorder grip */
.lyric-grip {
  cursor: grab;
  touch-action: none; /* keep touch drags from scrolling the page */
  color: var(--ink-3);
  width: 100%;
  min-width: 0;
  padding: 0;
}
.lyric-grip:hover { color: var(--ink-2); background: transparent; border-color: transparent; }
.lyric-row.dragging { border-color: var(--violet-hi); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.4); }
.lyric-row.dragging .lyric-grip { cursor: grabbing; color: var(--violet-hi); }

/* ---------- responsive ---------- */
@media (max-width: 1060px) {
  .bench {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(300px, 46%) minmax(0, 1fr);
  }
  .panel { border-left: none; border-top: 1px solid var(--line); }
}
@media (max-width: 940px) {
  .step .lbl { display: none; }
  .step .num, .step .tick { display: grid; }
  .step[data-state="done"] .num { display: none; }
  .bar-right .pill { display: none; }
}
@media (max-width: 640px) {
  .stage { padding: 0.9rem; }
  .transport { gap: 0.6rem; padding: 0.55rem 0.7rem; }
  .transport .time { font-size: 0.72rem; }
  #overlayTimelineWrap { padding: 0.45rem 0.6rem 0.55rem; }
  .ov-tl-tip { display: none; }
  .ov-lane { height: 34px; }
}

/* ---------- overlays ---------- */
.ov-actions { display: flex; gap: 0.5rem; align-items: center; }
.ov-actions .btn { flex: 0 0 auto; }
.ov-count { margin-left: auto; font-size: 0.72rem; color: var(--ink-3); }

#overlayTimelineWrap {
  position: relative;
  width: 100%;
  max-width: 1200px;
  padding: 0.55rem 0.9rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: rgba(20, 20, 44, 0.6);
  backdrop-filter: blur(8px);
}

/* timeline header row */
.ov-tl-head {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding-bottom: 0.35rem;
}
.ov-tl-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.ov-tl-label i { font-size: 0.8rem; color: var(--violet-hi); }
.ov-tl-head .ov-count { font-size: 0.7rem; color: var(--violet-hi); }
.ov-tl-tip {
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* new-overlay form */
.ov-new {
  margin-top: 0.6rem;
  padding: 0.8rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-m);
  background: var(--bg-card-2);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.ov-new-actions { display: flex; gap: 0.5rem; }

/* time ruler */
.ov-ruler {
  position: relative;
  height: 15px;
  margin-bottom: 5px;
  cursor: pointer;
}
.ov-tick {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  padding-top: 6px;
  font-size: 0.58rem;
  color: var(--ink-3);
  font-family: var(--font-mono);
  white-space: nowrap;
}
.ov-tick::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 4px;
  background: rgba(148, 124, 246, 0.4);
}

.ov-lanes {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 228px; /* ~5 lanes — never eat the stage */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}
.ov-lane {
  position: relative;
  flex: none;
  height: 40px;
  border-radius: 7px;
  background: rgba(148, 124, 246, 0.05);
  border: 1px solid rgba(148, 124, 246, 0.08);
  cursor: pointer; /* click/drag empty lane to seek */
  touch-action: none; /* let pointer drags scrub */
}
.ov-lane-empty {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  border-color: rgba(148, 124, 246, 0.28);
  color: var(--ink-3);
  font-size: 0.74rem;
  text-align: center;
  padding: 0 0.8rem;
}
.ov-lane-empty span { pointer-events: none; user-select: none; }
.ov-block {
  position: absolute;
  top: 2px;
  bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  min-width: 22px;
  border-radius: 6px;
  font-size: 0.74rem;
  white-space: nowrap;
  touch-action: none; /* let pointer drags move/trim */
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: box-shadow 0.15s var(--ease), filter 0.15s var(--ease);
}
.ov-block:active { cursor: grabbing; }
.ov-block.text {
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.5), rgba(109, 40, 217, 0.32));
  border: 1px solid rgba(167, 139, 250, 0.75);
}
.ov-block.image {
  background: linear-gradient(180deg, rgba(155, 89, 182, 0.45), rgba(109, 40, 217, 0.28));
  border: 1px solid rgba(155, 89, 182, 0.7);
}
.ov-block.selected { box-shadow: 0 0 0 2px var(--violet-hi), 0 4px 14px rgba(139, 92, 246, 0.35); }
.ov-block.dragging { filter: brightness(1.18); z-index: 1; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45); }
.ov-block .ov-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ov-hdl {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px;
  cursor: ew-resize;
  opacity: 0;
  transition: opacity 0.12s var(--ease);
}
.ov-hdl.l { left: -1px; border-radius: 6px 0 0 6px; }
.ov-hdl.r { right: -1px; border-radius: 0 6px 6px 0; }
.ov-block:hover .ov-hdl, .ov-block.selected .ov-hdl { opacity: 1; }
.ov-hdl:hover {
  background: rgba(167, 139, 250, 0.28);
}
.ov-hdl::after {
  content: '';
  position: absolute;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.75);
  left: 50%;
  transform: translateX(-50%);
}
.ov-hdl.l::after { left: 50%; transform: translateX(-50%); }
.ov-hdl.r::after { left: 50%; transform: translateX(-50%); }
.ov-playhead {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: 2px;
  border-radius: 1px;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(232, 182, 76, 0.7);
  pointer-events: none;
}

/* lyrics lane — chained blocks, gold-violet to read distinct from overlays */
.lyrics-lane {
  background: rgba(232, 182, 76, 0.045);
  border-color: rgba(232, 182, 76, 0.16);
}
.lyrics-lane .ov-lane-empty { border-color: rgba(232, 182, 76, 0.25); }
.ov-block.lyric {
  background: linear-gradient(180deg, rgba(232, 182, 76, 0.42), rgba(139, 92, 246, 0.38));
  border: 1px solid rgba(232, 182, 76, 0.72);
  color: #1a1300;
  min-width: 26px; /* room for a grabbable body between the edge zones */
}
.ov-block.lyric.selected {
  box-shadow: 0 0 0 2px var(--gold), 0 4px 14px rgba(232, 182, 76, 0.35);
}
/* lyric handles: visual affordances only — pointer hit-testing uses edge
   zones in JS (10px), so narrow blocks never mis-hit. Always faintly on. */
.ov-block.lyric .ov-hdl {
  width: 9px;
  opacity: 0.4;
  pointer-events: none;
}
.ov-block.lyric:hover .ov-hdl,
.ov-block.lyric.selected .ov-hdl { opacity: 1; }
.ov-block.lyric .ov-hdl::after { top: 8px; bottom: 8px; }

/* on-stage lyrics placement affordance */

/* lyrics timeline — its own zoomable, scrollable strip below the overlay one */
.lyric-tl {
  position: relative;
  width: 100%;
  max-width: 1200px;
  padding: 0.55rem 0.9rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: rgba(20, 20, 44, 0.6);
  backdrop-filter: blur(8px);
  margin-top: 0.6rem;
}
.lyric-tl .ov-tl-head { padding-bottom: 0.3rem; }
.lyric-zoom { display: inline-flex; gap: 0.25rem; }
.lyric-zoom .icon-btn { padding: 0.15rem 0.4rem; font-size: 0.8rem; }
.lyric-tl-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 124, 246, 0.4) transparent;
}
.lyric-tl-scroll::-webkit-scrollbar { height: 7px; }
.lyric-tl-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 124, 246, 0.4);
  border-radius: 4px;
}
.lyric-tl-body { position: relative; }
.lyric-lanes {
  position: relative;
  height: 52px;
  background: rgba(232, 182, 76, 0.045);
  border: 1px solid rgba(232, 182, 76, 0.16);
  border-radius: 7px;
  cursor: pointer; /* click empty lane to seek */
  touch-action: none;
}
.lyric-lanes .ov-block.lyric {
  top: 3px;
  bottom: 3px;
  font-size: 0.78rem;
}

.stage-lyric-box {
  position: absolute;
  display: none;
  border: 1.5px dashed rgba(167, 139, 250, 0.55);
  border-radius: 8px;
  z-index: 4;
  pointer-events: none;
  touch-action: none;
}
.stage-lyric-box.on {
  display: block;
  pointer-events: auto;
  cursor: move;
}
.stage-lyric-box:hover {
  border-color: rgba(167, 139, 250, 0.95);
  background: rgba(139, 92, 246, 0.06);
}
.stage-lyric-box.dragging { border-style: solid; border-color: var(--violet-hi); }
.stage-lyric-tag {
  position: absolute;
  top: -19px;
  left: -1.5px;
  font-size: 0.55rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  color: var(--violet-hi);
  background: rgba(5, 5, 15, 0.88);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  user-select: none;
}
.stage-lyric-hdl {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--violet-hi);
  border: 2px solid #05050f;
  cursor: nwse-resize;
  touch-action: none;
}
.stage-lyric-hdl:hover { transform: scale(1.15); }

/* editor head actions + live note */
.ov-head-actions { display: flex; align-items: center; gap: 0.4rem; }
.ov-live-note {
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-top: -0.45rem;
}

/* overlay editor */
.ov-editor {
  margin-top: 0.75rem;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--bg-card-2);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ov-editor-head { display: flex; align-items: center; justify-content: space-between; }
.ov-editor-head strong { font-size: 0.86rem; display: flex; align-items: center; gap: 0.45rem; color: var(--ink); }
.ov-editor-head .icon-btn { width: 28px; height: 28px; font-size: 0.85rem; }

.ov-img-preview {
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background:
    repeating-conic-gradient(rgba(148, 124, 246, 0.08) 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
  padding: 0.4rem;
  text-align: center;
}
.ov-img-preview img { max-width: 100%; max-height: 90px; border-radius: 5px; }

.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 210px;
}
.pos-cell {
  aspect-ratio: 1.7;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: rgba(148, 124, 246, 0.06);
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease), transform 0.1s var(--ease);
}
.pos-cell::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
  transition: background 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.pos-cell:hover { border-color: var(--line-2); transform: translateY(-1px); }
.pos-cell.active {
  border-color: var(--violet-hi);
  background: rgba(139, 92, 246, 0.18);
}
.pos-cell.active::after { background: var(--violet-hi); box-shadow: 0 0 8px rgba(167, 139, 250, 0.8); }

/* ---------- background sync ---------- */
#bgSyncSection { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
#bgSyncStrip {
  width: 100%;
  height: 64px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: grab;
  touch-action: none;
  display: block;
}
#bgSyncStrip:active { cursor: grabbing; }
.bg-sync-readout {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.74rem;
  color: var(--ink-3);
}
.bg-sync-readout b { color: var(--violet-hi); font-weight: 600; }
.bg-sync-readout .bi { font-size: 0.7rem; }
.bg-sync-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.bg-sync-actions .check-row { margin-left: auto; font-size: 0.78rem; color: var(--ink-2); }

/* ---------- export ---------- */
#exportContent { display: flex; flex-direction: column; gap: 0.75rem; }
.export-result {
  border: 1px solid rgba(61, 220, 151, 0.35);
  background: rgba(61, 220, 151, 0.06);
  border-radius: var(--radius-m);
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.export-result-head { display: flex; align-items: center; gap: 0.6rem; }
.export-result-head > .bi { color: var(--good); font-size: 1.25rem; }
.export-result-head strong { display: block; font-size: 0.86rem; color: var(--ink); word-break: break-all; }
.export-result-head .mono { font-size: 0.72rem; color: var(--ink-3); }
.export-result-actions { display: flex; gap: 0.5rem; }
.export-result-actions .btn { flex: 1; }
