/* ============================================================
   Media AI Box - Pro Video Editor (refined)
   Layout:
     - Back button floats top-left over preview (outside flow)
     - Preview = stage + transport in ONE rounded rectangle
     - Timeline auto-height (tools-bar + tracks only)
   ============================================================ */

.editor-shell {
  direction: ltr;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  grid-template-areas:
    "preview"
    "timeline";
  gap: 8px;
  height: calc(100vh - var(--s-12));
  min-height: 540px;
  padding: 0;
  position: relative;
}

/* ── Editor Skeleton Loader ──────────────────────────────────────────────── */

/* Shimmer keyframe - a diagonal light sweep */
@keyframes sk-sweep {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

/* Base shimmer block */
.sk-shim {
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.13) 40%,
    rgba(255, 255, 255, 0.22) 50%,
    rgba(255, 255, 255, 0.13) 60%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  animation: sk-sweep 1.5s ease-in-out infinite;
}

/* Light mode shimmer for timeline area */
.sk-timeline .sk-shim {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.06) 40%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0.06) 60%,
    rgba(0, 0, 0, 0) 100%
  );
  background-size: 200% 100%;
  animation: sk-sweep 1.5s ease-in-out infinite;
}

/* Root skeleton - exact same grid as .editor-shell */
.editor-skeleton {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
  gap: 8px;
  pointer-events: all;
  opacity: 1;
  transition: opacity 0.35s ease;
  /* fill the gap between grid rows and any overflow */
  background: var(--bg, #e4eaf1);
  padding: 0;
}
.editor-skeleton.sk-done {
  opacity: 0;
  pointer-events: none;
}

/* Media still loading: tools usable; preview + timeline tracks show site loaders */
.editor-shell.editor-media-loading .timeline-scroll {
  pointer-events: none;
}
.editor-shell.editor-media-loading .tr-scrub.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Same pattern as project-load: thin accent bar + ws-sk-bone + clear status */
.editor-media-load-overlay,
.editor-timeline-load-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}
.editor-media-load-overlay {
  /* Light scrim only. The first frame is usually already painted underneath -
     hiding it behind an opaque wash read as "the video is gone". */
  background: rgba(10, 10, 12, 0.38);
  animation: ed-load-in 0.18s ease-out both;
}
.editor-timeline-load-overlay {
  background: color-mix(in srgb, var(--surface, #fff) 92%, var(--bg, #e4eaf1));
  border-radius: 0 0 var(--r-md, 10px) var(--r-md, 10px);
  padding: 10px 12px 12px;
  gap: 8px;
  animation: ed-load-in 0.18s ease-out both;
}
@keyframes ed-load-in {
  from {
    opacity: 0;
  }
}

/* Compact status pill — the ONE place the loading sentence appears. */
.ed-load-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: min(92%, 30rem);
  padding: 8px 15px;
  border-radius: 999px;
  background: rgba(14, 16, 20, 0.78);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.09),
    0 6px 22px rgba(0, 0, 0, 0.4);
}
@supports (backdrop-filter: blur(10px)) {
  .ed-load-pill {
    background: rgba(14, 16, 20, 0.6);
    backdrop-filter: blur(10px) saturate(1.2);
  }
}
.ed-load-spinner {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: color-mix(in srgb, var(--teal, #12a3b0) 80%, white);
  animation: ed-load-spin 0.7s linear infinite;
}
@keyframes ed-load-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ed-load-spinner {
    animation-duration: 2.4s;
  }
  .editor-media-load-overlay,
  .editor-timeline-load-overlay {
    animation: none;
  }
}
.editor-media-load-overlay .ws-sk-progress,
.editor-timeline-load-overlay .ws-sk-progress,
.sk-preview > .ws-sk-progress,
.sk-timeline > .ws-sk-progress {
  border-radius: 0;
}
.editor-media-load-overlay .ws-sk-bone,
.sk-preview .sk-ed-preview-bone {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(255, 255, 255, 0.1) 45%,
    rgba(255, 255, 255, 0.04) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s ease-in-out infinite;
}
.sk-preview .sk-ed-status {
  color: rgba(255, 255, 255, 0.5);
}
.ed-load-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
  min-height: 0;
  overflow: hidden;
  container-type: size;
}
/* Match .preview-stage: fit inside the wrap with the project aspect, not a
   giant fixed 720/820px slab that dwarfs the real player. */
.sk-ed-preview-bone {
  --ed-ar: 1.777778;
  box-sizing: border-box;
  flex: 0 1 auto;
  width: min(100%, calc((100% - 2.5rem) * var(--ed-ar)));
  max-width: 100%;
  max-height: calc(100% - 2.5rem);
  aspect-ratio: var(--ed-ar);
  height: auto;
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 4px 24px rgba(0, 0, 0, 0.55);
}
.ed-load-center .sk-ed-preview-bone {
  /* Container queries: size exactly like applyAspect() in preview.js */
  width: min(100cqw, calc((100cqh - 2.5rem) * var(--ed-ar)));
  max-width: 100cqw;
  max-height: calc(100cqh - 2.5rem);
}
.sk-ed-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: -0.01em;
  direction: rtl;
  text-align: center;
  min-width: 0;
}
/* Inside the pill the text sits on its own backdrop, so it can be legible
   rather than the dim placeholder grey used on the bare skeleton. */
.ed-load-pill .sk-ed-status {
  gap: 7px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.94);
}
.ed-load-pill .sk-ed-status-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sk-ed-status--tl {
  color: var(--text-2, #667);
  flex-shrink: 0;
  padding: 0 4px;
  justify-content: space-between;
  width: 100%;
}
/* Now a files count ("3/12"), not a percentage — hidden entirely when the
   current step has nothing real to count, instead of showing a fake 0%. */
.sk-ed-status-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--accent, #0a6b76);
  text-align: start;
  white-space: nowrap;
}
.sk-ed-status-pct[hidden] {
  display: none;
}
.sk-preview .sk-ed-status-pct,
.editor-media-load-overlay .sk-ed-status-pct {
  color: color-mix(in srgb, var(--teal, #12a3b0) 70%, white);
}
.ed-load-pill .sk-ed-status-pct {
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
  direction: ltr;
}
.sk-ed-clips {
  display: flex;
  align-items: stretch;
  gap: 4px;
  flex: 1;
  min-width: 0;
  padding: 4px 6px 4px 2px;
}
.sk-ed-clips--overlay {
  flex: 0 0 auto;
  height: 52px;
  padding: 0;
}
.sk-ed-clip {
  min-width: 48px;
  height: 100%;
  border-radius: 5px;
}
.sk-ed-clip:nth-child(2) {
  animation-delay: 0.08s;
}
.sk-ed-clip:nth-child(3) {
  animation-delay: 0.16s;
}
.sk-ed-clip:nth-child(4) {
  animation-delay: 0.24s;
}
.sk-ed-clip:nth-child(5) {
  animation-delay: 0.32s;
}

/* ── Skeleton Preview (mimics .editor-preview) ─── */
.sk-preview {
  background: #0a0a0c;
  border-radius: var(--r-md, 10px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  position: relative;
}

.sk-stage-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.sk-open-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 12px;
  box-sizing: border-box;
  container-type: size;
}
.sk-open-screen .sk-ed-preview-bone {
  width: min(100cqw, calc((100cqh - 2.5rem) * var(--ed-ar)));
  max-width: 100cqw;
  max-height: calc(100cqh - 2.5rem);
}

@media (prefers-reduced-motion: reduce) {
  .sk-ed-preview-bone,
  .sk-ed-clip,
  .editor-media-load-overlay .ws-sk-bone {
    animation: none !important;
  }
}

/* The actual video frame placeholder */
.sk-video-frame {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  border-radius: 8px;
  background: #0e1116;
  align-self: center;
  flex-shrink: 0;
  height: min(100%, calc(100vw / 2));
  width: 100%;
  max-height: calc(100vh - 280px);
}

/* Transport skeleton bar */
.sk-transport {
  height: 48px;
  background: rgba(0, 0, 0, 0.45);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  flex-shrink: 0;
}

.sk-tr-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.07);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.12) 40%,
    rgba(255, 255, 255, 0.18) 50%,
    rgba(255, 255, 255, 0.12) 60%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  animation: sk-sweep 1.5s ease-in-out infinite;
}
/* Play button is slightly larger */
.sk-tr-btn:nth-child(3) {
  width: 36px;
  border-radius: 14px;
}

.sk-tr-timecode {
  width: 90px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 4px;
  margin: 0 4px;
}

.sk-tr-scrub {
  flex: 1;
  height: 4px;
  border-radius: 2px;
}

/* ── Skeleton Timeline (mimics .editor-timeline) ─── */
.sk-timeline {
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
.sk-timeline > .sk-ed-status--tl {
  padding: 8px 14px 0;
}
.editor-timeline .timeline-scroll {
  position: relative;
}

/* Tools bar - matches .timeline-tools-bar's spacing + groups */
.sk-tools-bar {
  --tb-h: 39px;
  min-height: 48px;
  border-bottom: 1px solid
    color-mix(in srgb, #fff 40%, var(--divider, rgba(0, 0, 0, 0.06)));
  background: color-mix(in srgb, var(--surface-2, #fafafa) 72%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  flex-shrink: 0;
}

.sk-tool-pill {
  height: var(--tb-h, 39px);
  min-width: 45px;
  flex-shrink: 0;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.05);
}
/* Tool-bar groups so the skeleton reads as the real grouped layout */
.sk-tb-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.sk-tb-segment {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: var(--tb-h, 39px);
  padding: 2px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 10px;
  background: var(--surface, #fff);
  flex-shrink: 0;
  box-sizing: border-box;
}
.sk-tb-divider {
  width: 1px;
  height: 17px;
  background: var(--divider, rgba(0, 0, 0, 0.08));
  flex-shrink: 0;
  margin: 0 2px;
}
.sk-tb-spacer {
  flex: 1;
  min-width: 12px;
}
.sk-tb-export {
  width: 94px;
  height: var(--tb-h, 39px);
  border-radius: 10px;
  flex-shrink: 0;
}

/* Ruler (time ticks) above the tracks */
.sk-ruler {
  display: grid;
  grid-template-columns: 52px 1fr;
  height: 24px;
  border-bottom: 1px solid var(--divider, rgba(0, 0, 0, 0.06));
  flex-shrink: 0;
}
.sk-ruler-track {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 8px 4px;
  overflow: hidden;
}
.sk-ruler-tick {
  width: 1px;
  height: 7px;
  background: var(--border-strong, rgba(0, 0, 0, 0.16));
  flex-shrink: 0;
}

/* Tracks area */
.sk-tracks {
  padding: 0 0 6px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sk-track-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0;
  overflow: hidden;
}

.sk-track-label {
  background: var(--surface-2, #fafafa);
  border-radius: 4px;
  margin: 3px 2px 3px 6px;
}

.sk-track-content {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 3px 6px 3px 2px;
  overflow: hidden;
}

/* Simplified full-width track fill (replaces individual sk-clip blocks) */
.sk-track-content-fill {
  border-radius: 5px;
  margin: 3px 6px 3px 2px;
  background: rgba(0, 0, 0, 0.05);
}

/* Simple ruler placeholder */
.sk-ruler-simple {
  height: 24px;
  border-bottom: 1px solid var(--divider, rgba(0, 0, 0, 0.06));
  background: var(--surface-2, #fafafa);
  flex-shrink: 0;
}

.sk-clip {
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  min-width: 0;
}
/* Stagger the shimmer delay for a wave effect */
.sk-clip:nth-child(1) {
  animation-delay: 0s;
}
.sk-clip:nth-child(2) {
  animation-delay: 0.12s;
}
.sk-clip:nth-child(3) {
  animation-delay: 0.24s;
}
.sk-clip:nth-child(4) {
  animation-delay: 0.36s;
}
.sk-clip:nth-child(5) {
  animation-delay: 0.48s;
}
.sk-clip:nth-child(6) {
  animation-delay: 0.6s;
}

@media (prefers-reduced-motion: reduce) {
  .sk-shim,
  .sk-tr-btn,
  .sk-tr-timecode,
  .sk-tr-scrub,
  .sk-video-frame,
  .sk-clip,
  .sk-tool-pill {
    animation: none;
  }
}

/* ── end skeleton ─────────────────────────────────────────────────────────── */

.content-area:has(.editor-shell) {
  padding: var(--s-3) var(--s-4);
}

/* ===== Floating Back button (top-right of preview) ===== */
.editor-back-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  width: 34px;
  height: 34px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.08s;
}
.editor-back-btn:hover {
  background: rgba(0, 0, 0, 0.75);
}
.editor-back-btn:active {
  transform: scale(0.94);
}
.editor-back-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== Preview (stage + transport combined) ===== */
.editor-preview {
  grid-area: preview;
  background: #0a0a0c;
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  min-height: 0;
}

.preview-stage-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.preview-stage {
  position: relative;
  background: #000;
  overflow: hidden;
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 4px 24px rgba(0, 0, 0, 0.55),
    0 1px 4px rgba(0, 0, 0, 0.4);
}

.preview-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  /* No will-change here: promoting the video to its own GPU layer breaks
     screen-blend compositing of the VFX layer above it (siblings on separate
     layers can't blend against each other). The JS engine drives opacity/
     transform directly per-frame without needing this hint. */
}

.preview-video.poster-img {
  object-fit: contain;
}

/* Flash-frame overlay - white / light-leak blooms, driven by the transition
   engine above the clips so the clips themselves never get filter-mangled. */
.preview-flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
}

/* Movie fade in/out - black overlay above the picture and any transition. */
.preview-fade {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #000;
  opacity: 0;
  pointer-events: none;
  will-change: opacity;
}

/* Movie-wide subtitles / lyrics band (above the fade; layout/colour set inline
   per the user's style so the preview matches the libass export). */
.preview-subtitle {
  box-sizing: border-box;
  overflow: hidden;
}
.preview-subtitle-text {
  display: inline-block;
  word-break: break-word;
  transform-origin: center center;
}
.preview-subtitle-unit {
  transform-origin: center bottom;
}
.preview-subtitle-unit.is-line {
  display: block;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  pointer-events: none;
  padding: var(--s-5);
}

.preview-empty .empty-icon {
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  box-sizing: border-box;
}

.preview-empty .empty-icon svg {
  width: 100%;
  height: 100%;
}

.preview-empty .empty-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: -0.01em;
  direction: rtl;
}

.preview-empty .empty-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  direction: rtl;
  line-height: 1.5;
  max-width: 150px;
}

.preview-aspect-badge {
  position: absolute;
  top: 12px;
  left: 14px;
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
  z-index: 5;
}

/* ===== Transport (inside preview, at bottom) ===== */
.preview-transport {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  z-index: 6;
}

.tr-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.08s;
}
.tr-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}
.tr-btn:active {
  transform: scale(0.92);
}
.tr-btn svg {
  width: 12px;
  height: 12px;
}

.tr-play {
  width: 36px;
  height: 30px;
  border-radius: var(--r-pill);
  background: white;
  color: black;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s,
    transform 0.08s;
  margin-right: 4px;
  flex-shrink: 0;
}
.tr-play:hover {
  background: rgba(255, 255, 255, 0.92);
}
.tr-play:active {
  transform: scale(0.94);
}
.tr-play svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.tr-timecode {
  font-family: "SF Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.95);
  letter-spacing: 0.02em;
  min-width: 110px;
  text-align: center;
  flex-shrink: 0;
}

.tr-timecode .sep {
  opacity: 0.5;
  margin: 0 3px;
}
.tr-timecode .total {
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
}

.tr-scrub {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--r-pill);
  position: relative;
  cursor: pointer;
}

.tr-scrub-fill {
  position: absolute;
  inset-block: 0;
  left: 0;
  background: white;
  border-radius: var(--r-pill);
}

.tr-scrub-handle {
  position: absolute;
  top: 50%;
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.tr-scrub:hover .tr-scrub-handle {
  opacity: 1;
}

.tr-fullscreen {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.85);
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  margin-left: 4px;
  flex-shrink: 0;
  transition:
    background 0.15s,
    transform 0.08s;
}
.tr-fullscreen:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}
.tr-fullscreen:active {
  transform: scale(0.92);
}
.tr-fullscreen svg {
  width: 13px;
  height: 13px;
}

/* ===== Timeline panel (auto-height) ===== */
.editor-timeline {
  grid-area: timeline;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--accent) 5%, var(--surface)),
      var(--surface) 22%
    );
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  direction: ltr;
}

/* Tools bar inside timeline */
.timeline-tools-bar {
  --tb-h: 39px;
  --tb-icon: 16px;
  --tb-label: 9.5px;
  --tb-pill-bg: color-mix(in srgb, var(--surface) 82%, transparent);
  --tb-pill-border: var(--border);
  --tb-pill-shine: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 3px 4px;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.14),
      transparent 58%
    ),
    color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(14px) saturate(1.12);
  -webkit-backdrop-filter: blur(14px) saturate(1.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  min-height: 48px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  flex-shrink: 0;
  scrollbar-width: thin;
  container: editor-tools-bar / inline-size;
}

[data-theme="dark"] .timeline-tools-bar {
  --tb-pill-bg: color-mix(in srgb, var(--surface) 62%, transparent);
  --tb-pill-border: color-mix(in srgb, #fff 14%, var(--border));
  --tb-pill-shine: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 55%),
    color-mix(in srgb, var(--surface) 70%, transparent);
  border-bottom-color: var(--border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* BPM compact group — same height as tool buttons */
.tb-bpm-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--tb-pill-border, var(--border));
  border-radius: 11px;
  background: var(--tb-pill-bg, var(--surface));
  box-shadow: var(--tb-pill-shine, none);
  height: var(--tb-h, 39px);
  padding: 0 3px 0 6px;
  gap: 4px;
  flex-shrink: 0;
  transition:
    border-color 0.15s var(--ease-out),
    box-shadow 0.15s var(--ease-out);
  box-sizing: border-box;
}

.tb-bpm-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tb-bpm-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.tb-bpm-unit {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: 0.06em;
}

.tb-bpm-group input {
  width: 36px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0;
  color: var(--text);
}

.tb-bpm-group input:focus {
  outline: none;
}
.tb-bpm-group input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.tb-bpm-group button {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  background: transparent;
  border: none;
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
}

.tb-bpm-group button:hover:not(:disabled) {
  background: var(--surface-pressed);
  color: var(--accent);
}

.tb-bpm-group button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tb-bpm-group button svg {
  width: 13px;
  height: 13px;
}

.tb-bpm-smart {
  color: var(--accent);
}

.flicker-pool-picker-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(70vh, 560px);
}
.flicker-pool-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  overflow-y: auto;
  padding: 2px;
  max-height: 48vh;
}
.flicker-pool-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  text-align: start;
  overflow: hidden;
  transition:
    border-color 0.12s var(--ease-out),
    background 0.12s var(--ease-out),
    color 0.12s var(--ease-out);
}
.flicker-pool-card:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.flicker-pool-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.flicker-pool-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-3, #12151c);
}
.flicker-pool-card-badge {
  position: absolute;
  inset-inline-start: 6px;
  top: 6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.flicker-pool-card-label {
  padding: 0 8px 8px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.flicker-pool-picker-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.flicker-pool-picker-count {
  margin-inline-end: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

/* Beat tools ("סדר לביט" / "חיתוך לביט"). Deliberately plain: same surface,
   spacing and type scale as every other editor popover - no card-in-card. */
.popover.beatsync-popover {
  width: min(300px, calc(100vw - 16px));
  gap: 10px;
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.beatsync-popover--flicker {
  width: min(320px, calc(100vw - 16px));
}
.beatsync-popover::-webkit-scrollbar {
  width: 6px;
}
.beatsync-popover::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--border-strong);
}
.beatsync-tool-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--divider);
}
.beatsync-tool-title {
  flex: 1;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.beatsync-status {
  flex-shrink: 0;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  white-space: nowrap;
}
.beatsync-status.is-muted {
  color: var(--text-3);
}
.beatsync-reset-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  transition:
    border-color 0.12s var(--ease-out),
    background 0.12s var(--ease-out),
    color 0.12s var(--ease-out);
}
.beatsync-reset-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}
.beatsync-reset-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.beatsync-reset-btn svg {
  width: 13px;
  height: 13px;
}
/* Mode picker: two plain options side by side, label + one short hint. */
.beatsync-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.beatsync-mode {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition:
    border-color 0.12s var(--ease-out),
    background 0.12s var(--ease-out),
    color 0.12s var(--ease-out);
}
.beatsync-mode:hover:not(.is-selected) {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.beatsync-mode.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.beatsync-mode-label {
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}
.beatsync-mode-hint {
  color: var(--text-3);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.3;
}
.beatsync-mode.is-selected .beatsync-mode-hint {
  color: color-mix(in srgb, var(--accent) 65%, var(--text-3));
}
.beatsync-chip-grid {
  display: grid;
  gap: 5px;
}
.beatsync-chip-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.beatsync-chip-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.beatsync-chip-grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.beatsync-chip-grid--5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.beatsync-manual {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition:
    border-color 0.12s var(--ease-out),
    box-shadow 0.12s var(--ease-out);
}
.beatsync-manual:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.beatsync-popover > .input {
  min-height: 34px;
  border-radius: var(--r-sm);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.beatsync-popover > .input[hidden],
.beatsync-popover .beatsync-length-hint[hidden] {
  display: none;
}
.beatsync-manual-label {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
}
.beatsync-manual-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.beatsync-manual-input::-webkit-inner-spin-button,
.beatsync-manual-input::-webkit-outer-spin-button {
  opacity: 1;
}
.beatsync-manual-unit {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
}
.beatsync-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  cursor: pointer;
  transition:
    border-color 0.12s var(--ease-out),
    background 0.12s var(--ease-out),
    color 0.12s var(--ease-out);
}
.beatsync-chip:hover:not(.is-selected) {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--text);
}
.beatsync-chip.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
/* Labels and notes keep the shared popover scale - no boxes around them. */
.beatsync-popover .popover-label {
  margin: 2px 0 -4px;
}
.beatsync-popover .export-note {
  margin: 0;
  padding: 0;
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.45;
}
.beatsync-popover .beatsync-intro {
  color: var(--text-2);
}
/* Pinned to the bottom of the scroll box so the main action stays reachable
   when the panel is taller than the room it has - plain surface, no glass. */
.beatsync-footer {
  position: sticky;
  bottom: calc(var(--s-3) * -1);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 calc(var(--s-3) * -1) calc(var(--s-3) * -1);
  padding: var(--s-2) var(--s-3) var(--s-3);
  border-top: 1px solid var(--divider);
  background: var(--surface);
}
.beatsync-footer .btn {
  min-height: 34px;
  border-radius: var(--r-sm);
}
.beatsync-footer .beatsync-save-btn {
  min-height: 28px;
  color: var(--text-3);
  font-size: 11px;
}
.beatsync-advanced {
  padding-top: var(--s-2);
  border-top: 1px solid var(--divider);
}
.beatsync-advanced-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.beatsync-advanced-summary::-webkit-details-marker {
  display: none;
}
.beatsync-advanced-summary:hover {
  color: var(--text);
}
.beatsync-advanced-summary-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.beatsync-advanced-summary-copy small {
  overflow: hidden;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.beatsync-advanced-chevron {
  display: inline-flex;
  color: var(--text-3);
  transition: transform 0.16s var(--ease-out);
}
.beatsync-advanced-chevron svg {
  width: 14px;
  height: 14px;
}
.beatsync-advanced[open] .beatsync-advanced-chevron {
  transform: rotate(180deg);
}
.beatsync-advanced-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
}
.beatsync-advanced-body .beatsync-save-btn {
  min-height: 30px;
  margin-top: 4px;
  color: var(--text-3);
  font-size: 11px;
}
.export-note {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.45;
  padding: 4px 0;
}

/* ── Flicker Studio: the rhythm window ─────────────────────────────────────
   Built on the same shell as the other big editor modals (see .sub-modal-*):
   an icon chip and a subtitle in the header, one scrolling body, a footer whose
   hint sits between the ghost action and the primary one. The settings are
   behind the shared .tabs component rather than stacked, because ten labelled
   chip rows in a column read as one undifferentiated list. */
/* The modal BOX is what scrolls if you let it: `.modal` ships `padding: s-7`
   plus `max-height: 90vh; overflow-y: auto`, so a child asking for 90vh of its
   own overflows the box by exactly that padding and the whole window gets a
   scrollbar. Take the box over the same way the subtitles modal does — no
   padding, no scrolling, a flex column — and let the window fill it.

   The height is DEFINITE, not a max. A window that sizes to its content grows
   and shrinks every time you change tab — the monitor jumps, the footer moves,
   and the button you were about to press is somewhere else. Fixed height means
   the frame never moves and only the panel inside it changes. 720px is the
   tallest panel (the step grid) plus the chrome, so nothing is cramped and
   nothing is left as dead space. */
.modal.modal-lg:has(.flicker-studio),
.modal:has(.flicker-studio) {
  display: flex;
  flex-direction: column;
  width: min(1120px, 96vw);
  max-width: min(1120px, 96vw);
  height: min(92vh, 720px);
  max-height: min(92vh, 720px);
  padding: 0;
  overflow: hidden;
}

.flicker-studio {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0 16px 10px;
}

/* `.btn` and `.beatsync-chip` are display:flex, which beats the browser's own
   [hidden] rule — a hidden button would otherwise stay on screen. */
.flicker-studio [hidden] {
  display: none !important;
}

/* Header */
.fstudio-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0 8px;
  border-bottom: 1px solid var(--divider);
}
.fstudio-head-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.fstudio-head-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
}
.fstudio-head-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.fstudio-head-main {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.fstudio-head-sub {
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.35;
}
.fstudio-head-side {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.fstudio-bpm {
  padding: 3px 9px;
  border-radius: var(--r-pill, 999px);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fstudio-bpm.is-muted {
  background: var(--surface-pressed);
  color: var(--text-3);
}

/* Body */
.fstudio-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 7px 0 0;
}

/* ── Monitor: the thing being made, always above the settings ── */
.fstudio-monitor {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(0, 172px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
@media (max-width: 820px) {
  .fstudio-monitor {
    grid-template-columns: minmax(0, 1fr);
  }
}
.fstudio-screen {
  min-width: 0;
}
.fstudio-track {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
/* The read-out and the manual-slot notice on one row. */
.fstudio-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 16px;
  min-width: 0;
}
.fstudio-meta .btn {
  flex-shrink: 0;
  font-size: 11px;
}
.fstudio-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-sm, 8px);
  background: #000;
  overflow: hidden;
  border: 1px solid var(--border);
}
.fstudio-stage-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  will-change: opacity, transform;
}
.fstudio-stage-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
}
.fstudio-stage-note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  text-align: center;
}

/* The beat canvas */
.fstudio-canvas-wrap {
  position: relative;
  direction: ltr;
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 8px);
  background: var(--bg-3, #12151c);
  overflow: hidden;
}
.fstudio-canvas {
  display: block;
  width: 100%;
  touch-action: none; /* the slot painter owns the drag */
  cursor: pointer;
}
.fstudio-canvas-note {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-align: center;
  padding: 0 16px;
  pointer-events: none;
}

.fstudio-transport {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.fstudio-play {
  min-width: 92px;
  flex-shrink: 0;
}
.fstudio-readout {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fstudio-readout.is-slot {
  color: var(--text-2);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* Rides in the transport row, which has spare width. */
.fstudio-legend {
  display: flex;
  gap: 4px 10px;
  min-width: 0;
  overflow: hidden;
  margin-inline-start: auto;
}
.fstudio-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.fstudio-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.fstudio-legend-dot.is-black {
  background: transparent;
  border: 1px dashed var(--border-strong);
}
/* ── Tabs ── */
.fstudio-tabs {
  flex-shrink: 0;
  display: flex;
  align-self: stretch;
  gap: 2px;
}
.fstudio-tab {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
}
.fstudio-panels {
  flex: 1;
  min-height: 0;
}
.fstudio-panel {
  display: flex;
  flex-direction: column;
  gap: 9px;
  height: 100%;
  /* The last resort only: everything is sized to fit, and this keeps a very
     short screen (or a project with dozens of clips) usable instead of clipped. */
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.fstudio-panel[hidden] {
  display: none;
}
.fstudio-panel-intro {
  margin-bottom: -4px;
}

/* ── One field: title, control, plain-language line ── */
.fstudio-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.fstudio-field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.fstudio-field-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fstudio-field-value {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.fstudio-field-hint {
  font-size: 10.5px;
  color: var(--text-3);
  line-height: 1.4;
}
/* ── Option rows: one segmented control, not N loose buttons ──
   Six identically-bordered rectangles in a row read as an undifferentiated bar
   and give the selected one nowhere to stand out. This is the shape the app
   already uses for tabs: a pressed-in track with the chosen option lifted out
   of it, so a glance answers "which one is on" before you read any label. */
.fstudio-seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--r-sm);
  background: var(--surface-pressed);
  overflow: hidden;
}
.fstudio-seg-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 6px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-3);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background 0.14s var(--ease-out),
    color 0.14s var(--ease-out);
}
.fstudio-seg-btn:hover:not(.is-selected) {
  color: var(--text);
  background: var(--surface-hover);
}
.fstudio-seg-btn.is-selected {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}
.fstudio-seg-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── The density glyph ──
   Bars whose gaps ARE the answer: wide gaps are slow cutting, tight gaps are
   fast, and the build's gaps visibly close up toward the drop. */
.fstudio-glyph {
  display: flex;
  align-items: flex-end;
  height: 11px;
  opacity: 0.55;
}
.fstudio-seg-btn.is-selected .fstudio-glyph {
  opacity: 1;
}
.fstudio-glyph-bar {
  width: 2px;
  height: 11px;
  border-radius: 1px;
  background: currentColor;
  flex: 0 0 auto;
}
.fstudio-glyph-step {
  width: 4px;
  height: 4px;
  margin-inline-end: 2px;
  border-radius: 1px;
  border: 1px solid currentColor;
  flex: 0 0 auto;
}
.fstudio-glyph-step.is-on {
  background: currentColor;
}
/* Two short fields side by side, so a pair of chip rows costs one row's height
   instead of two. Collapses on a narrow modal. */
.fstudio-duo {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
@media (max-width: 700px) {
  .fstudio-duo {
    grid-template-columns: minmax(0, 1fr);
  }
}
.fstudio-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.fstudio-inline .fstudio-seg {
  flex: 1;
  min-width: 180px;
}
.fstudio-number {
  width: 84px;
  flex: 0 0 auto;
}
.fstudio-number[hidden] {
  display: none;
}
.fstudio-range {
  width: 100%;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.fstudio-note {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}
.fstudio-note[hidden] {
  display: none;
}
.fstudio-save {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-3);
}

/* A panel that only applies under one rate — indented so it reads as belonging
   to the choice above it rather than as another top-level list. */
.fstudio-subpanel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 8px);
  background: var(--surface-2, rgba(255, 255, 255, 0.03));
}
.fstudio-subpanel[hidden] {
  display: none;
}

/* ── Step sequencer ── */
.fstudio-steps {
  display: grid;
  gap: 3px;
  direction: ltr;
}
/* A fixed height, not a square: at sixteen steps across a wide panel a square
   step is fifty pixels tall, which is fifty pixels the window does not have. */
.fstudio-step {
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-3);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.1s var(--ease-out),
    border-color 0.1s var(--ease-out);
}
.fstudio-step.is-beat {
  border-color: var(--border-strong);
}
.fstudio-step:hover {
  border-color: var(--accent);
}
.fstudio-step.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Video picker ── */
.fstudio-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 7px;
  padding: 2px;
  align-content: start;
}
.fstudio-video {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  text-align: start;
  overflow: hidden;
  transition:
    border-color 0.12s var(--ease-out),
    background 0.12s var(--ease-out);
}
.fstudio-video.is-static {
  cursor: default;
}
.fstudio-video:not(.is-static):hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.fstudio-video.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.fstudio-video-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-3, #12151c);
}
.fstudio-video-badge {
  position: absolute;
  inset-inline-start: 5px;
  top: 5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.fstudio-video-name {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 7px 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Footer ── */
/* Hint above, actions below. As one flex row with `flex: 1` on the hint, a long
   sentence pushed the buttons into each other and shrank the primary action to
   the smallest thing in the footer. */
.fstudio-foot {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 7px;
  padding-top: 9px;
  border-top: 1px solid var(--divider);
}
.fstudio-foot-hint {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.4;
}
.fstudio-foot-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* The destructive/secondary action sits away from the primary one. */
.fstudio-foot-actions .btn-ghost:first-child {
  margin-inline-end: auto;
}
.fstudio-foot-actions .btn-primary {
  min-width: 132px;
}

/* A cluster of related tool buttons, kept visually tight within the bar. */
.tb-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

/* Pre-export checks menu — compact icon+label rows */
.popover.tb-checks-popover {
  width: min(188px, calc(100vw - 16px));
  padding: 5px;
  gap: 2px;
}
.tb-checks-popover .popover-title {
  margin: 0;
  padding: 3px 6px 2px;
  font-size: 10px;
  letter-spacing: 0.04em;
}
.tb-checks-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 34px;
  text-align: start;
  padding: 5px 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}
.tb-checks-item-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-2);
}
[data-theme="dark"] .tb-checks-item-icon {
  background: rgba(255, 255, 255, 0.06);
}
.tb-checks-item svg,
.tb-checks-item-icon svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  margin: 0;
  color: inherit;
}
.tb-checks-item-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
  flex: 1;
}
.tb-checks-item-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Hints live in the button title tooltip — keep DOM/CSS compact */
.tb-checks-item-hint {
  display: none;
}
.tb-checks-item:hover:not(:disabled) {
  background: var(--surface-hover, rgba(0, 0, 0, 0.05));
  color: var(--text);
}
.tb-checks-item:hover:not(:disabled) .tb-checks-item-icon {
  background: var(--accent-soft, rgba(0, 113, 227, 0.12));
  color: var(--accent);
}
.tb-checks-item:active:not(:disabled) {
  transform: scale(0.98);
}
.tb-checks-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Right-click menu on a layer / effect / caption block (timeline-block-menu.js) */
.popover.tl-block-menu {
  min-width: 120px;
  padding: 4px;
  gap: 2px;
  animation: none;
}
.tl-block-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  padding: 5px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
}
.tl-block-menu-item:hover,
.tl-block-menu-item:focus-visible {
  background: var(--surface-hover, rgba(0, 0, 0, 0.05));
  outline: none;
}
.tl-block-menu-item.is-danger {
  color: var(--red);
}
.tl-block-menu-item.is-danger:hover,
.tl-block-menu-item.is-danger:focus-visible {
  background: color-mix(in srgb, var(--red) 10%, transparent);
}

/* ── Clean tool button: icon centred, small label below ─────── */
.tb-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--tb-h, 39px);
  width: max-content;
  min-width: 48px;
  max-width: none;
  padding: 2px 6px;
  border-radius: 8px;
  background: transparent;
  color: color-mix(in srgb, var(--accent) 42%, var(--text-2));
  border: none;
  cursor: pointer;
  flex: 0 0 auto;
  overflow: hidden;
  box-sizing: border-box;
  transition:
    background 0.14s var(--ease-out),
    color 0.14s var(--ease-out);
}
/* תיקון / גודל / אפקטים - זמינים בלשונית עריכה; מוסתרים כאן בלבד */
.tb-btn.tb-btn--hidden-in-bar {
  display: none;
}
.tb-btn svg {
  width: var(--tb-icon, 15.5px);
  height: var(--tb-icon, 15.5px);
  flex-shrink: 0;
  transition: color 0.14s var(--ease-out);
}
.tb-btn-label {
  font-size: var(--tb-label, 9.5px);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: var(--text-2);
}
.tb-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  color: var(--accent);
}
.tb-btn:hover:not(:disabled) .tb-btn-label {
  color: color-mix(in srgb, var(--accent) 50%, var(--text));
}
[data-theme="dark"] .tb-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.tb-btn.is-active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  box-shadow: none;
}
.tb-btn.is-active .tb-btn-label {
  color: var(--accent);
}
[data-theme="dark"] .tb-btn.is-active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: none;
}
.tb-btn:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}
.tb-btn:active:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* Mobile-only tool bar actions (shown via polish.css ≤768px) */
.tb-mobile-only {
  display: none;
}

.tb-delete-clip:not(:disabled) {
  color: var(--red, #ff3b30);
}
.tb-delete-clip:not(:disabled) .tb-btn-label {
  color: var(--red, #ff3b30);
}

.tb-delete-clip:not(:disabled):hover {
  background: color-mix(in srgb, var(--red, #ff3b30) 12%, transparent);
  color: var(--red, #ff3b30);
}

/* "Has a value set" - same gray pressed look as is-active, no dot */
.tb-btn-dot {
  display: none;
}
.tb-btn.has-value {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  box-shadow: none;
}
.tb-btn.has-value .tb-btn-label {
  color: var(--accent);
}
[data-theme="dark"] .tb-btn.has-value {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  box-shadow: none;
}

/* Segmented container - pill that groups related tb-btn buttons */
.tb-segment {
  display: inline-flex;
  align-items: stretch;
  height: var(--tb-h, 39px);
  background: var(--tb-pill-bg, var(--surface));
  border: 1px solid var(--tb-pill-border, var(--border));
  border-radius: 11px;
  padding: 2px;
  gap: 0;
  flex: 0 0 auto;
  box-sizing: border-box;
  box-shadow: var(--tb-pill-shine, none);
}
.tb-segment .tb-btn {
  border-radius: 8px;
  height: 100%;
  flex: 0 0 auto;
  width: max-content;
  min-width: 48px;
  max-width: none;
  padding: 1px 6px;
}
.tb-segment .tb-btn.is-active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  box-shadow: none;
}
[data-theme="dark"] .tb-segment .tb-btn.is-active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  box-shadow: none;
}

/* Tool buttons (snap toggle, fix, speed, fade) */
.tb-snap {
  height: var(--tb-h, 36px);
  padding: 0 12px;
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  transition: all 0.12s var(--ease-out);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
}
[data-theme="dark"] .tb-snap {
  background: rgba(255, 255, 255, 0.03);
}
.tb-snap svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.tb-snap:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.tb-snap.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  box-shadow: none;
}
[data-theme="dark"] .tb-snap.is-active {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}
.tb-snap:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Zoom */
.tb-zoom {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: var(--tb-h, 39px);
  padding: 0 4px 0 8px;
  color: color-mix(in srgb, var(--accent) 35%, var(--text-3));
  flex-shrink: 0;
  border: 1px solid var(--tb-pill-border, var(--border));
  border-radius: 11px;
  background: var(--tb-pill-bg, var(--surface));
  box-shadow: var(--tb-pill-shine, none);
  box-sizing: border-box;
}

.tb-zoom > svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Fit-all is icon-only — keep a square that matches the bar height */
.tb-fit-all-btn {
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  flex: 0 0 28px;
  height: 28px;
  padding: 0;
  gap: 0;
  border-radius: 7px;
}
.tb-fit-all-btn .tb-btn-label {
  display: none;
}

.tb-zoom input[type="range"] {
  width: 44px;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--surface-pressed);
  border-radius: var(--r-pill);
  outline: none;
  cursor: pointer;
}

.tb-zoom input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: white;
  border: 0.5px solid var(--border);
  border-radius: 50%;
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.12),
    0 0.5px 1px rgba(0, 0, 0, 0.04);
  cursor: grab;
  transition: transform 0.1s var(--ease-out);
}

.tb-zoom input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

.tb-zoom input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: white;
  border: 0.5px solid var(--border);
  border-radius: 50%;
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.12),
    0 0.5px 1px rgba(0, 0, 0, 0.04);
  cursor: grab;
  transition: transform 0.1s var(--ease-out);
}

.tb-zoom input[type="range"]::-moz-range-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}

/* History buttons */
.tb-history {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  height: var(--tb-h, 39px);
  padding: 2px;
  flex-shrink: 0;
  border: 1px solid var(--tb-pill-border, var(--border));
  border-radius: 11px;
  background: var(--tb-pill-bg, var(--surface));
  box-shadow: var(--tb-pill-shine, none);
  box-sizing: border-box;
}

.tb-history-btn {
  width: 30px;
  height: 100%;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: color-mix(in srgb, var(--accent) 42%, var(--text-2));
  border: none;
  cursor: pointer;
  transition:
    background 0.12s var(--ease-out),
    color 0.12s var(--ease-out);
}
.tb-history-btn svg {
  width: 14px;
  height: 14px;
}

.tb-history-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.tb-history-btn:active:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.tb-history-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.tb-divider {
  width: 1px;
  height: 16px;
  background: color-mix(
    in srgb,
    var(--border-strong, var(--divider)) 45%,
    transparent
  );
  flex-shrink: 0;
  opacity: 1;
  margin: 0 2px;
  border-radius: 1px;
}

.tb-spacer {
  flex: 1;
  min-width: 4px;
}

/* Export */
.tb-export {
  height: var(--tb-h, 39px);
  padding: 0 10px;
  border-radius: 10px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, #fff 12%, var(--accent)),
    var(--accent) 55%
  );
  color: white;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid color-mix(in srgb, #000 10%, var(--accent));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: background 0.12s var(--ease-out);
  flex-shrink: 0;
  letter-spacing: -0.01em;
  box-sizing: border-box;
}

.tb-export:hover {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, #fff 10%, var(--accent-hover)),
    var(--accent-hover) 55%
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

/* Its own size only, never squeezed: with min-width 0 a narrow bar shrank it
   and «בדיקות» slid over undo/redo. The bar's spare width goes to the zoom
   slider instead (below). Sticky, so when a very narrow bar scrolls, ייצוא
   stays in view and the other tools slide under it (as on phones,
   polish.css). */
.timeline-tools-bar > .tb-group:has(.tb-export) {
  display: flex;
  flex: 0 0 auto;
  margin-inline-start: 0;
  justify-content: flex-end;
  position: sticky;
  inset-inline-end: 0;
  z-index: 3;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: -10px 0 10px -4px color-mix(in srgb, var(--surface) 90%, transparent);
}
.timeline-tools-bar .tb-export {
  flex: 0 0 auto;
  width: auto;
  min-width: 76px;
  max-width: none;
  padding: 0 14px;
  justify-content: center;
}
/* The zoom slider fills whatever width the bar has left. */
.timeline-tools-bar > .tb-group:has(> .tb-zoom),
.timeline-tools-bar .tb-zoom {
  flex: 1 0 auto;
}
.timeline-tools-bar .tb-zoom input[type="range"] {
  flex: 1 1 auto;
}
/* A narrower bar (a 1280px window) tightens the buttons a little, so the
   whole row, ייצוא included, still fits without scrolling. Touch and phone
   bars keep their own layout (polish.css). */
@media (hover: hover) and (min-width: 769px) {
  @container editor-tools-bar (max-width: 1310px) {
    .tb-segment .tb-btn,
    .tb-group > .tb-btn {
      min-width: 44px;
      padding-inline: 4px;
    }
    .timeline-tools-bar .tb-export {
      min-width: 64px;
      padding-inline: 8px;
    }
  }
}
.tb-export:active {
  transform: none;
  filter: brightness(0.96);
}
.tb-export svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ===== Mobile: tidy the timeline tools bar ===== */
@media (max-width: 640px) {
  .timeline-tools-bar {
    -webkit-overflow-scrolling: touch;
  }
  /* Dividers just add clutter on a scrolling row */
  .timeline-tools-bar .tb-divider {
    display: none;
  }
  .timeline-tools-bar .tb-zoom input[type="range"] {
    width: 48px;
  }
  .timeline-tools-bar .tb-spacer {
    flex: 1 1 auto;
    min-width: 4px;
  }
}

/* ===== Timeline tracks area ===== */
.timeline-scroll {
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.timeline-inner {
  position: relative;
  min-width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Ruler */
.timeline-ruler {
  position: sticky;
  top: 0;
  height: 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--divider);
  z-index: 4;
  margin-left: 52px;
}

.ruler-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.ruler-tick.major {
  background: var(--border-strong);
}

.ruler-tick .label {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 9px;
  font-family: "SF Mono", Consolas, monospace;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.ruler-beat {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 6px;
  background: var(--purple);
  opacity: 0.5;
}

.ruler-beat.downbeat {
  height: 10px;
  opacity: 0.85;
  width: 2px;
}

.ruler-marker {
  position: absolute;
  bottom: 0;
  width: 2px;
  height: 12px;
  z-index: 5;
  pointer-events: none;
  transform: translateX(-50%);
  background: var(--orange, #ff9500);
  opacity: 0.75;
  border-radius: 1px;
}

/* Tracks */
.timeline-tracks-wrap {
  flex: 1;
  position: relative;
  padding: 4px 0 6px;
}

.track-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: stretch;
  min-height: 0;
  margin-bottom: 2px;
}

.track-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  background: var(--surface-2);
  border-radius: var(--r-xs);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.06em;
  position: sticky;
  left: 0;
  z-index: 3;
}

.track-label .tl-sub {
  font-size: 8px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 1px;
  letter-spacing: 0;
}

.track-label.is-clickable {
  cursor: pointer;
  transition:
    background 0.12s var(--ease-out),
    color 0.12s var(--ease-out);
}
.track-label.is-clickable:hover {
  background: var(--surface-hover);
  color: var(--accent);
}

.track-row.video .track-label.is-muted {
  color: var(--text-muted);
}
.track-row.video .track-label.is-muted .tl-sub {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.track-label-audio,
.track-label-overlays,
.track-label-subtitles {
  padding: 0;
}

.track-label-body {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
}

.track-label-body.is-clickable {
  cursor: pointer;
  transition:
    background 0.12s var(--ease-out),
    color 0.12s var(--ease-out);
}

.track-label-body.is-clickable:hover {
  background: var(--surface-hover);
  color: var(--accent);
}

.track-label-expand {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  bottom: 0;
  height: 12px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition:
    background 0.12s var(--ease-out),
    color 0.12s var(--ease-out);
}

.track-label-expand svg {
  display: block;
  transition: transform 0.12s var(--ease-out);
}

.track-label-expand:hover {
  background: var(--surface-hover);
  color: var(--accent);
}

.track-label-expand.is-open svg {
  transform: rotate(180deg);
}

.track-label-expand.has-hidden-audio {
  color: var(--text-2);
}

.track-label:has(.track-label-expand) .track-label-body {
  padding-bottom: 10px;
}

.track-content {
  position: relative;
  background: var(--surface-2);
  border-radius: var(--r-xs);
  min-height: 52px;
  height: 52px;
  overflow: hidden;
}

.track-content.video {
  min-height: 60px;
  height: 60px;
}
.track-content.audio {
  min-height: 36px;
  height: 36px;
}

.track-row.video .track-label,
.track-row.video .track-content {
  min-height: 60px;
  height: 60px;
}
.track-row.audio,
.track-row.overlays,
.track-row.subtitles {
  min-height: 36px;
  height: 36px;
  margin-bottom: 1px;
}
.track-row.audio .track-label,
.track-row.audio .track-content,
.track-row.overlays .track-label,
.track-row.overlays .track-content,
.track-row.subtitles .track-label,
.track-row.subtitles .track-content {
  min-height: 36px;
  height: 36px;
}
.track-row.audio.is-empty .track-label-body,
.track-row.overlays.is-empty .track-label-body,
.track-row.subtitles.is-empty .track-label-body {
  color: var(--text-3);
}

.track-row.audio.is-muted .track-label-body,
.track-row.subtitles.is-muted .track-label-body {
  color: var(--text-muted);
}

.track-row-add .track-add-btn {
  border: 1px dashed var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--text-3);
  width: 100%;
  min-height: 44px;
  transition:
    background 0.12s var(--ease-out),
    color 0.12s var(--ease-out),
    border-color 0.12s var(--ease-out);
}
.track-row-add .track-add-btn:hover {
  background: var(--surface-hover);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.track-row-add .track-add-content {
  background: transparent;
  border: 1px dashed var(--border);
  min-height: 44px;
  height: 44px;
}

/* Clip */
.tl-clip {
  position: absolute;
  top: 3px;
  bottom: 3px;
  border-radius: var(--r-xs);
  background: linear-gradient(180deg, #2a3142, #1c2230);
  overflow: hidden;
  cursor: grab;
  transition:
    box-shadow 0.15s,
    transform 0.15s;
  border: 1.5px solid transparent;
  user-select: none;
  z-index: 1;
}

.tl-clip:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 2;
}

.tl-clip.is-selected {
  border-color: var(--orange);
  box-shadow:
    0 0 0 2px var(--orange),
    0 2px 10px rgba(255, 149, 0, 0.45);
  z-index: 3;
}

/* Lift the selected clip's image out of the dimmed crowd so it clearly reads
   as the active one. */
.tl-clip.is-selected .tl-clip-thumb-video,
.tl-clip.is-selected .tl-clip-thumb {
  filter: brightness(1);
}

.tl-clip.is-dragging {
  opacity: 0.85;
  cursor: grabbing;
  z-index: 10;
}

.tl-clip-thumb {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.7);
}

/* <video> element used as a clip's first-frame thumbnail */
.tl-clip-thumb-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.72);
  pointer-events: none;
  background: #000;
}

/* Blank tail - the media ends before the clip's fixed slot; the rest plays
   black. An OPAQUE empty box (the footage thumb stops at the media end), with
   a white/black checkerboard that reads as "no video here". */
.tl-clip-gap {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-conic-gradient(#232937 0% 25%, #0d1017 0% 50%) 0 0 /
    12px 12px;
  border-left: 1px dashed rgba(255, 255, 255, 0.35);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Gap actions: fill the slot by slowing the video, or delete the gap
   (shrink the clip to its real video length). */
.tl-gap-actions {
  display: flex;
  gap: 4px;
}

.tl-gap-btn {
  pointer-events: auto;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(10, 13, 20, 0.85);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition:
    background 0.12s var(--ease-out),
    color 0.12s var(--ease-out),
    border-color 0.12s var(--ease-out);
}

.tl-gap-fill:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.tl-gap-close:hover {
  background: var(--danger, #e5484d);
  border-color: var(--danger, #e5484d);
  color: white;
}

/* Audio waveform drawn over the clip's lower strip (visual only) */
.tl-clip-wave {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22px;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.35), transparent);
}
.tl-clip-wave canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Per-clip audio region editor (modal) ───────────────────────────────── */
.modal:has(.clip-audio-editor) {
  display: flex;
  flex-direction: column;
  width: min(980px, 96vw);
  max-width: min(980px, 96vw);
  max-height: min(90dvh, 780px);
  padding: 0;
  overflow: hidden;
}

.clip-audio-editor {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: inherit;
  min-height: 0;
  direction: rtl;
  text-align: right;
  color: var(--text);
  background: var(--surface);
  overflow: hidden;
}

.cae-modal-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px 11px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.cae-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
}

.cae-modal-title-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.cae-modal-title-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cae-modal-title-main {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.cae-modal-title-sub {
  max-width: min(560px, 68vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.3;
}

.cae-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  background: var(--surface-2);
}

.cae-workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.cae-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--divider);
  background: color-mix(in srgb, var(--surface-2) 65%, var(--surface));
}

.cae-toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.cae-toolbar-group--mix {
  gap: 4px;
  padding: 2px 4px 2px 2px;
  border: 1px solid var(--divider);
  border-radius: 10px;
  background: var(--surface);
}

.cae-toolbar-sep {
  width: 1px;
  align-self: stretch;
  margin: 4px 0;
  background: var(--divider);
}

.cae-toolbar-spacer {
  flex: 1;
}

.cae-toolbtn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s,
    border-color 0.12s;
}

.cae-toolbtn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.cae-toolbtn.is-on {
  background: var(--accent-soft);
  color: var(--accent);
}

.cae-toolbtn.is-muted {
  color: var(--text-muted);
}

.cae-toolbtn--ai {
  width: auto;
  min-height: 34px;
  padding: 0 12px;
  gap: 7px;
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.cae-toolbtn--ai:hover:not(:disabled) {
  filter: brightness(1.03);
}

.cae-toolbtn--ai:disabled {
  opacity: 0.45;
  cursor: default;
  filter: none;
}

.cae-toolbtn-label {
  white-space: nowrap;
}

.cae-vol {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  width: min(150px, 26vw);
  min-width: 88px;
  height: 34px;
  padding: 0 8px 0 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
}

.cae-vol-label {
  display: none;
}

.cae-vol-range {
  width: 100%;
  height: 3px;
  accent-color: var(--accent);
  cursor: pointer;
}

.cae-tool-val {
  min-width: 30px;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-align: end;
}

.cae-transport-play {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition:
    filter 0.12s,
    transform 0.1s;
}

.cae-transport-play:hover {
  filter: brightness(1.06);
}

.cae-transport-play.is-playing {
  background: var(--text);
}

.cae-transport-time {
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text-2);
  min-width: 7.5ch;
}

.cae-canvas {
  flex: 1 1 auto;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 10px;
  background: var(--surface);
}

.cae-wave-outer {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.cae-time-ruler {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
  direction: ltr;
}

.cae-time-mark {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

.cae-wave {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 200px;
  height: 100%;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px) 0 50% /
      100% 50%,
    linear-gradient(145deg, #0b0e14 0%, #151b26 55%, #1c2736 100%);
  border: 1px solid color-mix(in srgb, var(--border) 56%, transparent);
  overflow: hidden;
  user-select: none;
  touch-action: none;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 -18px 34px rgba(0, 0, 0, 0.22);
}

.cae-wave-canvas {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  pointer-events: none;
}

.cae-wave-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.cae-overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  z-index: 2;
}

.cae-region {
  position: absolute;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--red) 24%, transparent);
  border-inline: 2px solid color-mix(in srgb, var(--red) 70%, #fff);
  box-sizing: border-box;
  cursor: pointer;
}

.cae-region.is-selected {
  background: color-mix(in srgb, var(--red) 36%, transparent);
  border-inline-color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.cae-region.is-transient {
  opacity: 0.75;
  pointer-events: none;
}

.cae-fade {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
  opacity: 0.55;
}

.cae-fade-in {
  background: linear-gradient(
    to right,
    transparent,
    color-mix(in srgb, var(--red) 35%, transparent)
  );
}

.cae-fade-out {
  background: linear-gradient(
    to left,
    transparent,
    color-mix(in srgb, var(--red) 35%, transparent)
  );
}

.cae-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  z-index: 3;
}

/* PHYSICAL left/right, never inset-inline-*: the modal is RTL but the waveform
   is a left-to-right time axis (every band is placed with `left: %`). Logical
   insets flipped the handles onto the opposite edges, so grabbing a region's
   start dragged its end - and the region collapsed to a sliver. */
.cae-handle-start {
  left: -4px;
  right: auto;
}

.cae-handle-end {
  right: -4px;
  left: auto;
}

.cae-handle:hover {
  background: rgba(255, 255, 255, 0.18);
}

.cae-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px; /* physical: the axis is LTR inside an RTL modal */
  background: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
  z-index: 4;
  pointer-events: none;
  display: none;
}

.cae-region-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cae-region-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s,
    color 0.12s;
}

.cae-region-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--accent);
}

.cae-region-chip.is-selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

.cae-region-chip-time {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  color: var(--text-3);
  font-weight: 500;
}

.cae-region-chip.is-selected .cae-region-chip-time {
  color: inherit;
}

.cae-clear-all {
  align-self: flex-start;
  font-size: 11.5px;
}

.cae-editor-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cae-editor-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.cae-fades {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cae-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cae-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cae-field-head label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
}

.cae-slider {
  width: 100%;
  accent-color: var(--accent);
}

.cae-val {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}

.cae-delete {
  color: var(--text-3);
}

.cae-delete:hover {
  color: var(--red);
}

/* Mute-region lane under the canvas — reads as a track, not a button list */
.cae-lane {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 14px 10px;
  border-top: 1px solid var(--divider);
  background: color-mix(in srgb, var(--surface-2) 50%, var(--surface));
  min-height: 52px;
}

.cae-lane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cae-lane-title {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cae-region-count {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--divider);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
}

.cae-regions {
  display: contents;
}

.cae-region-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 28px;
}

.cae-editor-panel {
  display: none;
  flex-shrink: 0;
  border-top: 1px solid var(--divider);
  background: var(--surface);
  padding: 10px 14px 12px;
}

.cae-editor-panel.is-visible {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cae-modal-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--divider);
  background: var(--surface);
}

.cae-footer-spacer {
  flex: 1;
}

.cae-footer-hint {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.35;
}

.cae-done {
  min-height: 34px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 700;
}

@media (max-width: 720px) {
  .modal:has(.clip-audio-editor) {
    width: min(96vw, 960px);
    max-height: min(94dvh, 820px);
  }
  .cae-canvas {
    min-height: 180px;
  }
  .cae-toolbar {
    flex-wrap: wrap;
  }
  .cae-toolbtn-label {
    display: none;
  }
}

/* ── Library audio editor (cut middle → save as new copy) ───────────────── */
/* The studio chrome lives in the "professional workspace" block further down;
   only the shell fit and the header subtitle belong here. */
.library-audio-editor.clip-audio-editor {
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.library-audio-editor .cae-subtitle {
  max-width: min(720px, 60vw);
  overflow: hidden;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lae-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
  /* Sits in an LTR strip (time flows left→right) — the Hebrew status text
     inside still reads right-to-left. */
  direction: rtl;
}

.lae-result-dur {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.lae-play-mode {
  min-height: 28px;
  max-width: min(220px, 42vw);
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
}

.lae-zoom {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.lae-bpm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.lae-bpm-input {
  width: 3.2em;
  min-height: 26px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.lae-bpm-input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.lae-bpm-input::-webkit-outer-spin-button,
.lae-bpm-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.lae-bpm-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.lae-bpm-unit {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

.lae-bpm-detect,
.lae-beat-grid-btn {
  min-height: 26px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 700;
}

.lae-beat-grid-btn.is-on {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.lae-zoom-label {
  min-width: 2.4em;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.lae-zoom-btn {
  width: 26px;
  min-height: 26px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.lae-zoom-reset {
  min-height: 26px;
  padding: 0 7px;
  font-size: 10.5px;
  font-weight: 700;
}

.lae-scroll {
  display: block;
  width: 100%;
  margin-top: 6px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.lae-scroll[hidden] {
  display: none;
}

.lae-add-marker {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 28px;
  font-size: 12px;
  font-weight: 700;
}

.lae-marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.lae-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--ember);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--surface) 70%, transparent);
  pointer-events: auto;
  cursor: pointer;
  z-index: 4;
}

.lae-marker.is-selected {
  width: 3px;
  margin-left: -1.5px;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--surface) 85%, transparent),
    0 0 8px color-mix(in srgb, var(--ember) 45%, transparent);
}

.lae-marker-flag {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 3px;
  background: var(--ember);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.lae-marker.is-selected .lae-marker-flag {
  background: color-mix(in srgb, var(--ember) 80%, #fff);
}

.lae-marker-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.lae-marker-list:empty {
  display: none;
}

.lae-marker-empty {
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 500;
}

.lae-marker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.lae-marker-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 6px 0 8px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--ember) 35%, var(--border));
  background: var(--ember-soft);
  color: var(--text-2);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
}

.lae-marker-chip:hover,
.lae-marker-chip.is-selected {
  border-color: color-mix(in srgb, var(--ember) 60%, var(--border));
  background: color-mix(in srgb, var(--ember) 20%, var(--surface));
  color: var(--text);
}

.lae-marker-chip-n {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--ember);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
}

.lae-marker-chip-t {
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

.lae-marker-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
}

.lae-marker-chip-x:hover {
  background: color-mix(in srgb, var(--red) 18%, transparent);
  color: var(--red);
}

.lae-precise-row {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.library-audio-editor .lae-region-list {
  min-height: 0;
  gap: 4px;
}

.library-audio-editor .lae-region-list:empty,
.library-audio-editor .lae-region-list.is-empty {
  display: none;
}

.library-audio-editor .lae-region-list .cae-region-chips {
  flex: 0 1 auto;
}

.library-audio-editor .cae-clear-all {
  margin-inline-start: 0;
}

/* Keep cut chips visible so each one can be removed individually. */
.library-audio-editor
  .cae-regions:has(.lae-editor-panel.is-visible)
  .lae-region-list {
  display: flex;
}

.lae-cut-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.lae-cut-chip {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.lae-cut-chip-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

.lae-cut-chip-n {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--red) 22%, var(--surface));
  color: var(--red);
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}

.lae-cut-chip.is-selected .lae-cut-chip-n {
  background: var(--red);
  color: #fff;
}

.lae-cut-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 28px;
  border: none;
  border-inline-start: 1px solid
    color-mix(in srgb, var(--border) 80%, transparent);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.lae-cut-chip-x:hover {
  background: color-mix(in srgb, var(--red) 16%, transparent);
  color: var(--red);
}

.lae-clear-cuts {
  min-height: 28px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-3);
}

.library-audio-editor .cae-editor-panel.is-visible,
.library-audio-editor .lae-editor-panel.is-visible {
  padding-top: 0;
  border-top: none;
  overflow: visible;
}

.lae-cut-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.lae-cut-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}

.lae-cut-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-width: 0;
}

.lae-cut-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  white-space: nowrap;
}

.lae-cut-range {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: isolate;
}

.lae-cut-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.library-audio-editor .cae-delete {
  margin-top: 0;
  align-self: center;
}

.lae-precise {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  min-width: 0;
}

.lae-precise-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
}

.lae-precise-lab {
  min-width: 1.6em;
  text-align: center;
}

.lae-nudge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  direction: ltr;
  unicode-bidi: isolate;
}

.lae-nudge-btn {
  width: 28px;
  min-width: 28px;
  min-height: 30px;
  flex-shrink: 0;
}

.lae-time-input {
  box-sizing: border-box;
  width: 5.75rem;
  min-width: 5.75rem;
  height: 30px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  line-height: 30px;
  text-align: center;
  direction: ltr;
  unicode-bidi: isolate;
  appearance: textfield;
  -moz-appearance: textfield;
}

.lae-time-input::-webkit-outer-spin-button,
.lae-time-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.library-audio-editor .cae-region.lae-cut {
  background: color-mix(in srgb, var(--red) 20%, transparent);
  border-inline: 2px solid color-mix(in srgb, var(--red) 75%, transparent);
}

.library-audio-editor .cae-region.lae-cut.is-selected {
  background: color-mix(in srgb, var(--red) 32%, transparent);
  border-inline-color: var(--red);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 30%, transparent);
}

.lae-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.lae-footer-note {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
}

.lae-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
}

.lae-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
}

@media (max-width: 520px) {
  .cae-wave-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .lae-toolbar-left {
    justify-content: space-between;
  }

  .lae-play-mode {
    max-width: none;
    flex: 1;
  }
}

/* ── Library audio studio — professional workspace ──────────────────────── */
.modal:has(.library-audio-editor) {
  display: flex;
  flex-direction: column;
  width: min(1180px, calc(100vw - 48px));
  max-width: min(1180px, calc(100vw - 48px));
  height: min(92dvh, 880px);
  max-height: min(92dvh, 880px);
  padding: 0;
  overflow: hidden;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}

.library-audio-editor .cae-header {
  min-height: 60px;
  padding: var(--s-4) var(--s-6);
  margin-bottom: 0;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.library-audio-editor .modal-title {
  font-size: 17px;
  font-weight: 600;
}

.library-audio-editor .cae-title-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.library-audio-editor .cae-title-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.library-audio-editor .cae-title-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  box-shadow: none;
}

.library-audio-editor .cae-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--surface-2);
  overflow: hidden;
}

.lae-commandbar {
  min-height: 46px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px var(--s-4);
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: thin;
}

.lae-command-group,
.lae-tool-picker {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}

.lae-command-spacer {
  flex: 1 1 auto;
  min-width: 12px;
}

.lae-command-sep {
  width: 1px;
  height: 28px;
  flex: 0 0 auto;
  margin: 0 2px;
  background: var(--divider);
}

.lae-command-btn {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: 0.14s ease;
}

.lae-command-btn:hover:not(:disabled) {
  border-color: transparent;
  background: var(--surface-hover);
  color: var(--text);
}

.lae-command-btn.is-active {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
}

.lae-command-btn:disabled {
  opacity: 0.38;
  cursor: default;
}

.lae-command-btn--compact span {
  display: none;
}

.lae-command-btn--compact {
  width: 32px;
  padding: 0;
}

.library-audio-editor .lae-add-marker {
  min-height: 32px;
  border-color: transparent;
  font-size: 11.5px;
}

.library-audio-editor .lae-bpm,
.library-audio-editor .lae-zoom {
  flex: 0 0 auto;
  min-height: 34px;
  border-radius: 8px;
  background: var(--surface-2);
}

.lae-workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  direction: ltr;
  overflow: hidden;
}

.lae-inspector {
  direction: rtl;
}

/* The whole edit stage is a time surface: the ruler, the waveform, the cut and
   marker lanes and the zoom scrollbar all run left→right, so the stage is LTR
   and only the Hebrew text leaves inside it are flipped back to RTL. */
.lae-edit-stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  overflow: hidden;
  direction: ltr;
  background: var(--surface-2);
}

.library-audio-editor .lae-wave-card {
  flex: 1 1 auto;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.library-audio-editor .cae-wave-toolbar {
  min-height: 42px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 7px 12px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.lae-tool-hint {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: rtl;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.library-audio-editor .cae-wave-outer {
  flex: 1 1 auto;
  min-height: 0;
  gap: 0;
  padding: 0 12px 9px;
  background: var(--surface);
}

.library-audio-editor .cae-wave {
  flex: 1 1 auto;
  min-height: 220px;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  box-shadow: inset 0 1px 2px color-mix(in srgb, var(--text) 6%, transparent);
}

.library-audio-editor .cae-wave-loading {
  color: var(--text-3);
  font-size: 12.5px;
  font-weight: 600;
}

/* Red is the site's danger colour and already marks the cut bands — the
   playhead stays on the accent, like every other scrubber in the app. */
.library-audio-editor .cae-playhead {
  width: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--surface) 60%, transparent);
}

.library-audio-editor .cae-overlay[data-tool="select"] {
  cursor: text;
}

.library-audio-editor .cae-overlay[data-tool="range"] {
  cursor: crosshair;
}

.library-audio-editor .cae-overlay[data-tool="hand"] {
  cursor: grab;
}

.library-audio-editor .cae-overlay[data-tool="hand"]:active {
  cursor: grabbing;
}

.lae-pro-ruler {
  position: relative;
  height: 29px;
  flex: 0 0 29px;
  display: block;
  padding: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--divider);
  color: var(--text-3);
  background: var(--surface);
}

.lae-ruler-tick {
  position: absolute;
  inset-block: 0;
  transform: translateX(-50%);
  pointer-events: none;
}

.lae-ruler-tick i {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 7px;
  background: var(--text-muted);
}

.lae-ruler-tick b {
  position: absolute;
  left: 50%;
  top: 4px;
  transform: translateX(-50%);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 9.5px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

.lae-ruler-tick.is-start {
  transform: none;
}

.lae-ruler-tick.is-start b {
  left: 3px;
  transform: none;
}

.lae-ruler-tick.is-end {
  transform: translateX(-100%);
}

.lae-ruler-tick.is-end b {
  left: auto;
  right: 3px;
  transform: none;
}

.library-audio-editor .lae-scroll {
  height: 16px;
  margin: 7px 0 0;
}

.library-audio-editor .lae-lanes {
  flex: 0 0 auto;
  min-height: 96px;
  max-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.lae-lane-row {
  min-height: 47px;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  direction: ltr;
  border-bottom: 1px solid var(--divider);
}

.lae-lane-row:last-child {
  border-bottom: 0;
}

.lae-lane-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-right: 1px solid var(--divider);
  direction: rtl;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 800;
}

.lae-lane-label--cut {
  background: var(--surface-2);
  color: var(--text-2);
}

/* Chip 1 is the earliest cut/marker, so the lane must run the same way as the
   waveform above it — left→right — or the numbering reads backwards. */
.lae-lane-row > .lae-marker-list,
.lae-lane-row > .lae-region-list {
  min-width: 0;
  min-height: 46px;
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: 6px;
  padding: 7px 9px;
  direction: ltr;
}

.library-audio-editor .lae-clear-cuts {
  direction: rtl;
  margin-inline-start: 4px;
}

.library-audio-editor .lae-region-list.is-empty,
.library-audio-editor .lae-marker-list:empty {
  display: flex;
}

.library-audio-editor .lae-region-list.is-empty::before,
.library-audio-editor .lae-marker-list:empty::before {
  direction: rtl;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.library-audio-editor .lae-region-list.is-empty::before {
  content: "אין טווחים למחיקה";
}

.library-audio-editor .lae-marker-list:empty::before {
  content: "אין סמנים";
}

.lae-inspector {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--divider);
  background: var(--surface);
}

.lae-inspector-section {
  padding: var(--s-4);
  border-bottom: 1px solid var(--divider);
}

.lae-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: var(--s-3);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.lae-file-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lae-file-stats > span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 9px;
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.lae-file-stats b {
  color: var(--text-muted);
  font-size: 9.5px;
  font-weight: 750;
}

.lae-file-stats em {
  overflow: hidden;
  color: var(--text-2);
  font-size: 11.5px;
  font-style: normal;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lae-selection-empty {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.lae-selection-section:has(.lae-editor-panel.is-visible) .lae-selection-empty {
  display: none;
}

.library-audio-editor .lae-editor-panel.is-visible {
  display: block;
  padding: 0;
  background: transparent;
}

.library-audio-editor .lae-cut-editor {
  gap: 10px;
  padding: 0;
  border: none;
  background: transparent;
}

.library-audio-editor .lae-cut-head {
  align-items: flex-start;
  flex-direction: column;
}

.library-audio-editor .lae-cut-actions {
  align-self: stretch;
  justify-content: space-between;
}

.library-audio-editor .lae-precise {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.library-audio-editor .lae-precise-field {
  justify-content: space-between;
}

.lae-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
}

.lae-setting--stack {
  align-items: stretch;
  flex-direction: column;
  gap: 7px;
}

.lae-setting--stack > span {
  display: flex;
  justify-content: space-between;
}

.lae-setting-value {
  color: var(--accent);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10.5px;
}

.lae-output-range {
  width: 100%;
  accent-color: var(--accent);
}

.lae-check-setting {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 12px;
  padding: 9px;
  border: 1px solid var(--divider);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  cursor: pointer;
}

.lae-check-setting input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.lae-check-setting span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lae-check-setting b {
  color: var(--text-2);
  font-size: 11.5px;
}

.lae-check-setting small {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
}

.lae-setting-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lae-setting-pair .lae-setting {
  align-items: stretch;
  flex-direction: column;
  gap: 5px;
}

.lae-setting-number,
.lae-setting-select {
  min-width: 0;
  height: 30px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.lae-setting-number {
  width: 100%;
  direction: ltr;
}

.lae-setting-select {
  width: 96px;
}

.lae-reset-output {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--divider);
}

.lae-transport {
  min-height: 52px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 7px 14px;
  border-top: 1px solid var(--divider);
  background: var(--surface);
  direction: ltr;
}

.lae-transport-controls {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.lae-transport-icon,
.lae-transport-play {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}

.lae-transport-icon:hover,
.lae-transport-icon.is-active {
  border-color: transparent;
  background: var(--surface-hover);
  color: var(--accent);
}

.lae-transport-play {
  width: 38px;
  height: 38px;
  margin: 0 3px;
  border-color: var(--accent);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

.lae-transport-play.is-playing {
  background: var(--red);
  border-color: var(--red);
}

.lae-stop-symbol {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: currentColor;
}

.lae-transport-time {
  min-width: 132px;
  color: var(--text);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.lae-meter {
  width: min(250px, 22vw);
  display: grid;
  grid-template-columns: 11px minmax(45px, 1fr);
  align-items: center;
  gap: 3px 5px;
  direction: ltr;
}

.lae-meter-label {
  color: var(--text-muted);
  font-size: 8px;
  font-weight: 800;
}

.lae-meter-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 10%, transparent);
}

.lae-meter-fill {
  width: 100%;
  height: 100%;
  display: block;
  transform: scaleX(0);
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    var(--green) 0 68%,
    var(--orange) 84%,
    var(--red) 100%
  );
  transition: transform 65ms linear;
}

.lae-transport-spacer {
  flex: 1 1 auto;
}

.library-audio-editor .lae-play-mode {
  min-height: 32px;
  max-width: 220px;
  direction: rtl;
  background: var(--surface);
}

.library-audio-editor .lae-footer {
  min-height: 52px;
  margin: 0;
  padding: 8px 14px;
  border: 0;
  border-top: 1px solid var(--divider);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}

.library-audio-editor .lae-save-btn {
  min-height: 36px;
  padding: 0 18px;
  border-radius: var(--r-sm);
  box-shadow: none;
}

@media (max-width: 980px) {
  .lae-workspace {
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .lae-command-btn span {
    display: none;
  }

  .lae-command-btn {
    width: 32px;
    padding: 0;
  }

  .lae-tool-hint {
    display: none;
  }
}

@media (max-width: 760px) {
  .modal:has(.library-audio-editor) {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .library-audio-editor .cae-body {
    overflow-y: auto;
  }

  .lae-workspace {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .lae-edit-stage {
    min-height: 420px;
    overflow: visible;
  }

  .lae-inspector {
    display: grid;
    grid-template-columns: 1fr;
    overflow: visible;
    border-top: 1px solid var(--divider);
    border-left: 0;
  }

  .library-audio-editor .lae-wave-card {
    min-height: 310px;
  }

  .library-audio-editor .cae-wave {
    min-height: 190px;
  }

  .lae-meter {
    display: none;
  }

  .lae-transport-time {
    min-width: 108px;
    font-size: 10.5px;
  }

  .library-audio-editor .lae-play-mode {
    max-width: 150px;
  }
}

/* Speed badge - shown when clip is faster or slower than 1×. */
.tl-clip-speed {
  position: absolute;
  top: 4px;
  right: 5px;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 15px;
  padding: 0 4px 0 3px;
  border: none;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  font-family: "SF Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
  cursor: pointer;
  opacity: 0.95;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition:
    opacity 0.15s,
    background 0.15s;
}
.tl-clip-speed.is-fast {
  background: rgba(255, 140, 0, 0.85);
  color: #1a1200;
}
.tl-clip-speed.is-slow {
  background: rgba(56, 140, 220, 0.9);
  color: #fff;
}
.tl-clip-speed svg {
  flex-shrink: 0;
  opacity: 0.95;
}
.tl-clip-speed.is-fast:hover {
  background: rgba(255, 149, 0, 1);
}
.tl-clip-speed.is-slow:hover {
  background: rgba(70, 155, 235, 1);
}
.tl-clip.has-speed .tl-clip-title {
  padding-inline-end: 34px;
}

/* Per-clip mute toggle - professional NLE style.
   Unmuted = silent/hidden (normal state needs no indicator).
   Muted = always visible. Hover clip = ghost discovery hint. */
.tl-clip-mute {
  position: absolute;
  bottom: 5px;
  left: 6px;
  z-index: 7;
  width: 14px;
  height: 14px;
  border: none;
  background: none;
  padding: 0;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.tl-clip-mute span {
  width: 13px;
  height: 13px;
  display: flex;
  pointer-events: none;
}
.tl-clip-mute span svg {
  width: 100%;
  height: 100%;
  display: block;
}
/* muted = always show */
.tl-clip-mute.is-muted {
  opacity: 0.85;
}
/* on clip hover: ghost toggle hint for both states */
.tl-clip:hover .tl-clip-mute:not(.is-muted),
.tl-audio-block:hover .tl-clip-mute:not(.is-muted) {
  opacity: 0.3;
}
.tl-audio-block.is-muted .tl-waveform {
  opacity: 0.45;
}
/* hovering the button: full white */
.tl-clip-mute:hover {
  opacity: 1 !important;
}

/* Audio lane: no chip — dark icon so it reads on bright waveforms. */
.tl-audio-block .tl-clip-mute {
  width: 14px;
  height: 14px;
  bottom: 5px;
  left: 6px;
  border-radius: 0;
  background: none;
  color: #1a2433;
  opacity: 0.85;
  box-shadow: none;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.55));
}
.tl-audio-block .tl-clip-mute span {
  width: 13px;
  height: 13px;
}
.tl-audio-block:hover .tl-clip-mute:not(.is-muted) {
  opacity: 0.75;
}
.tl-audio-block .tl-clip-mute.is-muted {
  background: none;
  color: #b4232e;
  opacity: 1;
}
.tl-audio-block .tl-clip-mute:hover {
  background: none;
  color: #0f1724;
  opacity: 1 !important;
}
.tl-audio-block .tl-clip-mute.is-muted:hover {
  background: none;
  color: #9a1c26;
}

/* ===== Watermark removal time-range strip (on the timeline clip) ===== */
.tl-wm-strip {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 20px;
  height: 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 8;
  pointer-events: auto;
  touch-action: none;
  opacity: 0.72;
  transition: opacity 0.15s;
}
.tl-clip:hover .tl-wm-strip,
.tl-clip.is-selected .tl-wm-strip {
  opacity: 1;
}
.tl-wm-fill {
  position: absolute;
  top: 1px;
  bottom: 1px;
  min-width: 22px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.55);
  box-shadow: none;
  cursor: grab;
}
.tl-wm-fill:active {
  cursor: grabbing;
  background: rgba(239, 68, 68, 0.72);
}
.tl-wm-fill.is-whole {
  background: rgba(239, 68, 68, 0.28);
}
.tl-wm-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.12s;
}
.tl-wm-handle::after {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 1px;
  width: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: none;
}
.tl-wm-handle-l {
  left: 0;
}
.tl-wm-handle-l::after {
  left: 2px;
}
.tl-wm-handle-r {
  right: 0;
}
.tl-wm-handle-r::after {
  right: 2px;
}
.tl-clip:hover .tl-wm-handle,
.tl-clip.is-selected .tl-wm-handle {
  opacity: 0.85;
}
.tl-wm-fill:hover .tl-wm-handle,
.tl-wm-fill:active .tl-wm-handle {
  opacity: 1;
}

/* ===== Watermark region marker (over the preview) ===== */
/* Clean marker: NO fill (so the watermark stays clearly visible underneath),
   just a crisp outline that reads on any background (accent line between a white
   and a dark hairline). Ellipse variant rounds to 50%. */
.wm-box {
  position: absolute;
  z-index: 8;
  background: transparent;
  /* Thin single accent line + one faint dark hairline so it still reads on a
     light background - no heavy double border. */
  border: 1px solid var(--accent, #0a6b76);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);
  cursor: move;
}
.wm-box.is-ellipse {
  border-radius: 50%;
}

/* Corner resize handles - small L-brackets on the border, large invisible hit area. */
.wm-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  background: transparent;
  border: none;
  box-shadow: none;
  z-index: 2;
}
.wm-handle::before,
.wm-handle::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  border-radius: 1px;
}
.wm-handle-nw {
  left: 0;
  top: 0;
  cursor: nwse-resize;
}
.wm-handle-nw::before {
  left: 0;
  top: 0;
  width: 9px;
  height: 2px;
}
.wm-handle-nw::after {
  left: 0;
  top: 0;
  width: 2px;
  height: 9px;
}
.wm-handle-ne {
  right: 0;
  top: 0;
  cursor: nesw-resize;
}
.wm-handle-ne::before {
  right: 0;
  top: 0;
  width: 9px;
  height: 2px;
}
.wm-handle-ne::after {
  right: 0;
  top: 0;
  width: 2px;
  height: 9px;
}
.wm-handle-sw {
  left: 0;
  bottom: 0;
  cursor: nesw-resize;
}
.wm-handle-sw::before {
  left: 0;
  bottom: 0;
  width: 9px;
  height: 2px;
}
.wm-handle-sw::after {
  left: 0;
  bottom: 0;
  width: 2px;
  height: 9px;
}
.wm-handle-se {
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
}
.wm-handle-se::before {
  right: 0;
  bottom: 0;
  width: 9px;
  height: 2px;
}
.wm-handle-se::after {
  right: 0;
  bottom: 0;
  width: 2px;
  height: 9px;
}
.wm-box:hover .wm-handle::before,
.wm-box:hover .wm-handle::after {
  background: #fff;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 0 6px rgba(0, 113, 227, 0.35);
}

/* ── Movie logo (corner overlay across the whole film) ───────────────────── */
.preview-logo {
  position: absolute;
  height: auto;
  z-index: 3; /* below the movie-fade overlay so it fades in/out with the film */
  pointer-events: none;
  user-select: none;
  /* top + left/right + width are set inline by syncLogoOverlay() */
}

/* ── Timed image overlays (free position / size on the frame) ─────────────── */
.preview-overlay {
  position: absolute;
  z-index: 3; /* with logo, below movie-fade so they fade together */
  box-sizing: border-box;
  pointer-events: none;
  user-select: none;
  border: 1px solid transparent;
}
.preview-overlay .ov-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.preview-overlay.is-editable {
  pointer-events: auto;
  cursor: move;
  border-color: var(--accent, #0a6b76);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28);
  z-index: 6; /* above fade while editing */
}
.preview-overlay.is-selected {
  z-index: 6;
}
.ov-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 1px solid var(--accent, #0a6b76);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  display: none;
  z-index: 2;
}
.preview-overlay.is-editable .ov-handle {
  display: block;
}
.ov-handle-nw {
  left: -7px;
  top: -7px;
  cursor: nwse-resize;
}
.ov-handle-ne {
  right: -7px;
  top: -7px;
  cursor: nesw-resize;
}
.ov-handle-sw {
  left: -7px;
  bottom: -7px;
  cursor: nesw-resize;
}
.ov-handle-se {
  right: -7px;
  bottom: -7px;
  cursor: nwse-resize;
}

/* Overlay picker modal */
.modal.modal-lg:has(.overlay-modal),
.modal:has(.overlay-modal) {
  display: flex;
  flex-direction: column;
  width: min(1040px, 96vw);
  max-width: min(1040px, 96vw);
  max-height: min(90dvh, 860px);
  padding: 0;
  overflow: hidden;
}
/* The image-layer window is one fixed height on «התמונות שלי» and «גרפיקה
   מוכנה» alike - an empty tab no longer shrinks it. */
.modal:has(.ov-layer-picker) {
  height: min(90dvh, 860px);
}
.overlay-modal.ov-layer-picker {
  height: 100%;
  min-height: 0;
}
.overlay-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: inherit;
  direction: rtl;
  text-align: right;
}
.overlay-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}
.overlay-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.overlay-modal-title-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  flex-shrink: 0;
}
.overlay-modal-title-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.overlay-modal-title-main {
  font-size: 15px;
  font-weight: 700;
}
.overlay-modal-title-sub {
  font-size: 12px;
  color: var(--text-3);
}
.overlay-modal-body {
  padding: 14px 18px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.overlay-modal-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  background: var(--surface, #fff);
}
.ov-footer-spacer {
  flex: 1;
  min-width: 8px;
}
.overlay-settings-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 18px;
}
.ov-hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.45;
}
.ov-empty {
  text-align: center;
  padding: 28px 12px;
  color: var(--text-2);
}
.ov-empty strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}
.picker-source-filter {
  display: flex;
  align-items: stretch;
  gap: 1px;
  flex-shrink: 0;
  margin: 0 0 8px;
  padding: 2px;
  border-radius: 7px;
  background: var(--surface-pressed, rgba(0, 0, 0, 0.05));
  width: fit-content;
  max-width: 100%;
}
.picker-source-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 26px;
  padding: 3px 8px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-3, #889);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.12s ease,
    color 0.12s ease,
    box-shadow 0.12s ease;
}
.picker-source-btn:hover:not(:disabled):not(.is-on) {
  color: var(--text-2);
}
.picker-source-btn.is-on {
  background: var(--surface, #fff);
  color: var(--text);
  font-weight: 600;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.04);
}
.picker-source-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.picker-source-count {
  font-size: 10px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  opacity: 0.85;
}
.picker-source-btn.is-on .picker-source-count {
  color: var(--accent);
  opacity: 1;
}
.ov-empty--filter,
.lm-filter-empty {
  grid-column: 1 / -1;
  padding: 10px 6px;
  font-size: 11px;
  color: var(--text-3, #889);
  text-align: center;
}
.ov-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 12px;
}
.ov-thumb {
  appearance: none;
  width: 100%;
  border: 2px solid transparent;
  background: var(--surface-2, #f3f4f6);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  text-align: start;
  font: inherit;
  color: inherit;
}
/* Image tile = select button + a sibling enlarge button pinned to its corner. */
.ov-tile {
  position: relative;
  min-width: 0;
}
.ov-zoom-btn {
  appearance: none;
  position: absolute;
  top: 6px;
  inset-inline-start: 6px;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: rgba(15, 20, 28, 0.55);
  color: #fff;
  cursor: pointer;
  opacity: 0.8;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition:
    opacity 0.15s ease,
    background 0.15s ease,
    transform 0.15s ease;
}
.ov-tile:hover .ov-zoom-btn,
.ov-zoom-btn:focus-visible {
  opacity: 1;
}
.ov-zoom-btn:hover {
  background: rgba(15, 20, 28, 0.78);
  transform: scale(1.06);
}
.ov-zoom-btn .ui-icon svg {
  width: 14px;
  height: 14px;
}

@media (max-width: 640px) {
  .ov-picker {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}
/* Square media box - the loading shimmer (polish.css) lives on this wrapper,
   so the tile holds its size while the image is still on its way. */
.ov-thumb-media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
}
.ov-thumb-media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ov-thumb.sel {
  border-color: var(--accent);
}
.ov-thumb--upload {
  border: 2px dashed color-mix(in srgb, var(--accent, #0a6b76) 45%, transparent);
  background: var(--accent-soft, rgba(10, 107, 118, 0.08));
  color: var(--accent, #0a6b76);
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}
.ov-thumb--upload:hover:not(:disabled) {
  background: var(--accent-soft-2, rgba(10, 107, 118, 0.16));
  border-color: var(--accent, #0a6b76);
}
.ov-thumb--upload:disabled {
  cursor: default;
}
.ov-thumb--upload.is-busy {
  opacity: 0.75;
}
.ov-upload-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ov-upload-label {
  font-size: 12.5px;
  font-weight: 600;
}
.ov-thumb--upload .ov-thumb-name {
  color: var(--text-3);
  text-align: center;
}
.ov-thumb-name {
  display: block;
  padding: 6px 7px;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ov-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
  gap: 14px;
  padding: 12px 18px;
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  background: var(--surface, #fff);
}
.ov-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

/* «התמונות שלי» / «גרפיקה מוכנה» (overlays.js + overlay-graphics.js) */
.ov-mode-tabs {
  margin-bottom: 10px;
}
.ov-mode-tabs .picker-source-btn {
  min-height: 32px;
  padding: 4px 16px;
  font-size: 13px;
}
.ov-picker.ov-gfx-grid {
  grid-template-columns: repeat(auto-fill, minmax(106px, 1fr));
  gap: 10px;
}
.ov-gfx-group {
  grid-column: 1 / -1;
  margin: 6px 2px -4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
}
.ov-gfx-group:first-child {
  margin-top: 0;
}
/* A checkerboard under the drawing: the graphic is transparent around it. */
.ov-gfx .ov-thumb-media {
  background:
    repeating-conic-gradient(#c9d1d8 0% 25%, #e8ecef 0% 50%) 50% / 16px 16px;
}
.ov-gfx .ov-thumb-media > canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.ov-gfx[aria-pressed="true"] .ov-thumb-name {
  color: var(--accent);
  font-weight: 700;
}
.ov-gfx-options {
  display: flex;
  flex: 1 0 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}
.ov-gfx-field {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ov-gfx-label {
  margin-inline-end: 2px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.ov-gfx-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
  border-radius: 50%;
  cursor: pointer;
}
.ov-gfx-field input[type="color"] {
  width: 38px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
}
.ov-gfx-dir {
  width: 32px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.ov-gfx-dir.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.ov-gfx-text {
  flex: 1 1 220px;
}
.ov-gfx-text input {
  flex: 1 1 160px;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.ov-gfx-text input:focus {
  border-color: var(--accent);
  outline: none;
  background: var(--surface);
}
@media (max-width: 640px) {
  .ov-gfx-swatch {
    width: 30px;
    height: 30px;
  }
  .ov-gfx-dir {
    width: 40px;
    height: 40px;
  }
  .ov-gfx-text input {
    height: 44px;
    font-size: 16px; /* under 16px iOS zooms the page on focus */
  }
}
.ov-bg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}
.ov-bg-row .lm-bg-toggle {
  width: fit-content;
}
.ov-stack-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-top: 2px;
}
.ov-stack-btns {
  display: inline-flex;
  gap: 6px;
}
.ov-stack-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px !important;
  font-size: 12px !important;
}
.ov-stack-hint {
  font-size: 11px;
  color: var(--text-2);
}

/* ── Logo modal (wide two-pane, matches subtitles / soundtrack shells) ───── */
.modal.modal-lg:has(.logo-modal),
.modal:has(.logo-modal) {
  display: flex;
  flex-direction: column;
  width: min(920px, 96vw);
  max-width: min(920px, 96vw);
  /* Fixed shell height so filter/empty states don't resize the dialog. */
  height: min(88dvh, 720px);
  max-height: min(88dvh, 720px);
  padding: 0;
  overflow: hidden;
}

.logo-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: inherit;
  min-height: 0;
  direction: rtl;
  text-align: right;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.logo-modal-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px 11px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.logo-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
}

.logo-modal-title-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.logo-modal-title-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.logo-modal-title-main {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.logo-modal-title-sub {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.3;
}

.logo-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-2);
  padding: 12px;
}

.logo-modal-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 12px;
  overflow: hidden;
}

.lm-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.lm-col--preview {
  overflow: hidden;
}

.lm-col--controls {
  overflow: auto;
}

.lm-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.lm-col-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.lm-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  border: 1px solid color-mix(in srgb, var(--accent, #0a6b76) 35%, transparent);
  background: var(--accent-soft, rgba(10, 107, 118, 0.1));
  color: var(--accent, #0a6b76);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.lm-upload:hover {
  background: var(--accent-soft-2, rgba(10, 107, 118, 0.18));
}
.lm-upload svg {
  flex-shrink: 0;
}

.lm-empty .lm-upload {
  margin-top: 12px;
}

.lm-divider {
  height: 1px;
  background: var(--divider);
  margin: 2px 0;
  flex-shrink: 0;
}

.logo-modal-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--divider);
  background: var(--surface);
}

.logo-modal-footer[hidden] {
  display: none;
}

.logo-footer-spacer {
  flex: 1;
}

.logo-footer-hint {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.35;
}

/* Preview frame */
.lm-preview-wrap {
  position: relative;
  flex: 1;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--divider);
  overflow: hidden;
  padding: 10px;
}

.lm-preview-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-3);
  pointer-events: none;
}

/* Checkerboard preview frame — size set inline by applyPreviewAspect() */
.lm-pv {
  position: relative;
  border-radius: var(--r-sm);
  overflow: hidden;
  background-color: #1c1c1e;
  background-image:
    linear-gradient(45deg, #2c2c2e 25%, transparent 25%),
    linear-gradient(-45deg, #2c2c2e 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #2c2c2e 75%),
    linear-gradient(-45deg, transparent 75%, #2c2c2e 75%);
  background-size: 14px 14px;
  background-position:
    0 0,
    0 7px,
    7px -7px,
    -7px 0;
  border: 1px solid var(--divider);
  max-width: 100%;
  max-height: 100%;
}
.lm-pv.is-empty .lm-pv-img {
  opacity: 0;
}
.lm-pv-img {
  position: absolute;
  height: auto;
  transition: opacity 0.15s;
}

/* Image picker */
.lm-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0 4px;
  flex: 1 1 auto;
  min-height: 120px;
  overflow: auto;
  align-content: flex-start;
}
.lm-filter-empty {
  width: 100%;
  padding: 18px 8px;
}

.lm-thumb {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}
.lm-thumb img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 2.5px solid transparent;
  background: var(--surface-pressed);
  display: block;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.lm-thumb:hover img {
  border-color: var(--border-strong, rgba(0, 0, 0, 0.18));
}
.lm-thumb.sel img {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.lm-thumb-name {
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 56px;
}
.lm-thumb.sel .lm-thumb-name {
  color: var(--accent);
  font-weight: 600;
}

.lm-settings {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Settings rows */
.lm-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.lm-row:first-child {
  padding-top: 0;
}
.lm-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.lm-row--slider {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.lm-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.lm-row-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.lm-row-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* Segmented control */
.lm-segment {
  flex: 1;
  display: flex;
  gap: 2px;
  background: var(--surface-pressed);
  border-radius: var(--r-pill);
  padding: 3px;
  min-width: 0;
}
.lm-seg-btn {
  flex: 1;
  padding: 7px 8px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-2);
  background: none;
  border: none;
  cursor: pointer;
  transition:
    background 0.15s var(--ease-out),
    box-shadow 0.15s var(--ease-out),
    color 0.1s;
  white-space: nowrap;
  text-align: center;
  line-height: 1.15;
}
.lm-seg-btn.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.1),
    0 1px 1px rgba(0, 0, 0, 0.06);
}

/* Slider */
.lm-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-pressed);
  outline: none;
  cursor: pointer;
  display: block;
  border: none;
}
.lm-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.18),
    0 0 0 1.5px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.12s var(--ease-out);
}
.lm-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.lm-slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
}
.lm-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 0.12s var(--ease-out);
}

.lm-bg-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
  line-height: 1;
}
.lm-bg-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.lm-bg-toggle.is-on {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--accent);
}
.lm-bg-toggle svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.lm-remove {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
  line-height: 1;
}
.lm-remove:hover {
  border-color: color-mix(in srgb, var(--red, #ff3b30) 22%, var(--border));
  background: color-mix(in srgb, var(--red, #ff3b30) 7%, var(--surface));
  color: var(--red, #ff3b30);
}
.lm-remove svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* Empty state */
.lm-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.lm-empty strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
  font-size: 15px;
}
.lm-empty p {
  margin: 0;
  max-width: 320px;
}

@media (max-width: 720px) {
  .modal.modal-lg:has(.logo-modal),
  .modal:has(.logo-modal) {
    width: min(96vw, 560px);
    max-width: min(96vw, 560px);
    height: min(92dvh, 860px);
    max-height: min(92dvh, 860px);
  }
  .logo-modal-layout {
    grid-template-columns: 1fr;
    overflow: auto;
  }
  .lm-col--preview {
    min-height: 220px;
  }
  .lm-col--controls {
    overflow: visible;
  }
}

/* No-video placeholder clip */
.tl-clip.no-video {
  background: repeating-linear-gradient(
    45deg,
    rgba(0, 0, 0, 0.04),
    rgba(0, 0, 0, 0.04) 8px,
    transparent 8px,
    transparent 16px
  );
  background-color: var(--surface-2);
  border-color: var(--border-strong);
  border-style: dashed;
}

.tl-clip.no-video:hover {
  background-color: var(--surface-hover);
  box-shadow: none;
}

.tl-clip.no-video .tl-clip-title {
  color: var(--text-2);
  text-shadow: none;
}

.tl-clip.no-video .tl-clip-info {
  justify-content: center;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.tl-clip-no-video {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

.tl-clip-info {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 7px;
  z-index: 2;
  pointer-events: none;
}

.tl-clip-title {
  font-size: 10px;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.tl-clip-dur {
  font-size: 9px;
  font-family: "SF Mono", Consolas, monospace;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  align-self: flex-end;
  font-variant-numeric: tabular-nums;
}

/* Trim handles - wide hit-area + small visible marker */
.tl-trim {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 14px;
  cursor: ew-resize;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tl-clip:hover .tl-trim,
.tl-clip.is-selected .tl-trim {
  opacity: 1;
}

.tl-trim:hover::before {
  background: var(--accent);
  width: 4px;
  height: 26px;
}

.tl-trim::before {
  content: "";
  width: 3px;
  height: 22px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition:
    background 0.1s,
    width 0.1s,
    height 0.1s;
}

/* Stick the handle a bit outside the clip so it's easy to grab on tiny clips */
.tl-trim.left {
  left: -5px;
}
.tl-trim.right {
  right: -5px;
}

/* ── Touch support ──────────────────────────────────────────────────────────
   The timeline is driven by pointer events; tell the browser NOT to treat a
   drag on these as a scroll/zoom so the gesture reaches our handlers. */
.timeline-ruler,
.tl-clip,
.tl-trim,
.tl-audio-block {
  touch-action: none;
}

/* Trim handles only capture the pointer while they're VISIBLE - an invisible
   (opacity:0) handle still receives touches, so otherwise a tap near a clip edge
   would trim instead of selecting the clip (very easy to mis-hit with a finger). */
.tl-trim {
  pointer-events: none;
}
.tl-clip:hover .tl-trim,
.tl-clip.is-selected .tl-trim,
.tl-audio-block:hover .tl-trim {
  pointer-events: auto;
}

/* Touch: fatter trim handles, and reveal+grab them without hover (selected clip
   / the audio block) since there's no hover to surface them. */
@media (pointer: coarse) {
  .tl-trim {
    width: 22px;
  }
  .tl-clip.is-selected .tl-trim,
  .tl-audio-block .tl-trim {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Junction - cut marker between clips */
.tl-junction {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transform: translate(-50%, -50%);
  z-index: 6;
  color: var(--text-3);
  /* Exclude `left` - position must follow the clip instantly during trim/drag. */
  transition: transform 0.1s ease;
  box-shadow: none;
}

.tl-junction .ui-icon {
  font-size: 10px;
}

.tl-junction:hover {
  transform: translate(-50%, -50%) scale(1.15);
}

.tl-junction:active {
  transform: translate(-50%, -50%) scale(0.96);
}

/* Active transition - tinted background to signal it's set. */
.tl-junction.has-transition {
  background: #1a6abf;
  border-color: #0f4f9e;
  color: #ffffff;
  box-shadow: none;
}
.tl-junction.has-transition:hover {
  transform: translate(-50%, -50%) scale(1.15);
  border-color: rgba(0, 113, 227, 0.7);
  color: rgba(0, 113, 227, 1);
}

[data-theme="dark"] .tl-junction.has-transition {
  background: rgba(30, 80, 180, 0.45);
  border-color: rgba(56, 189, 248, 0.5);
  color: #7dd3fc;
}

/* Centered transition band - straddles the cut point. */
/* Transition band - flat and understated. */
.tl-tx-band {
  position: absolute;
  top: 6px;
  bottom: 6px;
  z-index: 5;
  pointer-events: none;
  border-radius: 4px;
  overflow: hidden;
  background: repeating-linear-gradient(
    -45deg,
    rgba(0, 113, 227, 0.05),
    rgba(0, 113, 227, 0.05) 6px,
    rgba(0, 113, 227, 0.12) 6px,
    rgba(0, 113, 227, 0.12) 12px
  );
  border-left: 2px solid var(--accent, #0a6b76);
  border-right: 2px solid var(--accent, #0a6b76);
}

[data-theme="dark"] .tl-tx-band {
  background: repeating-linear-gradient(
    -45deg,
    rgba(56, 189, 248, 0.05),
    rgba(56, 189, 248, 0.05) 6px,
    rgba(56, 189, 248, 0.12) 6px,
    rgba(56, 189, 248, 0.12) 12px
  );
  border-left: 2px solid #38bdf8;
  border-right: 2px solid #38bdf8;
}

/* Movie fade-in / fade-out: a thin ramp along the bottom of the video track. */
.tl-fade-mark {
  position: absolute;
  top: auto;
  bottom: 5px;
  height: 8px;
  z-index: 4;
  pointer-events: none;
}

.tl-fade-fill {
  position: absolute;
  inset: 0;
  border-radius: 2px;
}

.tl-fade-in .tl-fade-fill {
  background: linear-gradient(
    to right,
    rgba(176, 223, 219, 0.72),
    rgba(176, 223, 219, 0.08)
  );
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}

.tl-fade-out .tl-fade-fill {
  background: linear-gradient(
    to left,
    rgba(176, 223, 219, 0.72),
    rgba(176, 223, 219, 0.08)
  );
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
}

.tl-fade-edge {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tl-fade-edge line {
  stroke: rgba(225, 244, 241, 0.8);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

/* Audio waveform */
.tl-waveform {
  position: absolute;
  inset: 3px 0;
  border-radius: var(--r-xs);
  background: linear-gradient(
    180deg,
    rgba(90, 200, 250, 0.18),
    rgba(90, 200, 250, 0.08)
  );
  border: 1px solid rgba(90, 200, 250, 0.3);
  overflow: hidden;
}

.tl-waveform canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== Flexible audio block (draggable / trimmable) ===== */
.tl-audio-block--pending {
  cursor: default;
  opacity: 0.85;
  border-style: dashed;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}
.tl-audio-pending {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  margin-top: 2px;
}

.tl-audio-block {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: var(--r-xs);
  cursor: grab;
  overflow: visible; /* let trim handles poke out (-5px); waveform clipped by .tl-waveform */
  border: 1.5px solid transparent;
  z-index: 1;
}
.tl-audio-block:hover {
  z-index: 2;
}
.tl-audio-block.is-selected {
  border-color: var(--orange);
  box-shadow:
    0 0 0 2px var(--orange),
    0 2px 10px rgba(255, 149, 0, 0.35);
  z-index: 3;
}
.tl-audio-block:active {
  cursor: grabbing;
}
.tl-audio-block:hover .tl-trim {
  opacity: 1;
}

/* ===== Image overlay timeline track ===== */
.track-row.overlays {
  min-height: 36px;
}
.track-content.overlays {
  position: relative;
  min-height: 36px;
  height: 36px;
}
.tl-overlay-block {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: var(--r-xs);
  cursor: grab;
  overflow: hidden;
  border: 1.5px solid transparent;
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
  z-index: 1;
  touch-action: none;
}
.tl-overlay-block:hover {
  z-index: 2;
}
.tl-overlay-block.is-selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent),
    0 2px 8px rgba(0, 0, 0, 0.18);
  z-index: 3;
}
.tl-overlay-block:active {
  cursor: grabbing;
}
.tl-overlay-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
  pointer-events: none;
}
.tl-overlay-info {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 9px;
  pointer-events: none;
  z-index: 2;
}
.tl-overlay-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-overlay-fx {
  font-size: 9px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.tl-overlay-block .tl-trim {
  opacity: 0;
}
.tl-overlay-block:hover .tl-trim,
.tl-overlay-block.is-selected .tl-trim {
  opacity: 1;
  pointer-events: auto;
}
.tl-overlay-block .tl-trim.left {
  left: -7px;
}
.tl-overlay-block .tl-trim.right {
  right: -7px;
}

.track-content.subtitles {
  position: relative;
  min-height: 36px;
  height: 36px;
}
.tl-sub-block {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: var(--r-xs);
  cursor: grab;
  overflow: hidden;
  border: 1.5px solid transparent;
  background: color-mix(in srgb, #e6b325 28%, var(--surface-2));
  z-index: 1;
  touch-action: none;
  display: flex;
  align-items: center;
  padding: 0 8px;
}
.tl-sub-block:hover {
  z-index: 2;
}
.tl-sub-block.is-active {
  background: color-mix(in srgb, #e6b325 42%, var(--surface-2));
}
.tl-sub-block.is-selected {
  border-color: #c49212;
  box-shadow:
    0 0 0 2px color-mix(in srgb, #e6b325 55%, transparent),
    0 2px 8px rgba(0, 0, 0, 0.18);
  z-index: 3;
}
.tl-sub-block:active {
  cursor: grabbing;
}
.tl-sub-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.45);
}
.tl-sub-block .tl-trim {
  opacity: 0;
}
.tl-sub-block:hover .tl-trim,
.tl-sub-block.is-selected .tl-trim {
  opacity: 1;
  pointer-events: auto;
}
.tl-sub-block .tl-trim.left {
  left: -7px;
}
.tl-sub-block .tl-trim.right {
  right: -7px;
}
.tl-sub-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0.7;
}
.track-row.subtitles.is-muted .tl-sub-block {
  opacity: 0.45;
}

/* Audio trim handles: center the visible bar exactly ON the block's edge.
   The handle zone is 14px wide; the bar (3px) is centered → half = 7px. */
.tl-audio-block .tl-trim.left {
  left: -7px;
}
.tl-audio-block .tl-trim.right {
  right: -7px;
}
.tl-audio-block .tl-waveform {
  left: 0;
  top: 0;
  bottom: 0;
  right: auto;
  width: 100%; /* overridden by inline style.width during trim drag */
  overflow: hidden;
}
.tl-audio-info {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 9px;
  pointer-events: none;
  z-index: 2;
}
.tl-audio-title {
  font-size: 10px;
  font-weight: 600;
  color: #eaf7ff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tl-audio-fx {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  color: #04222e;
  background: rgba(90, 200, 250, 0.95);
  border-radius: var(--r-pill);
  padding: 1px 7px;
  letter-spacing: 0.02em;
}

/* End-effect picker in the music popover */
/* Track name pill shown in the audio popover */
.audio-pop-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 7px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty-state upload zone inside the audio popover */
.audio-upload-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--r-sm);
  padding: 22px 12px 18px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  transition:
    background 0.15s,
    border-color 0.15s;
}
.audio-upload-zone:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}
.audio-upload-text {
  font-size: 12px;
  font-weight: 600;
}
.audio-upload-hint {
  font-size: 10px;
  color: var(--text-3);
}

.audio-upload-zone-compact {
  padding: 14px 12px;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.audio-pick-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 4px;
}

.audio-pick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  cursor: pointer;
  text-align: start;
  color: var(--text);
  font-size: 12px;
  transition: background 0.12s var(--ease-out);
}
.audio-pick-item:hover {
  background: var(--surface-hover);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.audio-pick-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-fx-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.audio-fx-chip {
  padding: 8px 0;
  border: 1.5px solid var(--border);
  border-radius: var(--r-xs);
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  transition: all 0.12s var(--ease-out);
}
.audio-fx-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.audio-fx-chip.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Frame-fit picker (clip popover) */
.fit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.fit-chip {
  padding: 8px 0;
  border: 1.5px solid var(--border);
  border-radius: var(--r-xs);
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  transition: all 0.12s var(--ease-out);
}
.fit-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.fit-chip.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.fit-blur-row,
.ws-fit-blur-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}

.fit-blur-row.is-disabled,
.ws-fit-blur-row.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.fit-blur-row input,
.ws-fit-blur-row input {
  accent-color: var(--accent);
}

.fit-blur-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.vplayer-wrap .fit-blur-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.fit-blur-bg,
.preview-clip-blur {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.15);
  transform-origin: center center;
  filter: blur(28px);
  pointer-events: none;
  z-index: 0;
}

.preview-stage .fit-blur-wrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}
.fit-fg-contain-blur,
.preview-video.fit-fg-contain-blur {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  object-fit: contain;
}

/* ===== Server render - progress card (lives in #toastContainer) ===== */
.render-progress {
  --render-accent: #0a6b76;
  --render-accent-soft: rgba(0, 113, 227, 0.12);
  position: relative;
  isolation: isolate;
  direction: rtl;
  width: min(380px, calc(100vw - 48px));
  pointer-events: auto;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--render-accent) 22%, var(--border));
  background-color: var(--surface);
  background-image: linear-gradient(
    145deg,
    color-mix(in srgb, var(--surface) 90%, #dbeafe) 0%,
    var(--surface) 52%,
    color-mix(in srgb, var(--surface) 94%, #eff6ff) 100%
  );
  box-shadow:
    0 10px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  animation: renderProgIn 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow: hidden;
}
.render-progress--in-dock {
  margin-bottom: 4px;
}
.render-progress--floating {
  position: fixed;
  top: calc(var(--s-12, 48px) + 12px);
  inset-inline-end: 20px;
  z-index: 260;
}
.render-progress--record {
  --render-accent: #ff375f;
  --render-accent-soft: rgba(255, 55, 95, 0.12);
  border-color: color-mix(in srgb, var(--render-accent) 24%, var(--border));
  background-image: linear-gradient(
    145deg,
    color-mix(in srgb, var(--surface) 90%, #ffe4e8) 0%,
    var(--surface) 52%,
    color-mix(in srgb, var(--surface) 94%, #fff1f2) 100%
  );
}
.render-progress::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(
    120deg,
    color-mix(in srgb, var(--render-accent) 55%, transparent),
    color-mix(in srgb, var(--render-accent) 12%, transparent) 42%,
    color-mix(in srgb, var(--render-accent) 40%, transparent)
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.render-progress-inner {
  position: relative;
  z-index: 1;
  padding: 12px 14px 13px;
}
.render-progress.is-minimized .render-progress-inner {
  padding-block: 10px;
}
.render-progress.is-minimized .render-progress-body {
  display: none;
}
.render-progress.is-done,
.render-progress.is-error {
  cursor: pointer;
}
@keyframes renderProgIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.render-progress-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.render-progress.is-minimized .render-progress-row {
  margin-bottom: 0;
  align-items: center;
}
.render-progress-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.render-progress-head-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.render-progress-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: transparent;
  color: var(--render-accent);
  position: relative;
}
.render-progress-live {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
}
.render-progress-live .toast-ai-brand--loop {
  width: 32px;
  height: 32px;
}
.render-progress-live .toast-ai-brand--loop .toast-ai-logo {
  width: 32px;
  height: 32px;
}
.render-progress-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--render-accent) 18%, transparent);
  border-top-color: var(--render-accent);
}
.render-progress.is-done .render-progress-live,
.render-progress.is-error .render-progress-live {
  display: none;
}
.render-progress.is-done .render-progress-spinner,
.render-progress.is-error .render-progress-spinner {
  display: block;
  border: none;
  animation: none;
  width: 18px;
  height: 18px;
  background: currentColor;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}
.render-progress.is-done .render-progress-spinner {
  background: var(--green, #34c759);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.2l2.8 2.8 6.2-6.4' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.render-progress.is-error .render-progress-spinner {
  background: var(--red, #ff3b30);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M5 5l6 6M11 5l-6 6' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
}
@keyframes renderProgSpin {
  to {
    transform: rotate(360deg);
  }
}
.render-progress-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  letter-spacing: -0.012em;
  line-height: 1.25;
}
.render-progress-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  line-height: 1.3;
}
.render-progress-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.render-progress-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--render-accent);
  font-variant-numeric: tabular-nums;
  min-width: 2.6em;
  text-align: end;
}
.render-progress-minimize,
.render-cancel-btn {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition:
    background 0.15s,
    color 0.15s;
}
.render-progress-minimize:hover,
.render-cancel-btn:hover {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text);
}
.render-cancel-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.render-progress-bar {
  height: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}
.render-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--render-accent) 82%, #fff),
    var(--render-accent)
  );
  box-shadow: 0 0 12px color-mix(in srgb, var(--render-accent) 45%, transparent);
  transition: width 0.25s linear;
}
.render-progress-stage {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.006em;
}
.render-progress.is-error .render-progress-stage {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
  color: #ff6b6b;
  font-weight: 500;
  line-height: 1.35;
  font-size: 12px;
}
.render-progress.is-error .render-progress-meta {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  color: #ff8a8a;
  font-size: 11px;
}
.render-progress-meta {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  min-height: 15px;
  letter-spacing: 0.01em;
}
/* Download button inside a "finished while you were away" render card */
.render-download-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 16px;
  border-radius: 8px;
  background: var(--green, #34c759);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.render-download-btn:hover {
  filter: brightness(1.1);
}
.render-progress.is-done {
  --render-accent: #34c759;
  --render-accent-soft: rgba(52, 199, 89, 0.12);
}
.render-progress.is-done .render-progress-fill {
  background: linear-gradient(90deg, #5ad879, var(--green, #34c759));
  box-shadow: 0 0 10px rgba(52, 199, 89, 0.35);
}
.render-progress.is-done .render-progress-pct {
  color: var(--green, #34c759);
}
.render-progress.is-error {
  --render-accent: #ff3b30;
  --render-accent-soft: rgba(255, 59, 48, 0.1);
}
.render-progress.is-error .render-progress-fill {
  background: linear-gradient(90deg, #ff6b63, var(--red, #ff3b30));
}
.render-progress.is-error .render-progress-pct,
.render-progress.is-error .render-progress-title {
  color: var(--red, #ff3b30);
}

/* "הרינדור ממשיך בשרת" - we lost the server, the render did NOT fail. Rides on
   is-error for the card chrome (× closes, a stray click can't dismiss it) but
   must never look like a failure: amber, with a clock instead of the ✕. */
.render-progress.is-error.is-detached {
  --render-accent: #ff9f0a;
  --render-accent-soft: rgba(255, 159, 10, 0.12);
}
.render-progress.is-error.is-detached .render-progress-fill {
  background: linear-gradient(90deg, #ffc45c, #ff9f0a);
}
.render-progress.is-error.is-detached .render-progress-pct,
.render-progress.is-error.is-detached .render-progress-title {
  color: #ff9f0a;
}
.render-progress.is-error.is-detached .render-progress-spinner {
  background: #ff9f0a;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Ccircle cx='8' cy='8' r='6.2' stroke='white' stroke-width='1.6'/%3E%3Cpath d='M8 4.6V8l2.4 1.6' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.render-progress.is-error.is-detached .render-download-btn {
  background: #ff9f0a;
  border: none;
  font-family: inherit;
}

/* Timeline markers - thin guides, low visual weight */
.tl-markers-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.tl-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: ew-resize;
  z-index: 1;
}

.tl-marker-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--orange, #ff9500);
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.12s var(--ease-out);
}

.tl-marker:hover .tl-marker-line,
.tl-marker:active .tl-marker-line {
  opacity: 0.85;
}

/* Magnetic snap guide — shown while an edge sticks to a target */
.tl-snap-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: var(--accent-bright, #12a3b0);
  box-shadow: 0 0 0 1px
    color-mix(in srgb, var(--accent-bright, #12a3b0) 35%, transparent);
  pointer-events: none;
  z-index: 6;
}

.tl-snap-guide[hidden] {
  display: none !important;
}

/* Playhead */
.tl-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--red);
  pointer-events: none;
  z-index: 7;
}

.tl-playhead::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid var(--red);
  transform: translateX(-50%);
}

.tl-playhead-handle {
  position: absolute;
  top: 0;
  width: 12px;
  height: 14px;
  background: var(--red);
  border-radius: 2px 2px 0 0;
  left: 50%;
  transform: translateX(-50%);
  cursor: ew-resize;
  pointer-events: auto;
}

/* Drop indicator */
.tl-drop-indicator {
  position: absolute;
  top: 2px;
  bottom: 2px;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  z-index: 9;
  box-shadow: 0 0 8px var(--accent);
}

/* Empty state */
.timeline-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-7) var(--s-4);
  color: var(--text-3);
  text-align: center;
  font-size: 12px;
  min-height: 100px;
}

/* ============================================================
   Popovers (color, transition)
   ============================================================ */
.popover {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: var(--s-3);
  z-index: 100;
  animation: popIn 0.15s var(--ease-out);
  direction: rtl;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  /* Never wider than the viewport - keeps popovers on-screen on narrow phones
     (the JS clamps the left edge, this caps the width). */
  max-width: calc(100vw - 16px);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.popover-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.popover-clip-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--divider);
}

.popover-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.popover-section + .popover-section {
  padding-top: var(--s-2);
  border-top: 1px solid var(--divider);
}

/* Compact section label - stronger than .popover-subtle */
.popover-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Thin rule between sections inside a popover */
.popover-divider {
  height: 1px;
  background: var(--divider);
  margin: 6px 0 4px;
}

/* Side-by-side action buttons at the bottom of a popover section */
.popover-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--divider);
}
.popover-actions .btn {
  flex: 1;
}

.color-popover {
  width: 320px;
}

.speed-popover {
  width: 260px;
  padding: 10px;
  gap: 8px;
  max-height: calc(100vh - 16px);
  overflow: visible;
}

.speed-popover .popover-clip-name {
  padding-bottom: 6px;
  font-size: 12px;
  line-height: 1.25;
}

.speed-popover .popover-section {
  gap: 5px;
}

.speed-popover .popover-title {
  font-size: 10px;
}

.speed-popover .popover-subtle {
  font-size: 11px;
  line-height: 1.3;
}

.speed-popover .btn-sm {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 12px;
}

.speed-motion-fix {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 5px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
}

.speed-motion-fix:hover {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}

.speed-motion-fix input {
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.speed-motion-fix-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.speed-motion-fix-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.speed-motion-fix-hint {
  color: var(--text-3);
  font-size: 10px;
  line-height: 1.3;
}

.fade-popover {
  width: 280px;
}

.fit-popover {
  width: 280px;
}

.audio-popover {
  width: 280px;
}

.video-track-popover {
  width: 240px;
  gap: 8px;
}

.video-track-mute-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  cursor: pointer;
  text-align: start;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  transition:
    background 0.12s var(--ease-out),
    border-color 0.12s var(--ease-out),
    color 0.12s var(--ease-out);
}

.video-track-mute-option:hover {
  background: var(--surface-hover);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.video-track-mute-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Speed slider - drag to set the clip's timeline duration */
.speed-slider {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.speed-slider .slider {
  width: 100%;
}
.speed-slider-ends {
  display: flex;
  justify-content: space-between;
  direction: ltr;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

/* Auto-correct - the headline action of the color popover */
.auto-correct-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--accent), var(--ember, #e86d2f));
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(10, 107, 118, 0.32);
  transition:
    transform 0.12s var(--ease-out),
    box-shadow 0.12s var(--ease-out),
    filter 0.12s var(--ease-out);
}
.auto-correct-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.42);
  filter: brightness(1.06);
}
.auto-correct-btn:active:not(:disabled) {
  transform: translateY(0);
}
.auto-correct-btn.is-analyzing {
  animation: autoPulse 1s ease-in-out infinite;
}
@keyframes autoPulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.18);
  }
}

.popover-subtle {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-align: center;
  letter-spacing: 0.02em;
  margin: 2px 0;
  text-transform: uppercase;
}

/* Transition popover */
.tx-popover {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  z-index: 100;
  /* Wide enough for three legible chips per row - with this many transitions
     the animated preview is what tells them apart, not the name. */
  width: 360px;
  max-height: calc(100vh - 16px);
  overflow: visible;
  animation: popIn 0.15s var(--ease-out);
  direction: rtl;
}

.tx-popover-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.tx-popover-title-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.tx-popover-title-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tx-popover-title-main {
  font-size: 13px;
  line-height: 1.15;
}

.tx-popover-title-sub {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.tx-popover .slider-row {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--divider);
}

/* ===== Source Monitor (in color popover) ===== */
.source-monitor {
  position: relative;
  background: #000;
  border-radius: var(--r-xs);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.source-monitor video,
.source-monitor img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.source-monitor-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
}

.io-bar {
  position: relative;
  height: 16px;
  background: var(--surface-2);
  border-radius: var(--r-xs);
  cursor: pointer;
  direction: ltr;
}

.io-track {
  position: absolute;
  inset: 4px 0;
  background: var(--surface-pressed);
  border-radius: 2px;
}

.io-selection {
  position: absolute;
  inset-block: 4px;
  background: var(--accent-soft-2);
  border-inline: 2px solid var(--accent);
  cursor: grab;
}

.io-handle {
  position: absolute;
  inset-block: -2px;
  width: 8px;
  background: var(--accent);
  border-radius: 2px;
  cursor: ew-resize;
  z-index: 2;
}

.io-handle.left {
  left: -4px;
}
.io-handle.right {
  right: -4px;
}

/* Touch: pointer-driven drag targets must not trigger native scroll/zoom, and
   the in/out handles need a fatter grab area for a finger. */
.wm-box,
.wm-handle,
.io-bar,
.io-handle {
  touch-action: none;
}
@media (pointer: coarse) {
  .io-handle {
    width: 14px;
  }
  .wm-handle {
    width: 22px;
    height: 22px;
  }
}

.io-times {
  display: flex;
  justify-content: space-between;
  font-family: "SF Mono", Consolas, monospace;
  font-size: 10px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

/* ===== Sliders (used in popovers) ===== */
.slider-row {
  display: grid;
  grid-template-columns: 70px 1fr 40px;
  align-items: center;
  gap: 8px;
}

.slider-row > label {
  font-size: 11px;
  color: var(--text-2);
  font-weight: 500;
}

.slider-row .value {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
  text-align: end;
  font-family: "SF Mono", Consolas, monospace;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: linear-gradient(
    to right,
    var(--accent) var(--slider-fill, 50%),
    var(--surface-pressed) var(--slider-fill, 50%)
  );
  border-radius: var(--r-pill);
  outline: none;
  cursor: pointer;
  direction: ltr;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
  cursor: grab;
}

.slider::-webkit-slider-thumb:active {
  cursor: grabbing;
}

.slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  box-shadow: var(--shadow-xs);
  cursor: grab;
}

/* ===== Look Presets ===== */
.look-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  direction: ltr;
}

/* Speed presets (slow-mo / fast-motion) */
.speed-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  direction: ltr;
}
.speed-chip {
  padding: 8px 0;
  border: 1.5px solid var(--border);
  border-radius: var(--r-xs);
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  transition: all 0.12s var(--ease-out);
}
.speed-chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}
.speed-chip.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.look-chip {
  aspect-ratio: 16 / 9;
  border-radius: var(--r-xs);
  border: 1.5px solid var(--border);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(135deg, #5a8ec0 0%, #9b6b4a 100%);
  transition: all 0.15s var(--ease-out);
}

.look-chip[data-look="natural"] {
  background-image: linear-gradient(135deg, #b9c3cf, #8c9aa8);
}
.look-chip[data-look="cinematic"] {
  background-image: linear-gradient(135deg, #2e3a4b, #c69a6a);
}
.look-chip[data-look="cool"] {
  background-image: linear-gradient(135deg, #1f3957, #4ea6e0);
}
.look-chip[data-look="warm"] {
  background-image: linear-gradient(135deg, #6a3b1d, #e8a85a);
}
.look-chip[data-look="bw"] {
  background-image: linear-gradient(135deg, #0a1628, #a8b4c2);
}
.look-chip[data-look="vivid"] {
  background-image: linear-gradient(135deg, #1a6b4a, #f0c040);
}

.look-chip:hover {
  transform: scale(1.05);
  border-color: var(--text-3);
}
.look-chip.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft-2);
}

.look-chip .look-name {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  font-size: 8px;
  font-weight: 700;
  color: white;
  text-align: center;
  padding: 2px 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  letter-spacing: 0.02em;
}

/* ===== Scene preset chips (one-click grade + VFX looks) ===== */
.scene-preset-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.02em;
  margin: 8px 0 4px;
}
.scene-preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.scene-preset-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2, var(--surface));
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.12s var(--ease-out);
}
.scene-preset-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}
.scene-preset-chip.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft-2, var(--accent-soft));
  color: var(--text);
}

/* ===== Scene template library cards ===== */
.modal.modal-lg:has(.template-studio) {
  display: flex;
  flex-direction: column;
  max-width: min(1180px, 96vw);
  width: min(1180px, 96vw);
  max-height: min(92dvh, 860px);
  padding: 0;
  overflow: hidden;
}

.template-studio {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: inherit;
  min-height: 0;
  direction: rtl;
  width: 100%;
  overflow: hidden;
  background: var(--surface);
}

.template-studio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 12px 16px 11px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
  flex-shrink: 0;
}

.template-studio-titlewrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.template-studio-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 8px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.template-studio-title-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.template-studio-title-main {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.template-studio-subtitle {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}

.template-studio-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
  min-height: 0;
  background: var(--surface-2);
}

.template-studio-body.is-picking {
  grid-template-columns: 1fr;
  overflow: hidden;
}

/* ── Left: template gallery ── */
.ts-gallery {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  background: var(--surface);
}

.ts-gallery-head {
  margin-bottom: 10px;
}

.ts-gallery-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.ts-gallery-sub {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
}

/* ── Right: configuration sidebar ── */
.ts-config {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  border-inline-start: 1px solid var(--divider);
  background: var(--surface);
}

.ts-config-active {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.ts-config-active-label {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
}

.ts-config-active-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.ts-config-active-note {
  margin-top: 4px;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.45;
}

.ts-config-empty {
  margin: auto 0;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 20px 12px;
  text-align: center;
}

.ts-config-empty-mark {
  display: none;
}

.ts-config-empty-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.ts-config-empty-note {
  max-width: 220px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.5;
}

.ts-config-block-title {
  margin-bottom: 8px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
}

/* Background pickers */
.ts-bg-grid {
  display: grid;
  gap: 8px;
}

.ts-bg-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: start;
  cursor: pointer;
  transition: border-color 0.14s var(--ease-out);
}

.ts-bg-card:hover {
  border-color: var(--border-strong);
}

.ts-bg-card.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.ts-bg-thumb {
  display: grid;
  place-items: center;
  width: 46px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.ts-bg-thumb img,
.ts-bg-thumb video,
.ts-slot-thumb img,
.ts-slot-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ts-bg-thumb.is-preset,
.ts-pick-thumb.is-preset {
  border: none;
}

.ts-bg-thumb.bg-sky,
.ts-pick-thumb.bg-sky,
.template-card-preview.bg-sky {
  background: linear-gradient(150deg, #7cc0ee, #cfe4ea 55%, #f4ecdc);
}

.ts-bg-thumb.bg-midnight,
.ts-pick-thumb.bg-midnight {
  background: linear-gradient(150deg, #10182e, #241a44 46%, #060812);
}

.ts-bg-thumb.bg-studio,
.ts-pick-thumb.bg-studio {
  background: linear-gradient(150deg, #f3f7fb, #b9c6d6 70%, #94a5ba);
}

.ts-bg-thumb.bg-clean,
.ts-pick-thumb.bg-clean {
  background: linear-gradient(150deg, #fbfdff, #d2dfec);
}

.ts-bg-thumb.bg-paper,
.ts-pick-thumb.bg-paper {
  background: linear-gradient(150deg, #fff8ea, #ecdcc4 68%, #d6c1a2);
}

.ts-bg-thumb.bg-warm,
.ts-pick-thumb.bg-warm {
  background: linear-gradient(150deg, #ffe9cf, #f2b98f 55%, #9db3cf);
}

.ts-bg-thumb.bg-stage,
.ts-pick-thumb.bg-stage {
  background:
    radial-gradient(85% 68% at 50% -6%, #3d2d60, transparent 62%),
    linear-gradient(150deg, #171226, #0c0f1c 55%, #05070b);
}

.ts-bg-thumb.bg-editorial,
.ts-pick-thumb.bg-editorial {
  background: linear-gradient(150deg, #f7f6f1, #dfe6e6 55%, #c2cad0);
}

.ts-bg-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ts-bg-label {
  color: var(--text-3);
  font-size: 10px;
  font-weight: 800;
}

.ts-bg-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
}

/* Slot rows */
.ts-slot-list {
  display: grid;
  gap: 8px;
}

.ts-slot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: start;
  cursor: pointer;
  transition: border-color 0.14s var(--ease-out);
}

button.ts-slot-row:hover {
  border-color: var(--border-strong);
}

.ts-slot-row.is-primary {
  cursor: default;
  background: var(--surface-2);
  border-style: dashed;
}

.ts-slot-thumb {
  display: grid;
  place-items: center;
  width: 46px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #12151c;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 800;
}

.ts-slot-thumb.is-empty {
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
}

.ts-slot-index {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.ts-slot-body {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.ts-slot-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 750;
}

.ts-slot-hint {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: 11px;
}

.ts-slot-chip {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
}

.ts-slot-action {
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 800;
  transition:
    background 0.14s var(--ease-out),
    color 0.14s var(--ease-out);
}

button.ts-slot-row:hover .ts-slot-action {
  background: var(--accent);
  color: #fff;
}

/* Media picker view (background / slot video) */
.ts-picker {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 16px 18px 22px;
}

.ts-picker-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.ts-pick-kind-filter {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin: 0 0 12px;
  padding: 4px;
  border-radius: 12px;
  background: var(--bg-2, rgba(0, 0, 0, 0.2));
  border: 1px solid var(--border);
}

.ts-pick-kind-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  transition:
    background 0.14s var(--ease-out),
    color 0.14s var(--ease-out);
}

.ts-pick-kind-btn:hover {
  color: var(--text);
}

.ts-pick-kind-btn.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}

.ts-pick-kind-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5em;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(127, 127, 127, 0.18);
  color: inherit;
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ts-pick-kind-btn.is-active .ts-pick-kind-count {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
}

.tpl-media-picker-body .ts-pick-kind-filter {
  margin-bottom: 14px;
}

.ts-pick-back {
  flex-shrink: 0;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition:
    border-color 0.14s var(--ease-out),
    color 0.14s var(--ease-out);
}

.ts-pick-back:hover {
  border-color: var(--accent);
  color: var(--text);
}

.ts-picker-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.ts-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  align-content: start;
}

.ts-pick-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: start;
  cursor: pointer;
  transition: border-color 0.14s var(--ease-out);
}

.ts-pick-card:hover {
  border-color: var(--border-strong);
}

.ts-pick-card.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.ts-pick-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #12151c;
  position: relative;
}

.ts-pick-thumb.is-none {
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(
    -45deg,
    var(--surface-2) 0 8px,
    var(--surface) 8px 16px
  );
}

.ts-pick-thumb img,
.ts-pick-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ts-pick-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 650;
}

.ts-pick-kind {
  position: absolute;
  inset-inline-start: 6px;
  top: 6px;
  z-index: 1;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(8, 10, 14, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
}

.ts-pick-empty {
  grid-column: 1 / -1;
  padding: 24px 8px;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
}

.template-popover {
  width: min(720px, calc(100vw - 16px));
  max-height: min(76vh, 720px);
  overflow: auto;
}

.template-library {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.template-library-tools {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
  background: var(--surface);
}

.template-library-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.template-library-count {
  flex-shrink: 0;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.template-library-search {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
}

.template-library-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.template-group-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.template-group-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 750;
  cursor: pointer;
}

.template-group-chip span {
  color: var(--text-3);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.template-group-chip.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--text);
}

.template-group-chip.is-active span {
  color: var(--accent);
}

.template-library-empty {
  padding: 28px 10px;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.5;
}

.template-library-empty strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 13px;
}

.template-group-count {
  margin-inline-start: 6px;
  color: var(--text-3);
  font-weight: 700;
}

.template-clear-option {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  align-self: flex-start;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition:
    border-color 0.14s var(--ease-out),
    background 0.14s var(--ease-out),
    color 0.14s var(--ease-out);
}

.template-clear-option:hover,
.template-clear-option.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text);
}

.template-clear-mark {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: color-mix(in srgb, currentColor 14%, transparent);
  font-size: 14px;
  line-height: 1;
}

.template-group-title {
  margin: 2px 0 -6px;
  padding-inline-start: 2px;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 850;
}

.template-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 10px;
}

.template-preset-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-2);
  text-align: start;
  cursor: pointer;
  transition:
    border-color 0.14s var(--ease-out),
    color 0.14s var(--ease-out);
}

.template-preset-card:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.template-preset-card.is-selected {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.template-card-preview {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 6px;
  background: linear-gradient(150deg, #7cc0ee, #cfe4ea 55%, #f4ecdc);
  border: 1px solid var(--divider);
}

.template-card-preview::before,
.template-card-preview::after {
  content: none;
  display: none;
}

.template-card-preview.bg-midnight {
  background: linear-gradient(150deg, #10182e, #241a44 46%, #060812);
}

.template-card-preview.bg-studio {
  background: linear-gradient(150deg, #f3f7fb, #b9c6d6 70%, #94a5ba);
}

.template-card-preview.bg-clean {
  background: linear-gradient(150deg, #fbfdff, #d2dfec);
}

.template-card-preview.bg-paper {
  background: linear-gradient(150deg, #fff8ea, #ecdcc4 68%, #d6c1a2);
}

.template-card-preview.bg-warm {
  background: linear-gradient(150deg, #ffe9cf, #f2b98f 55%, #9db3cf);
}

.template-card-preview.bg-stage {
  background:
    radial-gradient(85% 68% at 50% -6%, #3d2d60, transparent 62%),
    linear-gradient(150deg, #171226, #0c0f1c 55%, #05070b);
}

.template-card-preview.bg-editorial {
  background: linear-gradient(150deg, #f7f6f1, #dfe6e6 55%, #c2cad0);
}

.ts-bg-thumb.bg-aurora,
.ts-pick-thumb.bg-aurora,
.template-card-preview.bg-aurora {
  background:
    radial-gradient(
      50% 60% at 18% 30%,
      rgba(124, 92, 255, 0.7),
      transparent 70%
    ),
    radial-gradient(
      40% 50% at 78% 24%,
      rgba(34, 211, 238, 0.45),
      transparent 70%
    ),
    linear-gradient(160deg, #070814, #14102e 50%, #061018);
}

.ts-bg-thumb.bg-ocean,
.ts-pick-thumb.bg-ocean,
.template-card-preview.bg-ocean {
  background:
    radial-gradient(
      45% 50% at 70% 18%,
      rgba(125, 211, 252, 0.4),
      transparent 70%
    ),
    linear-gradient(165deg, #042f3c, #0c4a6e 55%, #082f49);
}

.ts-bg-thumb.bg-candy,
.ts-pick-thumb.bg-candy,
.template-card-preview.bg-candy {
  background: linear-gradient(145deg, #fff1f2, #fb7185 42%, #fde68a);
}

.ts-bg-thumb.bg-noir,
.ts-pick-thumb.bg-noir,
.template-card-preview.bg-noir {
  background:
    radial-gradient(
      50% 40% at 18% 80%,
      rgba(212, 175, 95, 0.28),
      transparent 70%
    ),
    linear-gradient(160deg, #121218, #070709);
}

.ts-bg-thumb.bg-forest,
.ts-pick-thumb.bg-forest,
.template-card-preview.bg-forest {
  background: linear-gradient(165deg, #14532d, #052e16 60%, #022c22);
}

.ts-bg-thumb.bg-sunset,
.ts-pick-thumb.bg-sunset,
.template-card-preview.bg-sunset {
  background: linear-gradient(
    165deg,
    #431447,
    #fb7185 40%,
    #fdba74 72%,
    #1e1b4b
  );
}

.ts-bg-thumb.bg-ice,
.ts-pick-thumb.bg-ice,
.template-card-preview.bg-ice {
  background: linear-gradient(160deg, #f8fbff, #e0f2fe 55%, #7dd3fc);
}

.ts-bg-thumb.bg-gold,
.ts-pick-thumb.bg-gold,
.template-card-preview.bg-gold {
  background:
    radial-gradient(
      50% 45% at 50% 35%,
      rgba(251, 191, 36, 0.45),
      transparent 70%
    ),
    linear-gradient(165deg, #3f2d12, #1c1408 60%, #100c06);
}

.ts-bg-thumb.bg-lava,
.ts-pick-thumb.bg-lava,
.template-card-preview.bg-lava {
  background:
    radial-gradient(
      40% 40% at 30% 70%,
      rgba(249, 115, 22, 0.65),
      transparent 70%
    ),
    linear-gradient(165deg, #7f1d1d, #1a0503);
}

.ts-bg-thumb.bg-chrome,
.ts-pick-thumb.bg-chrome,
.template-card-preview.bg-chrome {
  background: linear-gradient(155deg, #f8fafc, #cbd5e1 48%, #64748b);
}

/* ── Windows: each is a framed "photo" ── */
.template-card-window {
  position: absolute;
  display: block;
  min-width: 15px;
  z-index: 2;
  border: 1px solid rgba(251, 249, 244, 0.92);
  border-radius: 3px;
  background: #1b2536;
  box-shadow: 0 1px 3px rgba(6, 10, 20, 0.18);
  transform-origin: center;
}

/* the inner photo */
.template-card-window::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(168deg, rgba(255, 255, 255, 0.16), transparent 36%),
    linear-gradient(165deg, #2c384c, #151b26 58%, #0c1016);
}

/* frame accents (gloss / sprockets per style) */
.template-card-window::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.template-card-window.win-tone-2::before {
  background:
    linear-gradient(168deg, rgba(255, 255, 255, 0.14), transparent 34%),
    linear-gradient(165deg, #1d3348, #102033 58%, #0a1522);
}

.template-card-window.win-tone-3::before {
  background:
    linear-gradient(168deg, rgba(255, 255, 255, 0.12), transparent 34%),
    linear-gradient(165deg, #1a332c, #10241e 58%, #0a1612);
}

.template-card-window.win-tone-4::before {
  background:
    linear-gradient(168deg, rgba(255, 255, 255, 0.14), transparent 34%),
    linear-gradient(165deg, #2a2440, #161222 58%, #0c0a14);
}

.template-card-window.is-polaroid {
  border-color: #fffdf8;
  border-bottom-width: 5px;
  border-radius: 2px;
}

.template-card-window.is-album {
  border-color: #f2ead9;
  border-bottom-width: 4px;
}

.template-card-window.is-postcard {
  border-color: #fff4e2;
}

.template-card-window.is-film {
  border-color: #14161f;
  border-inline-width: 3px;
  border-radius: 2px;
}

/* film sprocket holes down each rail */
.template-card-window.is-film::after {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.55) 42%, transparent 46%),
    radial-gradient(circle, rgba(255, 255, 255, 0.55) 42%, transparent 46%);
  background-size:
    2px 5px,
    2px 5px;
  background-position:
    left 1px center,
    right 1px center;
  background-repeat: repeat-y;
}

.template-card-window.is-neon {
  border-color: rgba(139, 214, 255, 0.72);
  box-shadow:
    0 0 0 1px rgba(139, 214, 255, 0.28),
    0 3px 10px rgba(0, 188, 255, 0.28);
}

.template-card-window.is-glass {
  border-color: rgba(255, 255, 255, 0.48);
  box-shadow: 0 2px 8px rgba(6, 10, 20, 0.16);
}

.template-card-window.is-glass::before {
  opacity: 0.82;
}

.template-card-window.is-glass::after {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.32),
    transparent 46%
  );
}

.template-card-window.is-phone,
.template-card-window.is-story {
  border-color: #0e1118;
  border-width: 1.5px;
  border-radius: 6px;
  box-shadow: 0 3px 10px rgba(6, 10, 20, 0.28);
}

.template-card-window.is-orb,
.template-card-window.is-vinyl {
  border-radius: 50%;
}

.template-card-window.is-orb {
  border: 2px solid rgba(186, 230, 255, 0.78);
  background: #0b1018;
  box-shadow:
    0 0 0 5px rgba(80, 160, 220, 0.14),
    0 0 14px rgba(90, 180, 255, 0.38);
}

.template-card-window.is-orb::before {
  background:
    radial-gradient(
      circle at 32% 28%,
      rgba(255, 255, 255, 0.32),
      transparent 24%
    ),
    radial-gradient(circle at 50% 50%, #1c2838 42%, #090d14 74%);
}

.template-card-window.is-vinyl {
  border-width: 6px;
  border-color: #1a140f;
  box-shadow:
    inset 0 0 0 1px rgba(255, 206, 140, 0.55),
    inset 0 0 0 7px #100e0c,
    inset 0 0 0 8px rgba(255, 196, 120, 0.28);
}

.template-card-window.is-hex {
  border-radius: 0;
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
}

.template-card-window.is-diamond {
  border-radius: 0;
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

.template-card-window.is-pill {
  border-radius: 999px;
}

.template-card-window.is-broadcast {
  border-radius: 5px;
  border-color: rgba(125, 200, 255, 0.75);
  box-shadow: 0 0 0 1px rgba(56, 160, 255, 0.25);
}

.template-card-window.is-chrome {
  border-color: #f8fafc;
  box-shadow:
    0 0 0 1px rgba(71, 85, 105, 0.28),
    0 2px 6px rgba(15, 23, 42, 0.18);
}

.template-card-window.is-ticket {
  border-color: #f6f0e3;
  border-radius: 4px;
}

.template-card-window.is-portrait {
  border-radius: 8px;
}

.template-card-vizbars {
  position: absolute;
  z-index: 6;
  left: 7%;
  right: 7%;
  bottom: 8%;
  height: 32%;
  display: flex;
  align-items: flex-end;
  gap: 1px;
  pointer-events: none;
}

.template-card-vizbars i {
  flex: 1;
  display: block;
  border-radius: 1px;
  background: linear-gradient(
    180deg,
    #f4feff 0%,
    #67e8f9 14%,
    #4f46e5 58%,
    #1a1030 100%
  );
  box-shadow: 0 0 5px rgba(103, 232, 249, 0.35);
  transform-origin: bottom center;
  animation: tplVizBar 1.15s ease-in-out infinite alternate;
}

.template-card-preview.viz-center .template-card-vizbars {
  top: 22%;
  bottom: 16%;
  height: auto;
  align-items: center;
}

.template-card-preview.viz-center .template-card-vizbars i {
  transform-origin: center;
}

.template-card-preview.viz-stack .template-card-vizbars i {
  background: linear-gradient(
    180deg,
    #ecfccb 0%,
    #bef264 18%,
    #059669 70%,
    #052e16 100%
  );
  box-shadow: 0 0 4px rgba(190, 242, 100, 0.35);
}

.template-card-preview.viz-ring .template-card-vizbars {
  left: 16%;
  right: 16%;
  top: 6%;
  bottom: 6%;
  height: auto;
  border-radius: 50%;
  background: repeating-conic-gradient(
    from -5deg,
    #e0fbff 0 1.6deg,
    #67e8f9 1.6deg 2.6deg,
    transparent 2.6deg 10deg
  );
  -webkit-mask: radial-gradient(
    circle,
    transparent 54%,
    #000 56% 80%,
    transparent 82%
  );
  mask: radial-gradient(circle, transparent 54%, #000 56% 80%, transparent 82%);
  filter: drop-shadow(0 0 4px rgba(103, 232, 249, 0.45));
}

.template-card-preview.viz-ring .template-card-vizbars i {
  display: none;
}

@keyframes tplVizBar {
  from {
    transform: scaleY(0.35);
  }
  to {
    transform: scaleY(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .template-card-vizbars i {
    animation: none;
  }
}

/* count badge + selected check overlay the preview */
.template-card-count {
  position: absolute;
  top: 5px;
  inset-inline-end: 5px;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  height: 16px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(8, 12, 20, 0.55);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

.template-card-count::before {
  content: none;
  display: none;
}

.template-card-check {
  position: absolute;
  top: 5px;
  inset-inline-start: 5px;
  z-index: 7;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}

.template-card-check .ui-icon {
  font-size: 12px;
}

.template-card-name,
.template-card-meta {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-card-name {
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  padding-inline: 2px;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.template-card-kind {
  display: block;
  padding-inline: 2px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.template-card-meta {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .template-preset-card:hover .template-card-window,
  .template-preset-card:hover .template-card-window:nth-child(2n),
  .template-preset-card:hover .template-card-window:nth-child(3n) {
    animation: none;
  }
}

@media (max-width: 720px) {
  .modal.modal-lg:has(.template-studio) {
    max-width: calc(100vw - 12px);
  }

  .template-studio {
    min-height: 0;
    max-height: 88vh;
  }

  .template-studio-body {
    grid-template-columns: 1fr;
  }

  .ts-config {
    border-inline-start: 0;
    border-top: 1px solid var(--divider);
  }

  .template-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(134px, 1fr));
  }
}

/* ===== Transition picker chips ===== */
/* The catalogue runs to dozens of transitions, so the popover scrolls and the
   list is broken into labelled family blocks. */
.tx-list {
  max-height: min(52vh, 420px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  /* Room for the scrollbar so the chips don't sit under it. */
  padding-inline-end: 4px;
  margin-inline-end: -4px;
  scrollbar-width: thin;
}

.tx-family {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 6px;
  padding: 3px 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-3);
  background: var(--surface);
}

.tx-family:first-child {
  margin-top: 0;
}

.tx-family::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--divider);
}

.tx-family-count {
  order: 3;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-3);
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
}

.transition-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  /* Order the chips right-to-left: first transition appears top-right. */
  direction: rtl;
}

.transition-chip {
  aspect-ratio: 1.48;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  background: #1a1a1c;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  transition:
    transform 0.14s var(--ease-out),
    border-color 0.14s,
    box-shadow 0.14s;
}

.transition-chip:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.transition-chip.is-selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* A clear ✓ badge so it's obvious which transition is chosen. */
.transition-chip.is-selected::after {
  content: "✓";
  position: absolute;
  top: 4px;
  inset-inline-end: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.transition-chip .tx-name {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 5;
  min-height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1.15;
  color: white;
  text-align: center;
  padding: 2px 3px;
  background: rgba(0, 0, 0, 0.78);
  letter-spacing: 0.02em;
  white-space: normal;
  word-break: keep-all;
  pointer-events: none;
}

.transition-chip .tx-preview {
  position: absolute;
  inset: 0;
  /* Keep animated previews (esp. zoom-punch) from painting over the label. */
  bottom: 17px;
  overflow: hidden;
}

.tx-preview .tx-a,
.tx-preview .tx-b {
  position: absolute;
  inset: 0;
  overflow: hidden;
  /* No will-change: the picker holds dozens of chips, and promoting two layers
     each costs far more than it saves - only the handful actually on screen is
     ever animated, and opacity/transform/filter are cheap anyway. */
}

/* Each layer carries an off-centre marker. A flat gradient looks identical
   under scale and rotation, which made the zoom and spin chips read as "nothing
   happens"; the dot makes every move legible at 100 px wide. */
.tx-preview .tx-a {
  background:
    radial-gradient(
      circle at 30% 32%,
      rgba(255, 255, 255, 0.62) 0 11%,
      rgba(255, 255, 255, 0) 12%
    ),
    linear-gradient(135deg, #5a8ec0, #1f3957);
}
.tx-preview .tx-b {
  background:
    radial-gradient(
      circle at 71% 68%,
      rgba(24, 12, 4, 0.6) 0 11%,
      rgba(24, 12, 4, 0) 12%
    ),
    linear-gradient(135deg, #c69a6a, #6a3b1d);
}
.tx-preview .tx-flash {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
}

/* Slider area inside transition popover */
.tx-popover .tx-slider-area {
  min-height: 0;
}

.tx-popover .tx-slider-area:not(:empty) {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
}

.tx-popover .tx-slider-area .slider-row {
  margin-top: 0 !important;
  padding-top: 0 !important;
  border-top: none !important;
}

.tx-popover .tx-hint {
  margin-top: 5px;
  font-size: 9.5px;
  color: var(--text-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ===== Export Modal ===== */

.modal:has(.export-modal) {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  max-width: 440px;
  max-height: min(90dvh, 90vh);
  min-height: 0;
}

.export-modal {
  display: flex;
  flex-direction: column;
  direction: rtl;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.export-modal .modal-header {
  padding: var(--s-5) var(--s-6);
  margin-bottom: 0;
  flex-shrink: 0;
}

/* Scrollable body */
.export-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ── Info area (filename + stats) ───────────────────────────────── */
.export-info-area {
  background: var(--surface-2);
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.export-fn-row {
  display: flex;
  align-items: center;
  direction: rtl; /* RTL so filename is on the right, badge on the left */
  gap: 8px;
  margin-bottom: var(--s-4);
}
.export-fn-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--border);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  direction: rtl;
  text-align: right;
  outline: none;
  padding: 2px 0 4px;
  line-height: 1.3;
  transition: border-color 0.15s;
}
.export-fn-input::placeholder {
  color: var(--text-3);
  font-weight: 400;
}
.export-fn-input:focus {
  border-bottom-color: var(--accent);
}
.export-fn-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  background: var(--surface-pressed);
  border-radius: var(--r-xs);
  padding: 2px 6px;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  user-select: none;
}

/* Stats: 4-column flex, no borders */
.export-stats {
  display: flex;
  direction: ltr;
}
.export-stat {
  flex: 1;
  text-align: center;
}
.export-stat .lbl {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.export-stat .val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.export-light-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: var(--s-4) var(--s-6) 0;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: var(--r-sm);
  padding: 10px 13px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-2);
}

.export-light-note-icon {
  display: inline-flex;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}

.export-segment.is-locked .seg-btn {
  opacity: 0.55;
  pointer-events: none;
}

/* ── Warning ──────────────────────────────────────────────────── */
.export-warning {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: var(--s-4) var(--s-6) 0;
  background: rgba(245, 180, 60, 0.1);
  border: 1px solid rgba(245, 180, 60, 0.35);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  flex-shrink: 0;
}
.export-warning .warn-icon {
  color: #f5b43c;
  font-size: 14px;
  flex-shrink: 0;
}

.export-source-match {
  margin: var(--s-3) var(--s-6) 0;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.45;
  flex-shrink: 0;
}
/* While the source probe is still out - same box, visibly provisional, so the
   accent panel doesn't read as a finished recommendation. */
.export-source-match.is-checking {
  opacity: 0.72;
}
/* The probe came back empty (media not on the server, or it never answered):
   plain surface, not the accent "we matched it for you" look. */
.export-source-match.is-missing {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-3);
}
/* Re-run the source probe without closing the modal. */
.export-note-retry {
  margin-inline-start: 8px;
  padding: 2px 9px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.export-note-retry:hover {
  border-color: var(--accent);
  color: var(--accent);
}
/* The action that actually fixes the state (upload now), next to the plain retry. */
.export-note-retry.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.export-note-retry.is-primary:hover {
  filter: brightness(1.08);
  color: #fff;
}

/* ── Controls ─────────────────────────────────────────────────── */
.export-controls {
  display: flex;
  flex-direction: column;
  padding: var(--s-5) var(--s-6);
  flex: 1;
}

.export-form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.export-form-row:first-child {
  padding-top: 0;
}
.export-controls > .export-form-row:nth-child(3) {
  border-bottom: none;
  padding-bottom: 2px;
}
.export-form-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.export-mode-hint {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-3);
  margin-top: -2px;
}
.export-form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: -0.01em;
}

/* ── Segmented control (iOS) ──────────────────────────────────── */
.export-segment {
  display: flex;
  gap: 2px;
  background: var(--surface-pressed);
  border-radius: var(--r-pill);
  padding: 3px;
}
.seg-btn {
  flex: 1;
  padding: 7px 10px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-2);
  background: none;
  border: none;
  cursor: pointer;
  transition:
    background 0.15s var(--ease-out),
    box-shadow 0.15s var(--ease-out),
    color 0.1s;
  white-space: nowrap;
  text-align: center;
  line-height: 1;
}
.seg-btn.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.1),
    0 1px 1px rgba(0, 0, 0, 0.06);
}

/* ── CRF slider ──────────────────────────────────────────────── */
.crf-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.crf-display {
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.crf-display-val {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: -0.04em;
  line-height: 1;
}
.crf-display-note {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
}
.crf-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  direction: ltr;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--fill, 100%),
    var(--surface-pressed) var(--fill, 100%),
    var(--surface-pressed) 100%
  );
  outline: none;
  cursor: pointer;
  border: none;
}
.crf-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.18),
    0 0 0 1.5px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.12s var(--ease-out);
}
.crf-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.crf-slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
  box-shadow:
    0 2px 10px rgba(0, 113, 227, 0.25),
    0 0 0 3px rgba(0, 113, 227, 0.15);
}
.crf-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}
.crf-hints {
  display: flex;
  justify-content: space-between;
  direction: ltr;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  padding: 0 2px;
  margin-top: -4px;
}
/* "איכות" overrides the slider - say so where the number is read. */
.export-crf-lock {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

/* ── Footer ──────────────────────────────────────────────────── */
.export-footer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--divider);
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  background: var(--surface);
}
.export-footer-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  width: 100%;
  min-width: 0;
}
.export-alt-link {
  align-self: center;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 11px;
  color: var(--text-3);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.export-alt-link:hover {
  color: var(--text-2);
}
.export-footer-btns {
  display: flex;
  gap: var(--s-2);
  flex: 1 1 auto;
  min-width: 0;
}
.export-footer-btns .btn {
  flex: 0 1 auto;
  min-width: 0;
}
.export-btn-submit {
  min-width: 112px;
  justify-content: center;
  flex-shrink: 0;
}

/* Export modal — mobile bottom sheet + usable footer buttons */
@media (max-width: 768px) {
  .modal:has(.export-modal) {
    max-width: 100%;
    width: 100%;
    height: auto;
    max-height: min(92dvh, 92vh);
  }

  .modal:has(.export-modal)::before {
    flex-shrink: 0;
    margin: 10px auto 0;
  }

  .export-modal {
    flex: 1 1 auto;
    min-height: 0;
  }

  .export-modal .modal-header {
    padding: 10px 14px;
  }

  .export-info-area {
    padding: 12px 14px;
  }

  .export-controls {
    padding: 12px 14px;
  }

  .export-warning,
  .export-light-note,
  .export-source-match {
    margin-inline: 14px;
  }

  .export-stats {
    gap: 4px;
  }

  .export-stat .lbl {
    font-size: 8px;
  }

  .export-stat .val {
    font-size: 12px;
  }

  .seg-btn {
    padding: 8px 6px;
    font-size: 12px;
  }

  .export-footer {
    padding: 10px 14px max(12px, env(safe-area-inset-bottom, 12px));
    gap: 0;
  }

  .export-footer-main {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .export-footer-btns {
    width: 100%;
    flex: 0 0 auto;
    gap: 6px;
    order: 1;
  }

  .export-footer-btns .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 10px 6px;
    font-size: 12px;
    justify-content: center;
  }

  .export-btn-submit {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 12px 14px;
    font-size: 15px;
    order: 2;
  }
  .export-check-panel {
    max-height: min(32dvh, 220px);
  }
}

/* Advanced settings (always visible) */
.export-advanced {
  margin-top: 4px;
  border-top: 1px solid var(--divider);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
}
.export-advanced .export-form-row:first-child {
  padding-top: 4px;
}
.export-advanced .export-source-match {
  margin: 0 0 8px;
}
.export-opt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  margin: 8px 0 4px;
}
.export-opt input {
  margin: 0;
  accent-color: var(--accent);
}
.export-cine-row {
  margin-top: 0;
  border-bottom: none;
}

/* Before/after stills for the cinematic look - the setting runs on the server,
   so this is the only place it can be seen before committing to a render. */
.export-cine-preview {
  display: flex;
  gap: 10px;
  padding: 4px 0 10px;
}
.export-cine-shot {
  margin: 0;
  flex: 1 1 0;
  min-width: 0;
}
.export-cine-shot canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #000;
}
.export-cine-shot figcaption {
  margin-top: 4px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

/* ── Pre-export check panel ───────────────────────────────────── */
.export-modal.has-export-check .export-body {
  flex: 1 1 0;
  min-height: 0;
}

.export-check-panel {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(40vh, 300px);
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--divider);
  background: var(--surface);
  box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.06);
}

.export-check-panel[hidden] {
  display: none !important;
}

.export-check-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  padding: 10px 16px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
}

.export-check-head-text {
  min-width: 0;
}

.export-check-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  line-height: 1.3;
}

.export-check-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

.export-check-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: -4px 0 0;
  padding: 0;
  border: none;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
}

.export-check-close:hover {
  background: var(--surface-pressed);
  color: var(--text);
}

.export-check-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  flex-shrink: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--divider);
}

.export-check-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-xs);
  line-height: 1.2;
}

.export-check-chip--high {
  background: color-mix(in srgb, var(--red) 14%, transparent);
  color: var(--red);
}

.export-check-chip--med {
  background: color-mix(in srgb, var(--orange) 16%, transparent);
  color: var(--orange);
}

.export-check-chip--low {
  background: var(--surface-pressed);
  color: var(--text-2);
}

.export-check-ok {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--green) 28%, var(--border));
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  flex-shrink: 0;
}

.export-check-ok svg {
  color: var(--green);
  flex-shrink: 0;
}

/* Same slot as .export-check-ok, but for "the scan never answered" - the panel
   must not look reassuring when it has nothing to report. */
.export-check-warn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--ember) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ember) 34%, var(--border));
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  flex-shrink: 0;
}

.export-check-warn svg {
  color: var(--ember);
  flex-shrink: 0;
}

/* Chips, scan state and warnings share one stack: a failed or partial scan is
   shown ALONGSIDE the issue chips, never instead of them. */
.export-check-status {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* The way back from an EARLIER pass, read out of the project. Amber rather
   than green: it is not a result, it is an offer to undo one. */
.export-check-restore {
  flex-shrink: 0;
  margin: 8px 16px 4px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--orange) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--orange) 30%, var(--border));
}

.export-check-restore-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.export-check-restore-head svg {
  color: var(--orange);
  flex-shrink: 0;
}

.export-check-restore-sub {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-2);
}

/* What this pass already fixed, with the way back. An item that just vanishes
   leaves no evidence that anything happened. */
.export-check-fixed {
  flex-shrink: 0;
  margin: 4px 16px 12px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--green) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--green) 24%, var(--border));
}

.export-check-fixed-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.export-check-fixed-head svg {
  color: var(--green);
  flex-shrink: 0;
}

.export-check-fixed-head button {
  margin-inline-start: auto;
}

.export-check-fixed-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  font-size: 12px;
  color: var(--text-2);
}

.export-check-fixed-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-check-scanning {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.4;
}

.export-check-scanning--list {
  margin: 0;
}

.export-check-scanning .spinner {
  flex-shrink: 0;
  border-color: color-mix(in srgb, var(--accent) 24%, transparent);
  border-top-color: var(--accent);
}

.export-check-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
}

.export-check-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.export-check-item--high {
  border-color: color-mix(in srgb, var(--red) 35%, transparent);
  background: color-mix(in srgb, var(--red) 6%, var(--surface));
}

.export-check-item--med {
  border-color: color-mix(in srgb, var(--orange) 35%, transparent);
  background: color-mix(in srgb, var(--orange) 6%, var(--surface));
}

.export-check-sev {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: var(--r-xs);
  white-space: nowrap;
  line-height: 1.2;
  margin-top: 1px;
}

.export-check-sev--high {
  background: color-mix(in srgb, var(--red) 16%, transparent);
  color: var(--red);
}

.export-check-sev--med {
  background: color-mix(in srgb, var(--orange) 18%, transparent);
  color: var(--orange);
}

.export-check-sev--low {
  background: var(--surface-pressed);
  color: var(--text-2);
}

.export-check-item-body {
  min-width: 0;
}

.export-check-item-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  line-height: 1.35;
}

.export-check-item-detail {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 4px;
  line-height: 1.45;
}

.export-check-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.export-check-actions .export-check-goto {
  margin-top: 0;
}

.export-check-goto {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
}

.export-check-goto:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.export-check-enable-motion {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
}

/* Items "תקן הכול בבטחה" will not touch. The badge is the promise that the
   safe pass really is safe, so it has to be readable at a glance. */
.export-check-risk {
  display: inline-block;
  margin-inline-start: 8px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  vertical-align: middle;
  color: var(--text-2);
  background: color-mix(in srgb, var(--text-3) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--text-3) 26%, transparent);
}

/* The seam proof clip: the cut rendered through the real export pipeline and
   played inline, under the issue it belongs to. Deliberately not a modal - the
   panel itself lives inside the export modal. */
.export-check-proof {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--text-3) 6%, transparent);
}

.export-check-proof-video {
  display: block;
  width: 100%;
  max-height: 260px;
  border-radius: var(--r-xs);
  background: #000;
}

.export-check-proof-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-2);
}

.export-check-proof-status .export-check-goto {
  margin-top: 0;
  flex: none;
}

.export-check-proof-track {
  height: 4px;
  margin-top: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--text-3) 20%, transparent);
}

.export-check-proof-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

/* ===== Seam bridge acceptance test (see js/views/editor/seam-bridge.js) =====
   Same shell as logo / enhance / flow-review: icon title, surface-2 body,
   card cells, footer actions. Variants stay equal-sized so judgment is visual,
   not from memory. */
.modal:has(.seam-cmp-modal),
.modal.modal-lg:has(.seam-cmp-modal) {
  display: flex;
  flex-direction: column;
  width: min(1180px, 96vw);
  max-width: min(1180px, 96vw);
  max-height: min(90dvh, 900px);
  padding: 0;
  overflow: hidden;
}

.seam-cmp-modal {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  background: var(--surface-2);
  color: var(--text);
  overflow: hidden;
}

.seam-cmp-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px 11px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
}

.seam-cmp-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
}

.seam-cmp-title-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.seam-cmp-title-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.seam-cmp-title-main {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.seam-cmp-title-sub {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.35;
}

.seam-cmp-modal .modal-close {
  flex: 0 0 auto;
}

.seam-cmp-status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
}

.seam-cmp-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.seam-cmp-status-text {
  min-width: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-2);
}

.seam-cmp-modal .spinner {
  flex: 0 0 auto;
  border-color: var(--border);
  border-top-color: var(--accent);
}

.seam-cmp-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  background: var(--surface-2);
}

.seam-cmp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
  min-height: 0;
}

.seam-cmp-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.seam-cmp-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.seam-cmp-label {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

/* Fixed 16:9 slot so a late/failed cell never reflows neighbours. */
.seam-cmp-slot {
  display: flex;
  flex-direction: column;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface-2) 70%, var(--surface));
  border: 1px solid var(--border);
}

.seam-cmp-cell[data-state="done"] .seam-cmp-slot {
  background: #000;
  border-color: transparent;
}

.seam-cmp-cell[data-state="error"] .seam-cmp-slot {
  border-color: color-mix(in srgb, var(--red, #d64545) 55%, var(--border));
  background: color-mix(in srgb, var(--red, #d64545) 6%, var(--surface));
}

.seam-cmp-slot video {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  border-radius: 0;
  background: #000;
  object-fit: contain;
}

.seam-cmp-pending,
.seam-cmp-error {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
}

/* The slot is a fixed 16:9 box, so a long server error has to scroll INSIDE it
   rather than be clipped by it. */
.seam-cmp-error {
  justify-content: flex-start;
  overflow-y: auto;
  min-height: 0;
}

.seam-cmp-pending {
  flex-direction: row;
}

.seam-cmp-error-text {
  line-height: 1.55;
  color: var(--text);
  max-width: 36ch;
}

.seam-cmp-error-more {
  width: 100%;
  text-align: start;
}

.seam-cmp-error-more > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-3, var(--text-2));
  text-align: center;
  list-style: none;
}

.seam-cmp-error-more > summary::-webkit-details-marker {
  display: none;
}

.seam-cmp-error-more > summary::before {
  content: "▾ ";
}

.seam-cmp-error-raw {
  margin: 8px 0 0;
  padding: 8px 10px;
  max-height: 150px;
  overflow: auto;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  direction: ltr;
  text-align: left;
  color: var(--text-2);
}

.seam-cmp-error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.seam-cmp-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 16px;
  background: var(--surface);
  border-top: 1px solid var(--divider);
}

.seam-cmp-footer .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 720px) {
  .modal:has(.seam-cmp-modal),
  .modal.modal-lg:has(.seam-cmp-modal) {
    width: min(100vw - 16px, 96vw);
    max-height: min(94dvh, 900px);
  }

  .seam-cmp-title-sub {
    display: none;
  }

  .seam-cmp-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Continuity review ("בדיקת הסרט") ===== */
/* The same panel as the export modal's last-moment guard, but this is its real
   home: opened from the toolbar it is a working tool over the whole timeline,
   so it gets a window instead of the footer strip's 300px.

   Everything that makes it BIGGER is scoped to .flow-review-modal on purpose -
   the export strip still has only a footer's worth of room, and must keep the
   compact sizes it was built for. */
.modal.modal-lg:has(.flow-review-modal),
.modal:has(.flow-review-modal) {
  display: flex;
  flex-direction: column;
  width: min(1180px, 96vw);
  max-width: min(1180px, 96vw);
  max-height: min(90dvh, 900px);
  /* The list scrolls, not the modal - one scrollbar, and the head/summary stay
     put while reading down a long list of problems. */
  padding: 0;
  overflow: hidden;
}

.flow-review-modal {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  background: var(--surface-2);
}

.flow-review-modal .modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 16px 22px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.flow-review-modal .modal-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
}

/* Head in the house pattern (.enh-modal / .fstub-modal): icon tile, title,
   one line saying what the window is for. */
.flow-review-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.flow-review-title-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.flow-review-modal.is-suspended .flow-review-title-icon {
  background: color-mix(in srgb, var(--ember) 14%, transparent);
  color: var(--ember);
  border-color: color-mix(in srgb, var(--ember) 30%, transparent);
}

.flow-review-title-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.flow-review-title-sub {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.4;
}

.flow-review-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 22px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ── Suspended ──────────────────────────────────────────────────────────────
   The FLOW scan does not run - but the timeline checks passed in as
   `extraIssues` (empty slots, black tails, unreachable media) still do, and
   they still render their list here. So the notice-dialog treatment is
   conditional on there being no list: `:not(:has(.export-check-list))`. Drop
   that guard and a real list of problems gets squeezed into 560px. */
.modal.modal-lg:has(.flow-review-modal.is-suspended):not(
    :has(.export-check-list)
  ),
.modal:has(.flow-review-modal.is-suspended):not(:has(.export-check-list)) {
  width: min(560px, 94vw);
  max-width: min(560px, 94vw);
  max-height: min(80dvh, 520px);
}

.flow-review-modal.is-suspended:not(:has(.export-check-list))
  .export-check-head {
  border-bottom: 0;
  padding-bottom: 0;
  background: transparent;
}

.flow-review-modal.is-suspended .export-check-sub {
  color: var(--text-3);
  font-size: 12.5px;
}

.flow-review-modal.is-suspended:not(:has(.export-check-list))
  .export-check-status {
  flex: 1 1 auto;
  justify-content: center;
}

/* Only when the notice IS the window's content does it become a centred empty
   state. With a list present it keeps the ordinary warning-strip look above
   the problems, so it reads as context for them. */
.flow-review-modal.is-suspended:not(:has(.export-check-list))
  .export-check-suspended {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  margin: 0;
  padding: 26px 26px 34px;
  background: transparent;
  border: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
}

/* The icon becomes the empty state's mark, not a bullet beside the text. */
.flow-review-modal.is-suspended:not(:has(.export-check-list))
  .export-check-suspended
  .ui-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--ember) 13%, transparent);
  color: var(--ember);
}

.flow-review-modal.is-suspended:not(:has(.export-check-list))
  .export-check-suspended
  .ui-icon
  svg {
  width: 21px;
  height: 21px;
}

.flow-review-modal.is-suspended:not(:has(.export-check-list))
  .export-check-suspended
  > span {
  max-width: 42ch;
}

.flow-review-modal .export-check-panel {
  max-height: none;
  flex: 1 1 auto;
  min-height: 0;
  border-top: 0;
  box-shadow: none;
  background: transparent;
  overflow: hidden;
}

/* The modal already carries the title; the panel head keeps only its status
   line - how much was scanned, what failed, what was not checked at all. */
.flow-review-modal .export-check-head {
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
}

.flow-review-modal .export-check-title {
  display: none;
}

.flow-review-modal .export-check-sub {
  font-size: 13px;
  margin-top: 0;
  line-height: 1.5;
}

/* The severity chips are the summary of the whole scan - at this size they can
   be read at a glance instead of squinted at. */
.flow-review-modal .export-check-summary {
  gap: 8px;
  padding: 12px 22px;
}

.flow-review-modal .export-check-chip {
  font-size: 13px;
  padding: 5px 12px;
  border-radius: var(--r-sm);
}

.flow-review-modal .export-check-list {
  padding: 16px 22px 22px;
  gap: 12px;
  background: var(--surface-2);
}

.flow-review-modal .export-check-item {
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
}

.flow-review-modal .export-check-sev {
  font-size: 12px;
  padding: 4px 10px;
}

.flow-review-modal .export-check-item-title {
  font-size: 15px;
  line-height: 1.4;
}

.flow-review-modal .export-check-item-detail {
  font-size: 13.5px;
  margin-top: 6px;
  line-height: 1.6;
}

.flow-review-modal .export-check-actions {
  gap: 8px;
  margin-top: 12px;
}

.flow-review-modal .export-check-goto {
  font-size: 13px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
}

.flow-review-modal .export-check-risk {
  font-size: 11px;
  padding: 2px 8px;
}

/* A four-second proof clip is the thing being judged - give it real size. */
.flow-review-modal .export-check-proof {
  padding: 12px;
}

.flow-review-modal .export-check-proof-video {
  max-height: 420px;
}

.flow-review-modal .export-check-proof-status {
  font-size: 13px;
  margin-top: 10px;
}

/* The bulk action + the "what stays for a human" note sit together, and in a
   window this wide they read as a bar rather than a stray line. */
/* Sits ABOVE the list (head → summary → bulk → list → fixed), so it closes with
   a bottom rule; a top one would double up with the summary's. */
.flow-review-modal .export-check-bulk {
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.flow-review-modal .export-check-bulk .export-check-item-detail {
  margin-top: 0;
  font-size: 13px;
}

.flow-review-modal .export-check-ok,
.flow-review-modal .export-check-warn {
  font-size: 14px;
  padding: 14px 22px;
}

/* The undo trail closes the window; it must keep its height rather than be
   squeezed by a long list above it. */
.flow-review-modal .export-check-fixed {
  flex: 0 0 auto;
  max-height: 30%;
  overflow-y: auto;
  padding: 14px 22px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  .modal.modal-lg:has(.flow-review-modal),
  .modal:has(.flow-review-modal) {
    max-height: 94dvh;
  }
  .flow-review-modal .modal-head,
  .flow-review-modal .export-check-head,
  .flow-review-modal .export-check-summary,
  .flow-review-modal .export-check-list,
  .flow-review-modal .export-check-bulk,
  .flow-review-modal .export-check-fixed {
    padding-inline: 14px;
  }
}

/* ===== VFX modal ===== */
.modal:has(.vfx-modal) {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-width: min(1420px, 98vw);
  width: 100%;
  height: min(900px, 94vh);
  min-height: 680px;
  max-height: 94vh;
}

.vfx-modal {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: 100%;
  direction: rtl;
  background: var(--surface-2);
  overflow: hidden;
}

.vfx-modal .modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  background: var(--surface);
}

.vfx-m-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.vfx-modal .modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.vfx-m-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 99px;
  white-space: nowrap;
  margin-inline-start: auto;
}

.vfx-modal-body {
  display: grid;
  grid-template-columns: minmax(480px, 1fr) minmax(260px, 330px) minmax(
      320px,
      390px
    );
  grid-template-rows: minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  gap: 14px;
  padding: 14px;
}

/* Shared panel chrome */
.vfx-m-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

.vfx-m-panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
}

.vfx-m-panel-head svg {
  flex-shrink: 0;
  opacity: 0.75;
}

.vfx-m-panel-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

/* Tabs */
.vfx-m-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 10px 14px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.vfx-m-tab {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  transition:
    color 0.12s,
    background 0.12s;
}

.vfx-m-tab:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.vfx-m-tab.active {
  color: var(--text);
  background: var(--surface-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.vfx-m-tab-badge {
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 7px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

.vfx-m-panel--preview {
  grid-column: 1;
  grid-row: 1;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: auto;
}

.vfx-m-panel--preview .vfx-modal-preview-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.vfx-tab-panels {
  grid-column: 2;
  grid-row: 1;
  grid-column-end: 4;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.vfx-tab-panel {
  display: none;
  grid-template-columns: minmax(250px, 0.9fr) minmax(300px, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0 4px;
  -webkit-overflow-scrolling: touch;
}

.vfx-tab-panel.is-active {
  display: grid;
}

.vfx-m-panel--library,
.vfx-m-panel--active {
  flex: 0 0 auto;
  min-height: 0;
  height: 100%;
}

.vfx-m-panel--library {
  grid-column: 1;
  grid-row: 1;
}

.vfx-m-panel--active {
  grid-column: 2;
  grid-row: 1;
}

.vfx-m-panel--setup,
.vfx-prep-strip {
  grid-column: 1 / -1;
  grid-row: 1;
  flex: 0 0 auto;
}

.vfx-tab-panel:has(.vfx-m-panel--setup) .vfx-m-panel--library,
.vfx-tab-panel:has(.vfx-m-panel--setup) .vfx-m-panel--active,
.vfx-tab-panel:has(.vfx-prep-strip) .vfx-m-panel--library,
.vfx-tab-panel:has(.vfx-prep-strip) .vfx-m-panel--active {
  grid-row: 2;
}

.vfx-tab-panel:has(.vfx-m-panel--setup),
.vfx-tab-panel:has(.vfx-prep-strip) {
  grid-template-rows: auto minmax(0, 1fr);
}

.vfx-prep-strip {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 0 0 2px;
}

.vfx-m-panel--setup .vfx-setup-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 10px;
  padding: 10px 12px 12px;
}

.vfx-m-panel--setup .vfx-setup-body--single {
  grid-template-columns: minmax(0, 1fr);
}

.vfx-m-panel--library > .vfx-m-rails,
.vfx-m-panel--active > .vfx-m-active-wrap {
  padding: 10px 12px 12px;
}

.vfx-m-panel--library > .vfx-m-rails {
  min-height: 0;
}

.vfx-m-panel--active > .vfx-m-active-wrap {
  overflow-x: hidden;
  overflow-y: auto;
}

.vfx-m-setup-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-3);
}

.vfx-modal-preview-wrap {
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.vfx-modal-preview {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vfx-modal-monitor {
  position: relative;
  aspect-ratio: var(--mon-ar, 16 / 9);
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  background: #000;
  border-radius: var(--r-sm);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.vfx-modal-monitor video,
.vfx-modal-monitor img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.vfx-anchor-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  display: none;
}
.vfx-anchor-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.vfx-anchor-marker:active {
  cursor: grabbing;
}
.vfx-anchor-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}
.vfx-anchor-label {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.vfx-anchor-marker--handRight .vfx-anchor-dot,
.vfx-anchor-marker--handLeft .vfx-anchor-dot {
  background: var(--purple);
}
.vfx-anchor-marker--head .vfx-anchor-dot {
  background: var(--teal);
}
.vfx-anchor-marker--chest .vfx-anchor-dot {
  background: var(--orange);
}

.vfx-m-active-wrap {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.vfx-m-active {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  padding: 2px;
  -webkit-overflow-scrolling: touch;
}

.vfx-m-hint {
  margin: 0;
  padding: 18px 10px;
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.015);
}

.vfx-m-hint.is-busy {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* active effect card */
.vfx-m-card {
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition:
    border-color 0.12s,
    box-shadow 0.12s,
    background 0.12s;
}

.vfx-m-card.is-selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: inset 0 0 0 1px var(--accent-soft);
  cursor: default;
}

.vfx-m-card-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.vfx-m-card:not(.is-selected) .vfx-m-card-head {
  border-bottom: none;
}

.vfx-m-card-thumb {
  width: 42px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
  background: #000;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.vfx-m-card-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.vfx-m-card-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vfx-m-card-meta {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vfx-m-card-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
}

.vfx-m-card-x:hover {
  color: var(--red);
  background: rgba(220, 38, 38, 0.08);
}

.vfx-m-card-body {
  flex: 0 0 auto;
  min-width: 0;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.vfx-m-control-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 10px 0 0;
  border: none;
  border-top: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}

.vfx-m-control-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.05em;
}

.vfx-m-control-section-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
}

.vfx-m-slider-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px 10px;
  min-width: 0;
}

.vfx-m-card-body .slider-row,
.vfx-m-slider-row {
  grid-template-columns: minmax(0, 52px) minmax(0, 1fr) minmax(0, 32px);
  gap: 5px;
  min-width: 0;
}

.vfx-m-card-body .slider-row > label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vfx-m-card-body .slider-row .slider {
  height: 4px;
  width: 100%;
  min-width: 0;
}

.vfx-m-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.vfx-m-color {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--r-xs);
  cursor: pointer;
}

.vfx-m-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.vfx-m-target {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 0.12s,
    background 0.12s;
}

.vfx-m-target:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

.vfx-m-target.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* category rails */
.vfx-m-rails {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0 0;
  -webkit-overflow-scrolling: touch;
}

.vfx-m-rail-block {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 0 10px;
  border: none;
  border-bottom: 1px solid var(--divider);
  border-radius: 0;
  background: transparent;
}

.vfx-m-rail-cat {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  padding-inline-start: 0;
  border-inline-start: none;
}

.vfx-m-rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 10px;
  height: auto;
  overflow: visible;
  -webkit-overflow-scrolling: touch;
}

.vfx-m-tile {
  width: 100%;
  height: 92px;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition:
    border-color 0.12s,
    transform 0.12s,
    box-shadow 0.12s;
}

.vfx-m-tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.vfx-m-tile.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

.vfx-m-tile img {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  object-fit: cover;
  display: block;
  background: #000;
}

.vfx-m-tile span {
  flex: 0 0 auto;
  padding: 5px 4px 6px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-2);
  text-align: center;
  line-height: 1.2;
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .modal:has(.vfx-modal) {
    max-width: 100%;
    width: 100%;
    height: min(92dvh, 92vh);
    min-height: 0;
    max-height: min(92dvh, 92vh);
    padding: 0;
    overflow: hidden;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }

  .modal:has(.vfx-modal)::before {
    flex-shrink: 0;
    margin: 10px auto 0;
  }

  .vfx-modal {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    max-height: none;
    overflow: hidden;
  }

  .vfx-modal .modal-header {
    padding: 10px 14px;
    flex-shrink: 0;
  }

  .vfx-modal .modal-title {
    font-size: 15px;
  }

  .vfx-m-tabs {
    padding: 6px 10px 0;
  }

  .vfx-m-tab {
    padding: 8px 10px;
    font-size: 12px;
  }

  .vfx-modal-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 6px 10px 0;
    gap: 6px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  }

  /* Preview stays pinned at top with a real height box for the monitor */
  .vfx-m-panel--preview {
    flex: 0 0 auto;
    flex-shrink: 0;
    height: auto;
    border-radius: var(--r-md);
  }

  .vfx-m-panel--preview .vfx-m-panel-head {
    padding: 6px 10px;
  }

  .vfx-m-panel--preview .vfx-m-panel-title {
    font-size: 10px;
  }

  .vfx-m-panel--preview .vfx-modal-preview-wrap {
    flex: none;
    min-height: clamp(168px, 36dvh, 300px);
    height: clamp(168px, 36dvh, 300px);
    padding: 6px;
    background: #0a0a0a;
  }

  .vfx-tab-panels {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-bottom: 4px;
  }

  .vfx-tab-panel {
    overflow: visible;
    gap: 8px;
    padding: 0 0 8px;
  }

  .vfx-m-panel--library .vfx-m-panel-head,
  .vfx-m-panel--active .vfx-m-panel-head {
    padding: 8px 10px;
  }

  .vfx-modal-preview {
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    width: 100%;
  }

  .vfx-modal-monitor {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: unset;
  }

  .vfx-m-rails {
    overflow: visible;
    gap: 10px;
    max-height: none;
    padding: 0;
  }

  .vfx-m-rail-block {
    padding-bottom: 6px;
  }

  /* Horizontal swipe rails - saves vertical space on small screens */
  .vfx-m-rail {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
  }

  .vfx-m-rail::-webkit-scrollbar {
    display: none;
  }

  .vfx-m-tile {
    flex: 0 0 76px;
    width: 76px;
    height: 84px;
    scroll-snap-align: start;
  }

  .vfx-m-tile span {
    font-size: 10px;
    min-height: 24px;
  }

  .vfx-m-active-wrap {
    overflow-x: hidden;
    overflow-y: visible;
    min-height: 0;
  }

  .vfx-m-active {
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    gap: 10px;
    padding: 0;
  }

  .vfx-m-card {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
  }

  .vfx-m-panel--setup .vfx-setup-body {
    grid-template-columns: 1fr;
  }

  .vfx-m-slider-grid {
    grid-template-columns: 1fr;
  }

  .vfx-m-card-body .slider-row,
  .vfx-m-slider-row {
    grid-template-columns: minmax(0, 62px) minmax(0, 1fr) minmax(0, 40px);
  }

  .vfx-m-card-body .slider,
  .vfx-m-card-body input[type="range"] {
    height: 28px;
  }

  .vfx-m-card-body .slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }

  .vfx-m-card-body .slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }

  .vfx-m-targets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .vfx-m-target {
    min-height: 40px;
    font-size: 12px;
    padding: 8px 6px;
  }

  .vfx-prep-strip {
    gap: 4px;
  }

  .vfx-prep-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 8px 10px;
  }

  .vfx-prep-row-end {
    margin-inline-start: 0;
    width: 100%;
    justify-content: space-between;
  }

  .vfx-prep-redo {
    min-height: 36px;
  }

  .vfx-picker-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    padding-bottom: 2px;
  }

  .vfx-picker-chip {
    flex-shrink: 0;
    min-height: 36px;
    padding: 6px 12px;
  }
}

.vfx-m-analyze {
  align-self: flex-start;
  width: 100%;
}

/* VFX studio - subject & background panel */
.vfx-subject-wrap,
.vfx-subject {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Two distinct preparation cards (#1 attach-to-point, #2 isolate-from-bg) so the
   user stops conflating "זיהוי גוף" with "בידוד דמות". */
.vfx-prep-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px 12px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.vfx-prep-card--track {
  border-inline-start: 3px solid var(--purple);
}
.vfx-prep-card--isolate {
  border-inline-start: 3px solid var(--teal);
}

.vfx-prep-head {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.vfx-prep-num {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--border-strong, var(--border));
  color: var(--text-2);
  font-size: 11px;
  font-weight: 800;
}
.vfx-prep-num.is-done {
  background: var(--green);
  color: #fff;
}
.vfx-prep-ic {
  flex: 0 0 auto;
  color: var(--text-3);
}
.vfx-prep-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.vfx-prep-status {
  flex: 0 0 auto;
  margin-inline-start: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  background: var(--border);
}
.vfx-prep-status.is-done {
  color: #fff;
  background: var(--green);
}
.vfx-prep-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-2);
}
.vfx-prep-use {
  margin: 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
}
.vfx-prep-use.is-active {
  color: var(--text);
}
.vfx-prep-target {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-2);
}
.vfx-prep-target b {
  font-weight: 700;
  color: var(--text);
}

/* One compact preparation line: state · title · target ··· status · quality · redo. */
.vfx-prep-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex-wrap: wrap;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  transition: border-color 0.15s ease;
}
.vfx-prep-row--body {
  border-inline-start-color: var(--purple);
}
.vfx-prep-row--character {
  border-inline-start-color: var(--teal);
}
.vfx-prep-row.is-busy {
  border-inline-start-color: var(--accent);
}
.vfx-prep-row.is-done {
  border-inline-start-color: var(--green);
}
.vfx-prep-row-state {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-3);
}
.vfx-prep-row-state.is-busy {
  background: var(--accent-soft);
  color: var(--accent);
}
.vfx-prep-row-state.is-done {
  background: var(--green);
  color: #fff;
}
.vfx-prep-row-title {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.vfx-prep-row-target {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--text-3);
}
.vfx-prep-row-end {
  margin-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.vfx-prep-row-status {
  flex: 0 0 auto;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  background: var(--border);
  color: var(--text-3);
}
.vfx-prep-row-status.is-busy {
  background: var(--accent-soft);
  color: var(--accent);
}
.vfx-prep-row-status.is-done {
  background: var(--green);
  color: #fff;
}
.vfx-prep-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.vfx-prep-redo {
  flex: 0 0 auto;
}

/* VFX studio - character picker (above the two prep cards) */
.vfx-picker-wrap:not(:empty) {
  padding: 0;
}
.vfx-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.vfx-picker-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}
.vfx-picker-lbl {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
}
.vfx-picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.vfx-picker-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}
.vfx-picker-chip:hover {
  border-color: var(--border-strong);
}
.vfx-picker-chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent, #fff);
}

/* VFX studio - tappable person markers on the monitor */
.vfx-person-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.vfx-person-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}
.vfx-person-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  color: #fff;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}
.vfx-person-marker:hover .vfx-person-dot,
.vfx-person-marker:active .vfx-person-dot {
  transform: scale(1.12);
}
.vfx-person-check {
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity 0.12s ease,
    transform 0.12s ease;
}
.vfx-person-marker.is-selected .vfx-person-dot {
  background: var(--accent);
  border-color: #fff;
}
.vfx-person-marker.is-selected .vfx-person-check {
  opacity: 1;
  transform: scale(1);
}
.vfx-person-label {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
}
.vfx-person-marker.is-selected .vfx-person-label {
  background: var(--accent);
}

.vfx-subject-lbl {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
}

@media (max-width: 1100px) and (min-width: 769px) {
  .vfx-modal-body {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 390px);
  }

  .vfx-tab-panels {
    grid-column: 2;
    grid-column-end: 3;
  }

  .vfx-tab-panel.is-active {
    display: flex;
    flex-direction: column;
  }

  .vfx-m-panel--library,
  .vfx-m-panel--active,
  .vfx-m-panel--setup,
  .vfx-prep-strip {
    grid-column: auto;
    grid-row: auto;
    height: auto;
  }

  .vfx-m-panel--setup .vfx-setup-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .vfx-tab-panel.is-active {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .vfx-m-panel--library,
  .vfx-m-panel--active,
  .vfx-m-panel--setup,
  .vfx-prep-strip {
    grid-column: auto;
    grid-row: auto;
    height: auto;
    min-height: 0;
  }

  .vfx-m-panel--library > .vfx-m-rails,
  .vfx-m-panel--active > .vfx-m-active-wrap {
    padding: 8px 10px 10px;
  }
}

/* ── Slip-source modal - "בחר חלק מהסרטון" ───────────────────────────────── */
/* Fixed height (not just max-height): the body is a flex column where the
   preview flexes to fill, so the whole dialog always fits with no scrolling. */
.modal.modal-lg:has(.slip-modal) {
  display: flex;
  flex-direction: column;
  width: min(880px, 96vw);
  max-width: min(880px, 96vw);
  height: min(92vh, 820px);
  max-height: min(92vh, 820px);
  padding: 0;
  overflow: hidden;
}

.slip-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: inherit;
  min-height: 0;
  direction: rtl;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.slip-modal .modal-header {
  flex-shrink: 0;
  gap: 12px;
  margin: 0;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.slip-title-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.slip-title-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.slip-title-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slip-title-sub {
  max-width: min(560px, 64vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.25;
}

.slip-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-2);
}

/* buildVideoPlayer's own .vplayer-wrap already provides background/radius/
   overflow - this adds the modal-specific border + shadow, and makes the
   preview flex to fill whatever height the controls below leave, letterboxing
   the video inside (object-fit: contain) instead of forcing the body to
   scroll. */
.slip-preview-frame {
  flex: 1 1 0;
  min-height: 120px;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    var(--shadow-xs);
}

.slip-preview-frame .vplayer-video {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.slip-control-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 12px);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.slip-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.slip-control-head-start {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.slip-control-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
}

.slip-range-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}

.slip-range-label {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
}

.slip-range-value {
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.slip-part-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.slip-part-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.slip-part-tab.is-active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--text);
}

.slip-part-tab-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.slip-part-tab-time {
  direction: ltr;
  unicode-bidi: isolate;
  color: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.slip-part-tab--add,
.slip-part-tab--remove {
  border-style: dashed;
  color: var(--text-2);
}

.slip-part-tab--remove {
  border-style: solid;
  color: var(--danger, #c44);
}

.slip-add-hint {
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.35;
}

.slip-window-badge {
  position: absolute;
  top: 4px;
  inset-inline-start: 6px;
  z-index: 3;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 88%, #000);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  pointer-events: none;
}

.slip-window.is-secondary {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #fff 18%, transparent);
  opacity: 0.88;
}

.slip-window.is-active {
  opacity: 1;
}

/* Full source timeline: the highlighted window is the fixed-length slot; a
   draggable marker (slip-scrub) previews any single frame in the player. */
.slip-track-wrap {
  --slip-track-h: 66px;
  position: relative;
  padding-top: 24px; /* room for the scrub time bubble above the track */
}

.slip-track {
  position: relative;
  height: var(--slip-track-h);
  background:
    linear-gradient(
        90deg,
        color-mix(in srgb, var(--text) 11%, transparent) 0 1px,
        transparent 1px
      )
      0 0 / 10% 100%,
    linear-gradient(180deg, var(--surface-2), var(--surface-pressed));
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: crosshair;
  direction: ltr;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.slip-track::before {
  content: "";
  position: absolute;
  inset-inline: 10px;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--text) 12%, transparent);
  pointer-events: none;
}

.slip-dim {
  position: absolute;
  inset-block: 0;
  background: rgba(8, 11, 20, 0.4);
  backdrop-filter: saturate(0.7);
  pointer-events: none;
}

.slip-window {
  position: absolute;
  inset-block: 7px;
  min-width: 22px;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  box-shadow:
    0 8px 20px color-mix(in srgb, var(--accent) 22%, transparent),
    inset 0 0 0 1px color-mix(in srgb, #fff 34%, transparent);
  cursor: grab;
  z-index: 2;
}

.slip-window:active {
  cursor: grabbing;
}

.slip-window-grip {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #fff 62%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.slip-window-grip::before {
  content: "";
  width: 13px;
  height: 13px;
  opacity: 0.92;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0 2px,
    color-mix(in srgb, var(--accent) 80%, var(--text)) 2px 3.5px
  );
}

/* Resize handles at either edge - drag to grow/shrink how much of the source
   is used (the center grip only slips). */
.slip-handle {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 18px;
  display: grid;
  place-items: center;
  cursor: ew-resize;
  z-index: 3;
}

.slip-handle-left {
  left: -9px;
}

.slip-handle-right {
  right: -9px;
}

.slip-handle-grip {
  width: 8px;
  height: 58%;
  border-radius: 5px;
  background: var(--accent);
  border: 1px solid color-mix(in srgb, #fff 45%, var(--accent));
  box-shadow: 0 2px 7px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform 0.12s var(--ease-out);
}

.slip-handle:hover .slip-handle-grip,
.slip-handle:active .slip-handle-grip {
  transform: scaleY(1.12);
  background: var(--accent-hover, var(--accent));
}

/* Scrub marker: a draggable playhead that previews any frame of the source.
   Lives in an overflow-visible layer so its knob + time bubble sit above the
   track without being clipped. */
.slip-scrub-layer {
  position: absolute;
  left: 0;
  right: 0;
  top: 24px;
  height: var(--slip-track-h);
  overflow: visible;
  pointer-events: none;
  z-index: 5;
}

.slip-scrub {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
}

.slip-scrub::before {
  content: "";
  position: absolute;
  top: -5px;
  bottom: -5px;
  left: -1.5px;
  width: 3px;
  border-radius: 3px;
  background: var(--text);
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--surface) 75%, transparent);
}

.slip-scrub-knob {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--surface);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  cursor: ew-resize;
  pointer-events: auto;
  transition: transform 0.12s var(--ease-out);
}

.slip-scrub-knob:hover,
.slip-scrub-knob:active {
  transform: translateX(-50%) scale(1.16);
}

.slip-scrub-time {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--surface);
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}

.slip-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 650;
}

.slip-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.slip-legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
}

.slip-legend-dot--scrub {
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
}

.slip-legend-dot--edge {
  background: var(--accent);
}

.slip-legend-dot--window {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border: 1px solid var(--accent);
}

.slip-meta {
  display: flex;
  align-items: center;
  min-width: 0;
}

.slip-meta-dim {
  font-size: 12px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.slip-noslack {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--orange) 34%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--orange) 10%, var(--surface));
  font-size: 12px;
  color: color-mix(in srgb, var(--orange) 78%, var(--text));
  text-align: center;
}

.slip-noslack[hidden] {
  display: none;
}

.slip-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 14px 16px;
  border-top: 1px solid var(--divider);
  background: var(--surface);
}

@media (max-width: 760px) {
  .modal.modal-lg:has(.slip-modal) {
    width: 100%;
    max-width: 100%;
    height: min(92dvh, 92vh);
    max-height: min(92dvh, 92vh);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }

  .modal.modal-lg:has(.slip-modal)::before {
    flex: 0 0 auto;
    margin-top: 12px;
    margin-bottom: 0;
  }

  .slip-modal {
    max-height: min(92dvh, 92vh);
  }

  .slip-modal .modal-header {
    padding: 12px 14px;
  }

  .slip-title-icon {
    width: 30px;
    height: 30px;
  }

  .slip-title-sub {
    max-width: 58vw;
  }

  .slip-body {
    padding: 12px;
    gap: 12px;
  }

  .slip-control-panel {
    padding: 12px;
  }

  .slip-control-head {
    align-items: stretch;
    flex-direction: column;
  }

  .slip-range-pill {
    width: 100%;
    justify-content: space-between;
  }

  .slip-track-wrap {
    --slip-track-h: 56px;
  }

  .slip-footer {
    padding: 12px;
  }

  .slip-footer .btn {
    flex: 1;
  }
}

/* ── Subtitles / lyrics modal ─────────────────────────────────────────────── */
.modal.modal-lg:has(.sub-modal),
.modal:has(.sub-modal) {
  display: flex;
  flex-direction: column;
  width: min(1080px, 96vw);
  max-width: min(1080px, 96vw);
  height: min(88vh, 740px);
  max-height: min(88vh, 740px);
  padding: 0;
  overflow: hidden;
}

.sub-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  direction: rtl;
  text-align: right;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.sub-modal-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px 11px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface);
}

.sub-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
}

.sub-modal-title-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.sub-modal-title-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sub-modal-title-main {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.sub-modal-title-sub {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.3;
}

.sub-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  overflow: hidden;
  background: var(--surface-2);
}

.sub-col {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.sub-col-style {
  overflow: hidden;
}

.sub-field-head,
.sub-style-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sub-style-head {
  align-items: flex-start;
}

.sub-field-head label,
.sub-col-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.sub-style-note {
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.35;
}

.sub-upload-btn,
.sub-clear,
.sub-done,
.sub-enable {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.sub-upload-btn {
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.sub-upload-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: var(--accent-soft);
  color: var(--accent);
}

.sub-textarea {
  width: 100%;
  min-height: 230px;
  flex: 1 1 auto;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-family: "Segoe UI", "Heebo", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    background 0.15s;
}

.sub-textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-focus);
}

.sub-summary {
  min-height: 28px;
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.35;
}

.sub-summary.is-ok {
  border-color: color-mix(in srgb, var(--green) 34%, var(--border));
  background: color-mix(in srgb, var(--green) 9%, var(--surface));
  color: color-mix(in srgb, var(--green) 78%, var(--text));
  font-weight: 600;
}

.sub-summary.is-warn {
  border-color: color-mix(in srgb, var(--orange) 34%, var(--border));
  background: color-mix(in srgb, var(--orange) 10%, var(--surface));
  color: color-mix(in srgb, var(--orange) 78%, var(--text));
}

.sub-hint {
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.4;
}

.sub-style-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.sub-style-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
}

.sub-style-preview-frame {
  position: relative;
  height: 112px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  background:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 100%
      50%,
    linear-gradient(120deg, #0a0a0d 0%, #202128 48%, #44444d 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.sub-style-preview-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      circle at 18% 18%,
      rgba(255, 255, 255, 0.18),
      transparent 34%
    ),
    linear-gradient(180deg, transparent 42%, rgba(0, 0, 0, 0.36));
  pointer-events: none;
}

.sub-style-preview-text-wrap {
  position: absolute;
  inset-inline: 8%;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.sub-style-preview-frame[data-position="top"] .sub-style-preview-text-wrap {
  top: 13px;
}

.sub-style-preview-frame[data-position="middle"] .sub-style-preview-text-wrap {
  top: 50%;
  transform: translateY(-50%);
}

.sub-style-preview-frame[data-position="bottom"] .sub-style-preview-text-wrap,
.sub-style-preview-frame:not([data-position]) .sub-style-preview-text-wrap {
  bottom: 13px;
}

.sub-style-preview-text {
  display: inline-block;
  max-width: 100%;
  padding: 0;
  border-radius: 6px;
  text-align: center;
  line-height: 1.16;
  white-space: nowrap;
  transform-origin: center center;
}

.sub-style-preview-text.has-box {
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.58);
}

.sub-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.sub-row-label {
  flex: 0 0 84px;
  width: 84px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.sub-select {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  padding: 0 12px 0 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    background 0.15s;
}

.sub-select:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-focus);
}

.sub-range-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sub-range {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

.sub-row-value {
  flex-shrink: 0;
  width: 48px;
  text-align: left;
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.sub-color-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-color {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.sub-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.sub-color::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}

.sub-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.sub-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 5px;
  padding: 0;
  cursor: pointer;
  box-shadow: none;
}

.sub-swatch:hover {
  transform: none;
}

.sub-swatch.is-on {
  box-shadow:
    0 0 0 2px var(--surface),
    0 0 0 3.5px var(--accent);
}

.sub-toggles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sub-toggle {
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.sub-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sub-toggle.is-on {
  border-color: transparent;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.sub-toggles .sub-toggle {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.sub-toggles .sub-toggle.is-on {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-soft-2);
}

.sub-tabs {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sub-tab {
  min-height: 32px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.sub-tab.is-on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.sub-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  padding-inline-end: 2px;
}

.sub-panel[hidden] {
  display: none;
}

.sub-section-title {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
}

.sub-panel[data-panel="type"] {
  overflow: hidden;
}

.sub-panel[data-panel="type"] > .sub-section-title,
.sub-panel[data-panel="type"] > .sub-row {
  flex-shrink: 0;
}

.sub-font-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sub-font-section {
  padding: 8px 8px 2px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
}

.sub-font-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: right;
}

.sub-font-card:hover {
  background: var(--surface-hover);
}

.sub-font-card.is-on {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-soft-2);
}

.sub-font-sample {
  font-size: 15px;
  line-height: 1.2;
  max-width: 46%;
}

.sub-font-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.sub-font-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
}

.sub-font-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
}

.sub-panel-color {
  gap: 0;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sub-panel-color > .sub-row {
  gap: 10px;
  padding: 7px 2px;
  border: none;
  border-radius: 0;
  background: transparent;
  border-bottom: 1px solid var(--divider);
}

.sub-panel-color > .sub-row:last-child {
  border-bottom: none;
}

.sub-panel-color > .sub-section-title {
  margin: 2px 2px 0;
  padding-top: 8px;
}

.sub-choice .sub-row-label {
  flex: 0 0 84px;
  width: 84px;
  font-weight: 600;
}

.sub-choice .sub-color-wrap {
  gap: 8px;
}

.sub-choice .sub-color,
.sub-choice .sub-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

.sub-choice .sub-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.sub-choice .sub-color::-webkit-color-swatch {
  border: none;
  border-radius: 5px;
}

.sub-choice .sub-swatches {
  flex: 1;
  gap: 6px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.sub-choice .sub-swatch.is-on {
  box-shadow:
    0 0 0 2px var(--surface-2),
    0 0 0 3.5px var(--accent);
}

.sub-panel .sub-range {
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  background: transparent;
  cursor: pointer;
}

.sub-panel .sub-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 14%, var(--surface));
}

.sub-panel .sub-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
}

.sub-panel .sub-range::-moz-range-track {
  height: 4px;
  border: none;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 14%, var(--surface));
}

.sub-panel .sub-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
}

.sub-effect-row {
  padding-top: 8px;
  padding-bottom: 8px;
}

.sub-effect-toggles {
  flex: 1;
  background: var(--surface);
}

.sub-effect-toggles .sub-toggle {
  flex: 1 1 0;
}

.sub-pos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sub-pos .sub-toggle {
  height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.sub-pos .sub-toggle::before {
  content: "";
  width: 28px;
  height: 18px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  background: linear-gradient(currentColor, currentColor) center 78% / 12px 2px
    no-repeat;
  opacity: 0.8;
}

.sub-pos .sub-toggle[data-pos="top"]::before {
  background-position: center 22%;
}

.sub-pos .sub-toggle[data-pos="middle"]::before {
  background-position: center 50%;
}

.sub-panel-motion:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.sub-motion-block {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sub-motion-block + .sub-motion-block {
  margin-top: 0;
  border-top: none;
}

.sub-motion-block > .sub-section-title:first-child {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 0 2px 6px;
  background: var(--surface-2);
}

.sub-anim-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.sub-anim-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  text-align: center;
}

.sub-anim-card:hover {
  background: var(--surface-hover);
}

.sub-anim-card.is-on {
  border-color: transparent;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-soft-2);
  color: var(--accent);
}

.sub-anim-demo {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
  background:
    radial-gradient(
      circle at 20% 20%,
      rgba(255, 255, 255, 0.14),
      transparent 36%
    ),
    linear-gradient(160deg, #101014, #2c2c34);
}

.sub-anim-name {
  min-height: 2em;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.sub-replay {
  margin-inline-start: auto;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.sub-style-preview-head .sub-replay {
  color: var(--text-2);
  border-color: var(--border);
  background: var(--surface-2);
}

.sub-modal-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--divider);
  background: var(--surface);
}

.sub-footer-spacer {
  flex: 1;
}

.sub-enable {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.sub-enable.is-on {
  border-color: color-mix(in srgb, var(--green) 52%, var(--border));
  background: color-mix(in srgb, var(--green) 12%, var(--surface));
  color: color-mix(in srgb, var(--green) 75%, var(--text));
}

.sub-clear {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.sub-clear:hover {
  border-color: color-mix(in srgb, var(--red) 22%, var(--border));
  background: color-mix(in srgb, var(--red) 7%, var(--surface));
  color: var(--red);
}

.sub-done {
  min-height: 34px;
  padding: 8px 17px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.sub-done:hover {
  background: var(--accent-hover);
}

@media (max-width: 840px) {
  .modal-backdrop:has(.sub-modal) {
    align-items: flex-end;
    padding: 0;
  }

  .modal.modal-lg:has(.sub-modal),
  .modal:has(.sub-modal) {
    width: 100%;
    max-width: 100%;
    height: min(94dvh, 94vh);
    max-height: min(94dvh, 94vh);
    margin: 0;
    padding: 0;
    overflow: hidden;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }

  .modal.modal-lg:has(.sub-modal)::before,
  .modal:has(.sub-modal)::before {
    flex: 0 0 auto;
    margin: 8px auto 0;
  }

  .sub-modal {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .sub-modal-head {
    padding: 8px 12px 10px;
  }

  .sub-modal .modal-close {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .sub-modal-title-icon {
    width: 30px;
    height: 30px;
  }

  .sub-modal-title-sub {
    display: none;
  }

  .sub-modal-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(132px, 32%) minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
    overflow: hidden;
  }

  .sub-col,
  .sub-col-style,
  .sub-col-text {
    overflow: hidden;
    min-height: 0;
    padding: 10px;
    gap: 8px;
  }

  .sub-field-head {
    flex-wrap: wrap;
  }

  .sub-upload-btn,
  .sub-tab,
  .sub-toggle,
  .sub-font-card,
  .sub-enable,
  .sub-clear,
  .sub-done {
    min-height: 44px;
  }

  .sub-col-text {
    overflow: auto;
  }

  .sub-textarea {
    min-height: 88px;
    flex: 1 1 auto;
    font-size: 16px;
  }

  .sub-hint {
    display: none;
  }

  .sub-style-preview {
    flex-shrink: 0;
  }

  .sub-style-preview-frame {
    height: 64px;
  }

  .sub-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sub-panel[data-panel="type"] {
    overflow: hidden;
  }

  .sub-font-grid {
    flex: 1 1 auto;
    min-height: 96px;
    overflow: auto;
  }

  .sub-choice .sub-color,
  .sub-choice .sub-swatch {
    width: 32px;
    height: 32px;
  }

  .sub-anim-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sub-anim-card {
    min-height: 72px;
  }

  .sub-modal-footer {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px max(12px, env(safe-area-inset-bottom, 12px));
  }

  .sub-footer-spacer {
    display: none;
  }

  .sub-enable {
    flex: 1 1 100%;
  }

  .sub-clear,
  .sub-done {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .sub-row-label,
  .sub-choice .sub-row-label {
    flex: 0 0 68px;
    width: 68px;
  }

  .sub-upload-btn,
  .sub-range-wrap,
  .sub-color-wrap,
  .sub-toggles {
    width: auto;
    flex: 1;
    min-width: 0;
  }
}

/* ============================================================
   Smart sharpen ("חידוד חכם") - editor batch upscale scan.
   Mirrors the auto-soundtrack modal chrome so the two editor
   batch tools read as one family.
   ============================================================ */
.modal.modal-lg:has(.enh-modal),
.modal:has(.enh-modal) {
  display: flex;
  flex-direction: column;
  width: min(940px, 96vw);
  max-width: min(940px, 96vw);
  max-height: min(90dvh, 780px);
  padding: 0;
  overflow: hidden;
}

.enh-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: inherit;
  min-height: 0;
  direction: rtl;
  text-align: right;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.enh-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px 11px;
  border-bottom: 1px solid var(--divider);
}

.enh-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.enh-title-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.enh-title-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.enh-title-main {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.enh-title-sub {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.35;
}

.enh-bulk {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  background: var(--surface-2);
}

.enh-bulk-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.enh-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.enh-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.enh-row:hover {
  background: var(--surface-hover);
}

.enh-row-pick {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1 1 260px;
  cursor: pointer;
}

.enh-row-pick input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.enh-row-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.enh-row-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.enh-row-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
}

.enh-res {
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

.enh-verdict {
  padding: 1px 7px;
  border-radius: var(--r-pill);
  font-weight: 600;
  border: 1px solid transparent;
}

.enh-verdict--needed {
  background: color-mix(in srgb, var(--orange) 16%, transparent);
  color: var(--orange);
  border-color: color-mix(in srgb, var(--orange) 30%, transparent);
}

.enh-verdict--gain {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 26%, transparent);
}

.enh-verdict--fine {
  background: color-mix(in srgb, var(--green) 14%, transparent);
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 26%, transparent);
}

.enh-verdict--unknown,
.enh-verdict--blocked {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
}

.enh-row-tool {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  flex: 0 1 300px;
  min-width: 0;
}

.enh-row-tool-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--text-3);
}

.enh-cost {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  flex-shrink: 0;
}

.enh-manual {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--divider);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}
.enh-manual-copy {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.35;
}

.enh-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 14px;
  border-top: 1px solid var(--divider);
  background: var(--surface-2);
}

.enh-replace {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}

.enh-replace input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.enh-summary {
  margin-inline-start: auto;
  font-size: 12px;
  color: var(--text-3);
}

@media (max-width: 720px) {
  .enh-row {
    align-items: stretch;
    flex-direction: column;
  }

  .enh-row-tool {
    flex: 1 1 auto;
  }

  .enh-summary {
    margin-inline-start: 0;
    flex: 1 1 100%;
  }
}

/* Unify look - before/after colour preview before applying the film-wide grade */
.modal.modal-lg:has(.ulook-modal),
.modal:has(.ulook-modal) {
  display: flex;
  flex-direction: column;
  width: min(920px, 96vw);
  max-width: min(920px, 96vw);
  max-height: min(90dvh, 820px);
  padding: 0;
  overflow: hidden;
}

.ulook-list {
  gap: 8px;
}

.ulook-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
}

.ulook-row:hover {
  background: var(--surface-hover);
}

.ulook-row.is-strong {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.ulook-row.is-mild {
  opacity: 0.78;
}

.ulook-row.is-failed {
  opacity: 0.55;
}

.ulook-row.is-scanning {
  opacity: 0.7;
}

.ulook-row-pick {
  display: flex;
  align-items: flex-start;
  padding-top: 4px;
}

.ulook-row-pick input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.ulook-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ulook-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ulook-name {
  font-size: 13px;
  font-weight: 600;
}

.ulook-delta {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.ulook-compare {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ulook-side {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ulook-side-label {
  font-size: 11px;
  color: var(--text-3);
}

.ulook-frame {
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: #111;
  border: 1px solid var(--border);
}

.ulook-frame img,
.ulook-thumb-empty {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ulook-thumb-empty {
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.45);
  font-size: 18px;
}

.ulook-arrow {
  flex-shrink: 0;
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
  padding-top: 14px;
}

.ulook-status {
  font-size: 12px;
  color: var(--text-3);
}

.ulook-footer {
  justify-content: space-between;
}

.ulook-foot-note {
  font-size: 11px;
  color: var(--text-3);
  max-width: 52%;
  line-height: 1.35;
}

@media (max-width: 720px) {
  .ulook-compare {
    flex-direction: column;
    align-items: stretch;
  }

  .ulook-arrow {
    padding-top: 0;
    text-align: center;
    transform: rotate(-90deg);
  }

  .ulook-foot-note {
    max-width: none;
    flex: 1 1 100%;
  }
}

/* ── Multi-select + Flicker Montage ─────────────────────────────────────────
   A "marked" clip is part of a run selected for a batch tool (Ctrl/Shift click)
   but is not the primary selection, so it reads as clearly grouped WITHOUT
   competing with the orange primary-selection ring. */
.tl-clip.is-marked {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px var(--accent),
    0 2px 8px rgba(90, 200, 250, 0.35);
  z-index: 2;
}
.tl-clip.is-marked .tl-clip-thumb-video,
.tl-clip.is-marked .tl-clip-thumb {
  filter: brightness(1);
}

/* The block itself: strobe stripes drawn at the real cut positions, so the
   montage's rhythm is readable straight off the timeline. */
.tl-flicker-stripes {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}
.tl-flicker-stripe {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.5),
    rgba(255, 255, 255, 0.12)
  );
  mix-blend-mode: screen;
}
/* Gaps between the stripes are the black frames - show them as real black so
   the strip previews the strobe instead of just tinting the thumbnail. */
.tl-clip.is-flicker .tl-flicker-stripes {
  background: rgba(0, 0, 0, 0.72);
}

.tl-flicker-badge {
  position: absolute;
  top: 4px;
  inset-inline-start: 5px;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 15px;
  padding: 0 4px 0 3px;
  border-radius: 3px;
  background: rgba(120, 80, 255, 0.9);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  pointer-events: none;
  white-space: nowrap;
}
.tl-flicker-badge svg {
  flex-shrink: 0;
}

/* ===== Audio mixer — timeline studio ===== */
.modal:has(.mx-wrap) {
  display: flex;
  flex-direction: column;
  width: min(1440px, 98vw);
  max-width: min(1440px, 98vw);
  height: min(94dvh, 980px);
  max-height: min(94dvh, 980px);
  padding: 0;
  overflow: hidden;
}

.mx-wrap {
  --mx-head: 232px;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  gap: 0;
  color: var(--text);
  background: var(--surface);
  overflow: hidden;
  user-select: none;
}

.mx-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider, var(--border));
}

.mx-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mx-title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: 9px;
  color: var(--accent);
  background: var(
    --accent-soft,
    color-mix(in srgb, var(--accent) 12%, transparent)
  );
}

.mx-title-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.mx-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.15;
}

.mx-title-copy > span {
  font-size: 12px;
  color: var(--text-2, var(--text-muted));
}

.mx-channel-count {
  margin-inline-start: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text-2, var(--text-muted));
  font-size: 11px;
  font-weight: 700;
}

.mx-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--divider, var(--border));
  background: color-mix(in srgb, var(--text) 3%, var(--surface));
}

.mx-transport {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mx-transport-btn,
.mx-transport-play,
.mx-tool,
.mx-m,
.mx-zero,
.mx-block-mute {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--text) 5%, var(--surface));
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
}

.mx-transport-btn,
.mx-transport-play {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
}

.mx-transport-play {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-color: var(--accent);
  color: #14120c;
}

.mx-transport-play.is-playing {
  background: var(--red, #e25555);
  border-color: var(--red, #e25555);
  color: #fff;
}

.mx-transport-btn:hover,
.mx-transport-play:hover,
.mx-tool:hover,
.mx-m:hover,
.mx-zero:hover {
  filter: brightness(1.06);
}

.mx-transport-time {
  min-width: 9.5em;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--text);
}

.mx-sep {
  width: 1px;
  align-self: stretch;
  min-height: 22px;
  background: var(--border);
}

.mx-tool {
  height: 30px;
  padding: 0 8px;
  border-radius: 8px;
}

.mx-tool:disabled {
  opacity: 0.4;
  cursor: default;
  filter: none;
}

.mx-tool.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #14120c;
}

.mx-tool-danger.is-on,
.mx-m.is-on,
.mx-block-mute.is-on {
  background: var(--red, #e25555);
  border-color: var(--red, #e25555);
  color: #fff;
}

.mx-zoom,
.mx-duck {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 11px;
  color: var(--text-2, var(--text-muted));
}

.mx-zoom input,
.mx-duck input,
.mx-lane-vol input {
  accent-color: var(--accent);
  cursor: pointer;
}

.mx-zoom input {
  width: 92px;
}

.mx-duck input {
  width: 88px;
}

.mx-duck b,
.mx-db {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}

.mx-master-mini {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
  font-size: 11px;
  color: var(--text-2, var(--text-muted));
}

.mx-master-meter,
.mx-lane-meter {
  position: relative;
  overflow: hidden;
  border-radius: 99px;
  background: color-mix(in srgb, var(--text) 12%, transparent);
}

.mx-master-meter {
  width: 88px;
  height: 8px;
}

.mx-master-meter-fill,
.mx-lane-meter-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #3cb371, #e2b340 72%, #e25555);
}

.mx-master-meter.is-hot {
  box-shadow: 0 0 0 1px var(--red, #e25555);
}

.mx-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  direction: ltr;
}

.mx-ruler-clip {
  flex: 0 0 32px;
  height: 32px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.mx-ruler-inner {
  display: flex;
  height: 32px;
}

.mx-corner,
.mx-lane-head {
  position: sticky;
  left: 0;
  flex: 0 0 var(--mx-head);
  width: var(--mx-head);
  z-index: 6;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-sizing: border-box;
}

.mx-corner {
  z-index: 7;
  height: 32px;
}

.mx-ruler {
  position: relative;
  height: 32px;
  cursor: ew-resize;
  background: linear-gradient(
    180deg,
    transparent 22px,
    color-mix(in srgb, var(--text) 14%, transparent) 22px,
    color-mix(in srgb, var(--text) 14%, transparent) 23px,
    transparent 23px
  );
}

.mx-tick,
.mx-minor {
  position: absolute;
  top: 0;
  font-style: normal;
  pointer-events: none;
}

.mx-tick {
  padding-top: 2px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-2, var(--text-muted));
  transform: translateX(4px);
}

.mx-minor {
  width: 1px;
  height: 8px;
  top: 24px;
  background: color-mix(in srgb, var(--text) 22%, transparent);
}

.mx-playhead-mark {
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #ff4d4f;
  transform: translateX(-6px);
  z-index: 2;
  pointer-events: none;
}

.mx-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--text) 4%, transparent),
      transparent 28px
    ),
    color-mix(in srgb, var(--text) 4.5%, var(--surface));
}

.mx-lanes {
  position: relative;
  min-height: 100%;
}

.mx-row {
  display: flex;
  height: 92px;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 8%, var(--border));
}

.mx-lane-head {
  height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px 6px 14px;
  direction: rtl;
  box-shadow: inset -6px 0 0 var(--lane, transparent);
}

.mx-lane-head.is-selected {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.mx-lane-id {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.mx-lane-id b {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--lane, var(--accent));
  color: #1a140c;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.mx-lane-id span,
.mx-lane-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mx-lane-id span {
  flex: 1 1 auto;
  font-size: 12px;
  font-weight: 700;
}

.mx-lane-name {
  font-size: 11px;
  color: var(--text-2, var(--text-muted));
}

.mx-m,
.mx-zero {
  width: 22px;
  height: 20px;
  padding: 0;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
}

.mx-lane-vol {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mx-lane-vol input {
  flex: 1 1 auto;
  min-width: 0;
  height: 16px;
}

.mx-lane-meter {
  height: 4px;
}

.mx-lane {
  position: relative;
  height: 92px;
  background-color: color-mix(
    in srgb,
    var(--lane, transparent) 11%,
    transparent
  );
  background-image: repeating-linear-gradient(
    to right,
    transparent 0,
    transparent calc(var(--mx-pps) * 1px - 1px),
    color-mix(in srgb, var(--text) 9%, transparent)
      calc(var(--mx-pps) * 1px - 1px),
    color-mix(in srgb, var(--text) 9%, transparent) calc(var(--mx-pps) * 1px)
  );
}

.mx-lane-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding-inline-start: 14px;
  color: var(--text-3, var(--text-muted));
  font-size: 12px;
  pointer-events: none;
}

.mx-block {
  position: absolute;
  top: 11px;
  height: 70px;
  box-sizing: border-box;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid
    color-mix(in srgb, var(--lane, var(--accent)) 72%, transparent);
  background: color-mix(
    in srgb,
    var(--lane, var(--accent)) 30%,
    var(--surface)
  );
  box-shadow: inset 6px 0 0 var(--lane, var(--accent));
  cursor: grab;
  touch-action: none;
}

.mx-block.is-locked {
  cursor: pointer;
}

.mx-wrap.is-razor .mx-block,
.mx-wrap.is-envelope .mx-block {
  cursor: crosshair;
}

.mx-block.is-selected {
  z-index: 3;
  border-color: var(--text);
  box-shadow:
    inset 6px 0 0 var(--lane, var(--accent)),
    0 0 0 2px color-mix(in srgb, var(--text) 80%, transparent);
}

.mx-block.is-muted {
  opacity: 0.42;
  filter: saturate(0.4);
}

.mx-wave {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mx-wave canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.mx-block-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 3px 6px 3px 8px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(12, 16, 22, 0.88) 42%);
  color: #fff;
}

.mx-block-label.has-script {
  top: 0;
  bottom: auto;
  padding: 4px 24px 8px 8px;
  background: linear-gradient(
    180deg,
    rgba(12, 16, 22, 0.9) 0%,
    rgba(12, 16, 22, 0.72) 68%,
    transparent 100%
  );
}

.mx-block-kicker {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.mx-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 16px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--lane, #fff);
  color: #1a140c;
  font-style: normal;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.mx-block-label b,
.mx-script-line {
  min-width: 0;
  overflow: hidden;
}

.mx-block-label b {
  flex: 1 1 auto;
  font-size: 12px;
  font-weight: 750;
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mx-block-time {
  flex: 0 0 auto;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.78);
}

.mx-script-line {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
}

.mx-script {
  position: absolute;
  top: 3px;
  z-index: 5;
  height: 20px;
  box-sizing: border-box;
  display: block;
  padding: 2px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--lane, #e2b340) 86%, #111);
  color: #1a140c;
  font-size: 12px;
  font-weight: 750;
  line-height: 16px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.mx-script.is-roomy {
  top: 14px;
  height: auto;
  max-height: 64px;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-height: 1.35;
  padding: 5px 8px;
}

.mx-trim {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  z-index: 4;
  cursor: ew-resize;
}

.mx-trim.is-left {
  left: 0;
}
.mx-trim.is-right {
  right: 0;
}

.mx-trim::after {
  content: "";
  position: absolute;
  top: 16px;
  bottom: 16px;
  width: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.9);
}

.mx-trim.is-left::after {
  left: 3px;
}
.mx-trim.is-right::after {
  right: 3px;
}

.mx-wrap.is-razor .mx-trim,
.mx-wrap.is-envelope .mx-trim {
  display: none;
}

.mx-block-mute {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 6;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  pointer-events: auto;
}

.mx-env {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mx-wrap.is-envelope .mx-env {
  pointer-events: auto;
  cursor: crosshair;
}

.mx-env-fill {
  fill: rgba(255, 224, 138, 0.16);
}

.mx-env-line {
  fill: none;
  stroke: #ffe08a;
  stroke-width: 1.75;
  stroke-linejoin: round;
}

.mx-env-unity {
  stroke: rgba(255, 255, 255, 0.38);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.mx-env-dot {
  fill: #ffe08a;
  stroke: #1a1200;
  stroke-width: 1;
  cursor: grab;
}

.mx-playhead,
.mx-snap-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  pointer-events: none;
  z-index: 4;
}

.mx-playhead {
  background: #ff4d4f;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.mx-snap-guide {
  background: var(--accent);
  opacity: 0.85;
}

.mx-readout {
  position: fixed;
  z-index: 80;
  padding: 3px 7px;
  border-radius: 6px;
  background: #141820;
  color: #fff;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  direction: ltr;
}

.mx-inspect {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-height: 52px;
  padding: 8px 12px;
  border-top: 1px solid var(--divider, var(--border));
  background: var(--surface);
}

.mx-inspect-name {
  font-size: 13px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mx-inspect-note {
  margin: 0;
  flex: 1 1 240px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-2, var(--text-muted));
}

.mx-field {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-2, var(--text-muted));
}

.mx-num {
  width: 76px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: color-mix(in srgb, var(--text) 4%, var(--surface));
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  user-select: text;
}

.mx-field-vol {
  display: none;
}

.mx-num:disabled {
  opacity: 0.7;
}

@media (max-width: 860px) {
  .modal-backdrop:has(.mx-wrap) {
    padding: 0;
    align-items: stretch;
  }

  .modal:has(.mx-wrap) {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .mx-wrap {
    --mx-head: 108px;
  }

  .mx-head {
    min-height: 48px;
    padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px
      max(10px, env(safe-area-inset-left));
  }

  .mx-close {
    width: 44px;
    height: 44px;
  }

  .mx-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 8px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
    -webkit-overflow-scrolling: touch;
  }

  .mx-toolbar::-webkit-scrollbar {
    display: none;
  }

  .mx-transport,
  .mx-zoom,
  .mx-duck,
  .mx-master-mini,
  .mx-tool,
  .mx-sep {
    flex: 0 0 auto;
  }

  .mx-tool span,
  .mx-duck > span,
  .mx-zoom span,
  .mx-title-copy > span,
  .mx-master-mini > span,
  .mx-lane-vol,
  .mx-lane-meter,
  .mx-lane-name {
    display: none;
  }

  .mx-transport-play {
    width: 44px;
    height: 44px;
  }

  .mx-duck input,
  .mx-zoom input {
    width: 96px;
  }

  .mx-lane-head {
    justify-content: flex-start;
    gap: 4px;
    padding: 6px 6px 6px 10px;
  }

  .mx-lane-id {
    flex-wrap: wrap;
    align-content: center;
  }

  .mx-lane-id b {
    order: 0;
  }

  .mx-m {
    order: 1;
    width: 32px;
    height: 32px;
    margin-inline-start: auto;
  }

  .mx-lane-id span {
    order: 2;
    flex: 1 1 100%;
    font-size: 11px;
    line-height: 1.15;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .mx-transport-btn,
  .mx-tool {
    min-width: 40px;
    min-height: 40px;
  }

  .mx-scroll {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .mx-trim {
    width: 18px;
  }

  .mx-block-mute {
    width: 28px;
    height: 28px;
    top: 3px;
    right: 3px;
  }

  .mx-inspect {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    min-height: 48px;
    -webkit-overflow-scrolling: touch;
    padding: 8px max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .mx-inspect::-webkit-scrollbar {
    display: none;
  }

  .mx-inspect-note {
    flex: 0 1 180px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .mx-field-vol {
    display: inline-flex;
    flex: 1 1 150px;
    min-width: 150px;
  }

  .mx-field-vol input {
    flex: 1 1 auto;
    min-width: 72px;
    height: 28px;
  }
}

@media (max-width: 860px) and (max-height: 480px) {
  .mx-row,
  .mx-lane,
  .mx-lane-head {
    height: 64px;
  }

  .mx-lane-head {
    overflow: hidden;
  }

  .mx-lane-id span {
    -webkit-line-clamp: 1;
  }

  .mx-block {
    top: 4px;
    height: 56px;
  }

  .mx-script.is-roomy {
    top: 4px;
    max-height: 40px;
    -webkit-line-clamp: 2;
  }
}

/* ===== Blocked-videos check ("בדיקת סרטונים חסומים") =====
   House modal pattern, same as .enh-modal: head with an icon tile, a status
   strip, a scrolling list, a footer. All colours come from tokens so the
   modal follows the theme (the old inline styles hardcoded #2a8/#c44/#c80). */
.modal.modal-lg:has(.fstub-modal),
.modal:has(.fstub-modal) {
  display: flex;
  flex-direction: column;
  width: min(720px, 96vw);
  max-width: min(720px, 96vw);
  max-height: min(88dvh, 720px);
  padding: 0;
  overflow: hidden;
}

.fstub-modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: inherit;
  min-height: 0;
  direction: rtl;
  text-align: right;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

.fstub-head {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px 11px;
  border-bottom: 1px solid var(--divider);
}

.fstub-title {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.fstub-title-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.fstub-title-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.fstub-title-main {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.fstub-title-sub {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.45;
}

.fstub-status {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--divider);
}

.fstub-status-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--text-3);
}

.fstub-status.is-ok .fstub-status-icon {
  color: var(--green);
}

.fstub-status.is-warn .fstub-status-icon {
  color: var(--ember);
}

.fstub-status.is-bad {
  color: var(--red);
}

.fstub-status.is-bad .fstub-status-icon {
  color: var(--red);
}

.fstub-status.is-busy .fstub-status-icon {
  animation: fstubSpin 1.1s linear infinite;
}

@keyframes fstubSpin {
  to {
    transform: rotate(-360deg);
  }
}

.fstub-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fstub-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.fstub-row:hover {
  background: var(--surface-hover);
}

.fstub-thumb {
  width: 72px;
  height: 41px;
  flex: 0 0 auto;
  border-radius: 7px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fstub-thumb-ph {
  display: inline-flex;
  color: var(--text-3);
  opacity: 0.6;
}

.fstub-thumb-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fstub-row-copy {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.fstub-row-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fstub-sizes {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.fstub-size {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 11px;
}

.fstub-size-label {
  color: var(--text-3);
}

.fstub-size-value {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
  font-weight: 600;
}

/* The copy the verdict is actually about - so the row explains itself. */
.fstub-size.is-bad {
  background: color-mix(in srgb, var(--red) 12%, transparent);
  border-color: color-mix(in srgb, var(--red) 30%, transparent);
}

.fstub-size.is-bad .fstub-size-label,
.fstub-size.is-bad .fstub-size-value {
  color: var(--red);
}

.fstub-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

.fstub-badge--ok {
  background: color-mix(in srgb, var(--green) 14%, transparent);
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 28%, transparent);
}

.fstub-badge--warn {
  background: color-mix(in srgb, var(--ember) 15%, transparent);
  color: var(--ember);
  border-color: color-mix(in srgb, var(--ember) 30%, transparent);
}

.fstub-badge--bad {
  background: color-mix(in srgb, var(--red) 13%, transparent);
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 30%, transparent);
}

/* Unrecoverable: not an error to retry, a verdict to act on. */
.fstub-badge--dead {
  background: var(--surface-2);
  color: var(--text-3);
  border-color: var(--border);
  max-width: 190px;
  white-space: normal;
}

.fstub-empty,
.fstub-scanning {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 34px 16px;
  color: var(--text-3);
  font-size: 13.5px;
  text-align: center;
}

.fstub-scanning {
  flex-direction: row;
  gap: 8px;
}

.fstub-empty-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--green) 13%, transparent);
  color: var(--green);
}

.fstub-empty-text {
  color: var(--text-2);
  font-weight: 500;
}

.fstub-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 16px;
  border-top: 1px solid var(--divider);
  background: var(--surface-2);
}

@media (max-width: 560px) {
  .fstub-row {
    flex-wrap: wrap;
  }

  .fstub-badge {
    margin-inline-start: 84px;
  }

  .fstub-title-sub {
    display: none;
  }
}

/* Template assignments: movie span vs per-clip blocks. */
.track-row.templates {
  min-height: 36px;
  height: 36px;
  margin-bottom: 1px;
}
.track-row.templates .track-label,
.track-row.templates .track-content {
  min-height: 36px;
  height: 36px;
}
.track-row.templates.is-split,
.track-row.templates.is-split .track-label,
.track-row.templates.is-split .track-content {
  min-height: 52px;
  height: 52px;
}
.track-content.templates { position: relative; }
.tl-template-block {
  position: absolute;
  top: 4px;
  height: 28px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  padding: 0 6px;
  border-radius: var(--r-xs);
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-2));
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  overflow: hidden;
  cursor: pointer;
}
.tl-template-block span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tl-template-block.is-movie {
  background: color-mix(in srgb, var(--accent) 30%, var(--surface-2));
}
.tl-template-block.is-layer { border-style: dashed; }
.tl-template-block.is-selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.tl-template-block:hover { z-index: 2; }
.track-row.templates.is-split .tl-template-block.is-movie { top: 3px; height: 14px; }
.track-row.templates.is-split .tl-template-block.is-clip { top: 20px; height: 28px; }
