/* ===========================================================================
   CapCut-style reel timeline editor
   Uses the palette vars from style.css (--bg, --surface, --accent, etc.)

   Design language (2026-08-13 pro pass): warm-dark surfaces, amber accent,
   track colours as tinted-glass blocks with a colour-coded edge bar (never
   loud solid fills), one shared focus ring, quiet chrome around a big stage.
   =========================================================================== */

/* The same faces libass burns into the export, so preview text matches it.
   font-display is BLOCK, not swap. With swap the browser paints the overlay in
   whatever fallback it has until the file arrives, and a fallback has different
   metrics: a caption comes out wider, wraps onto a second line, and reads as
   "the editor makes captions bigger than the video". Blocking shows nothing for
   a moment instead of showing the wrong thing, which is the right trade for a
   preview whose whole job is to be accurate. The browser still falls back after
   its block period if a file genuinely fails to load. */
@font-face {
  font-family: 'ReelBold';
  src: url('/api/fonts/BebasNeue-Regular.ttf') format('truetype');
  font-display: block;
}
@font-face {
  font-family: 'ReelAnton';
  src: url('/api/fonts/Anton-Regular.ttf') format('truetype');
  font-display: block;
}
@font-face {
  font-family: 'ReelArchivo';
  src: url('/api/fonts/ArchivoBlack-Regular.ttf') format('truetype');
  font-display: block;
}
/* Added font families (P2 #7). Reel-prefixed so a same-named system font can't
   shadow the bundled file — preview uses the EXACT face the export burns. */
@font-face { font-family: 'ReelPoppins';   src: url('/api/fonts/Poppins-Bold.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'ReelBarlow';    src: url('/api/fonts/Barlow-Bold.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'ReelKanit';     src: url('/api/fonts/Kanit-Bold.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'ReelRighteous'; src: url('/api/fonts/Righteous-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'ReelFjalla';    src: url('/api/fonts/FjallaOne-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'ReelAlfaSlab';  src: url('/api/fonts/AlfaSlabOne-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'ReelBangers';   src: url('/api/fonts/Bangers-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'ReelPacifico';  src: url('/api/fonts/Pacifico-Regular.ttf') format('truetype'); font-display: block; }
@font-face { font-family: 'ReelLobster';   src: url('/api/fonts/Lobster-Regular.ttf') format('truetype'); font-display: block; }

.ed-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  /* Editor-local tokens: preview tiles + card fills share one warm ramp. */
  --ed-tile: linear-gradient(160deg, #1D1A15 0%, #121013 100%);
  --ed-card: #121218;
  --ed-focus-ring: 0 0 0 2px var(--accent);
  --ed-ruler-h: 26px;
  touch-action: manipulation;   /* no double-tap zoom on the video; scrolling stays native */
}

/* --- Top bar --- */
.ed-topbar {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px;
  background: rgba(16,16,21,0.82);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid var(--glass-border);
  flex: 0 0 auto;
}
.ed-title { font-family: var(--font-display); font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.ed-save-status {
  font-size: 11px; color: var(--muted); margin-left: 4px; min-width: 60px;
  font-variant-numeric: tabular-nums;
}
.ed-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.ed-add {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface2); color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 7px 12px; cursor: pointer; font-size: 12px; font-weight: 500;
  transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out),
              color var(--dur) var(--ease-out);
}
.ed-add:hover { border-color: var(--border-strong); background: var(--surface3); color: var(--text); }

/* Inline SVG icons — sized in em so they track the button/label font-size. */
.ed-ic { display: inline-block; width: 1em; height: 1em; flex: 0 0 auto; vertical-align: -0.15em; }
.ed-topbar #ed-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border-color: transparent;
}
.ed-topbar #ed-back:hover { background: var(--surface2); border-color: var(--border); }
.ed-track-label .ed-ic { color: var(--muted); }
.ed-export-btn {
  background: var(--grad-molten, linear-gradient(135deg,#FFCB5C,#FFB020));
  color: var(--on-accent); border: none;
  border-radius: var(--r-pill); padding: 8px 20px; cursor: pointer;
  font-weight: 700; font-size: 13px; letter-spacing: .01em;
  box-shadow: 0 2px 14px rgba(255,176,32,.25);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur) var(--ease-out),
              filter var(--dur) var(--ease-out);
}
.ed-export-btn:hover { filter: brightness(1.06); box-shadow: var(--glow-accent); transform: translateY(-1px); }
.ed-export-btn:disabled { opacity: .5; cursor: default; }

/* "Apply to all clips" (clip editor only). Its OWN class so the topbar's
   ".ed-add:not(.ed-tool){display:none}" rule can't hide it. Hidden by default;
   shown via .is-on (set in clip mode). Amber outline to read as a key action
   next to the solid Export button. */
.ed-applyall-btn {
  display: none; align-items: center; justify-content: center; gap: 6px;
  background: transparent; color: var(--accent, #FFB020);
  border: 1px solid var(--accent, #FFB020); border-radius: var(--r-pill);
  padding: 8px 16px; cursor: pointer; font-size: 12px; font-weight: 700;
  white-space: nowrap;
  transition: background var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.ed-applyall-btn.is-on { display: inline-flex; }
.ed-applyall-btn:hover { background: rgba(255,176,32,.14); transform: translateY(-1px); }
.ed-applyall-btn.ed-exporting { opacity: .6; cursor: default; }

/* "Download project" (both editor modes). Its OWN class for the same reason
   as Apply to all: the topbar hides .ed-add:not(.ed-tool). Outline style so
   the solid Export stays the primary action. */
.ed-project-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text, #EDE6DA);
  border: 1px solid var(--border, rgba(255,255,255,.14)); border-radius: var(--r-pill);
  padding: 8px 14px; cursor: pointer; font-size: 12px; font-weight: 600;
  white-space: nowrap;
  transition: background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.ed-project-btn:hover { background: var(--surface2); border-color: var(--accent, #FFB020); transform: translateY(-1px); }
.ed-project-btn:disabled { opacity: .5; cursor: default; }

/* --- Main area: stage + inspector --- */
.ed-main { flex: 1 1 auto; display: flex; min-height: 0; }

.ed-stage-wrap {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 18px 16px 14px; gap: 14px;
  /* A faint amber ambience keeps the big empty area from reading dead-flat. */
  background:
    radial-gradient(640px 420px at 50% 38%, rgba(255,176,32,.045), transparent 70%),
    radial-gradient(900px 600px at 50% 110%, rgba(255,255,255,.02), transparent 60%);
}
.ed-stage {
  position: relative;
  height: 100%;
  max-height: calc(100vh - 374px);
  aspect-ratio: 9 / 16;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.07);
  box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 4px 16px rgba(0,0,0,.4);
}
.ed-zoomwrap {
  position: absolute; inset: 0;
  transform-origin: center center;
  will-change: transform;
}
/* Ease the zoom punch-in during playback so preview matches the exported
   `zoompan` ramp. Only while playing — a permanent transition would make
   scrubbing lag as the frame catches up to the seeked scale. */
.ed-zoomwrap.is-playing {
  transition: transform 220ms cubic-bezier(.22,.61,.36,1);
}
.ed-bg-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; filter: blur(22px) brightness(.85);
  transform: scale(1.12); pointer-events: none;
}
.ed-fg-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain;
}
/* The double buffer's standby video: parked on the next clip's first frame,
   invisible until the cut swaps it in. Kept in layout so the frame is decoded. */
.ed-fg-video.ed-standby { opacity: 0; pointer-events: none; }
/* Crop-to-fill framing: the foreground video FILLS the frame (centre-cropped)
   and the blurred backdrop is hidden — mirrors the export's crop mode so the
   editor preview matches the rendered reel. Default is crop (see edFrameMode). */
.ed-frame-crop .ed-fg-video { object-fit: cover; }
.ed-frame-crop .ed-bg-video { display: none; }
.ed-overlay { position: absolute; inset: 0; pointer-events: none; }

/* Overlay elements — positioned by normalized center via inline style. */
.ed-el {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center; white-space: nowrap;
  /* Per kind below: the render stacks lines at 1.23 for titles and subtitles
     (reel_pipeline) and 1.2 for free text and the CTA (reel_overlays). 1.05
     for everything made multi-line overlays sit tighter here than in the
     finished video. */
  line-height: 1.2;
  pointer-events: auto; cursor: grab;
  user-select: none; -webkit-touch-callout: none;
}
.ed-el * { -webkit-touch-callout: none; }
.ed-el.ed-caption { font-family: 'ReelBold', 'Bebas Neue', sans-serif; letter-spacing: 0; }
.ed-el.ed-title, .ed-el.ed-subtitle { line-height: 1.23; }
.ed-el.ed-title, .ed-el.ed-subtitle, .ed-el.ed-cta, .ed-el.ed-text {
  font-family: 'ReelBold', 'Bebas Neue', sans-serif;
  text-transform: uppercase; letter-spacing: 0;   /* ASS Spacing=0; Pillow has no tracking */
  /* Stroke UNDER fill (like the export's Pillow/drawtext outline) so a thick
     outline doesn't paint over white text and make it look dark. */
  paint-order: stroke fill;
}
.ed-el .ed-text-box {
  display: inline-block; padding: 4px 12px;
  /* No blanket shadow. The export draws one only where the preset asks (ASS
     Shadow, which is 0 on 27 of the 31 presets) and never on a Pillow-drawn
     title, so a soft shadow on everything made every overlay read murkier than
     it burns. Captions get their real per-preset shadow in edBuildOverlay. */
}
/* Sharp corners: the export's ASS/drawtext readability boxes are square. */
.ed-el.boxed .ed-text-box { background: rgba(0,0,0,.55); border-radius: 0; }
.ed-el.ed-sticker { font-size: 1em; }
/* Meme stingers — mirror reel_overlays' styled drawtext (Phase 2 WYSIWYG). */
.ed-el.ed-meme {
  font-family: 'ReelBold', 'Anton', 'Bebas Neue', sans-serif;
  text-transform: uppercase; letter-spacing: 2px; font-weight: 900;
}
.ed-el.ed-meme-wasted .ed-text-box {   /* GTA WASTED: wide grey caps on a dark box */
  color: #c8c8c8; background: rgba(0,0,0,.45); border-radius: 4px;
  padding: 10px 26px; text-shadow: 0 0 3px #101010, 0 2px 8px rgba(0,0,0,.9);
}
.ed-el.ed-meme-reaction .ed-text-box {  /* reaction text: white caps, heavy outline */
  color: #fff;
  -webkit-text-stroke: 3px #000;
  text-shadow: 0 0 6px rgba(0,0,0,.9), 0 3px 8px rgba(0,0,0,.85);
}
/* Colour-emoji stack so preview emoji match the export's colour PNGs. */
.ed-emoji-glyph {
  font-family: 'Apple Color Emoji', 'Noto Color Emoji', 'Segoe UI Emoji',
               'Twemoji Mozilla', sans-serif;
  text-shadow: 0 2px 8px rgba(0,0,0,.55);
}
/* CTA trailing 👇✅ — colour-emoji sat just under the CTA text (out of flow so
   it doesn't move the text anchor), mirroring _cta_emoji_overlay in the export. */
.ed-cta-emoji {
  position: absolute; left: 50%; top: 100%;
  transform: translate(-50%, 18%);
  font-size: 1.5em; line-height: 1; letter-spacing: 0;
  text-transform: none; white-space: nowrap; pointer-events: none;
}
.ed-el.ed-image { white-space: normal; }
.ed-el.ed-image img {
  display: block; width: 100%; height: auto;
  pointer-events: none; user-select: none;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.4));
}
.ed-el.ed-video { white-space: normal; overflow: hidden; border-radius: 6px; }
.ed-el.ed-video video {
  display: block; width: 100%; height: 100%; object-fit: contain;
  pointer-events: none; user-select: none; background: #000;
}
.ed-el.ed-video.fill { border-radius: 0; }
.ed-el.ed-video.fill video { object-fit: cover; }
.ed-el .word-pop { color: var(--warn); }
/* Caption words: keep the outline stroke behind the fill so a heavy stroke
   never eats legibility (approximates the export's ASS outline). */
.ed-el.ed-caption { paint-order: stroke fill; }
.ed-el.ed-caption .ed-cap-w { display: inline-block; }
.ed-caption[data-anim="pop"] .is-active { animation: edCapPop 150ms var(--ease-out); }
.ed-caption[data-anim="highlight"] .is-active,
.ed-caption[data-anim="karaoke"] .is-active { animation: edCapLite 170ms var(--ease-out); }
.ed-el.ed-caption .ed-text-box.ed-cap-fade { animation: edCapFade 260ms var(--ease-out); }
/* scaleY, not scale: the export punches the word on the vertical axis only
   so the line cannot slide sideways (captioner._viral_phrase_lines). The
   preview matches it. */
@keyframes edCapPop  { 0% { transform: scaleY(.6); opacity: .3; } 60% { transform: scaleY(1.13); } 100% { transform: scaleY(1); opacity: 1; } }
@keyframes edCapLite { 0% { transform: scale(.9); filter: brightness(1.7); } 100% { transform: scale(1); filter: none; } }
@keyframes edCapFade { from { opacity: 0; transform: translateY(9%); } to { opacity: 1; transform: none; } }
.ed-el.selected { outline: 2px solid var(--accent); outline-offset: 3px; }
.ed-el:focus-visible, .ed-block:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ed-el:focus:not(:focus-visible), .ed-block:focus:not(:focus-visible) { outline: none; }

.ed-canvas-ui { position: absolute; inset: 0; pointer-events: none; z-index: 4; }

/* Where a zoom punch lands. Sits in the UI layer rather than inside the zoom
   wrapper, so it stays put while the frame it is aiming scales underneath. */
.ed-zoomaim {
  position: absolute; width: 0; height: 0; pointer-events: auto;
  cursor: grab; touch-action: none; z-index: 2;
}
.ed-zoomaim:active { cursor: grabbing; }
.ed-zoomaim .ed-za-ring,
.ed-zoomaim .ed-za-dot {
  position: absolute; left: 50%; top: 50%; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none;
}
/* Sized for a finger on a phone; the ring is the target, the dot is the point. */
.ed-zoomaim .ed-za-ring {
  width: 46px; height: 46px;
  border: 2px solid var(--accent, #FFB020);
  box-shadow: 0 0 0 1px rgba(0,0,0,.55), inset 0 0 0 1px rgba(0,0,0,.45);
}
.ed-zoomaim .ed-za-dot {
  width: 7px; height: 7px; background: var(--accent, #FFB020);
  box-shadow: 0 0 0 1.5px rgba(0,0,0,.6);
}
.ed-zoomaim:hover .ed-za-ring { background: rgba(255,176,32,.14); }
@media (prefers-reduced-motion: no-preference) {
  .ed-zoomaim .ed-za-ring { transition: background 140ms ease; }
}

/* Selection box for canvas drag/resize (title/subtitle/cta/text). */
.ed-selbox { position: absolute; outline: 1.5px solid var(--accent); pointer-events: none; }
.ed-sb-move { position: absolute; inset: 0; pointer-events: auto; cursor: move; }
.ed-sb-h {
  position: absolute; width: 12px; height: 12px; background: #fff;
  border: 1.5px solid var(--accent); border-radius: 50%;
  pointer-events: auto; box-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.ed-sb-h::before, .ed-sb-w::before { content: ''; position: absolute; inset: -14px; }  /* thumb-sized hit area */
.ed-sb-h.nw { left: -6px; top: -6px; cursor: nwse-resize; }
.ed-sb-h.ne { right: -6px; top: -6px; cursor: nesw-resize; }
.ed-sb-h.se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.ed-sb-h.sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
/* Width handles (#4): a rounded bar mid-edge; only shown for text blocks. */
.ed-sb-w {
  position: absolute; top: 50%; width: 8px; height: 26px; margin-top: -13px;
  background: #fff; border: 1.5px solid var(--accent); border-radius: 4px;
  pointer-events: auto; box-shadow: 0 1px 3px rgba(0,0,0,.5); cursor: ew-resize;
  display: none; touch-action: none;
}
.ed-selbox.ed-sb-has-width .ed-sb-w { display: block; }
.ed-sb-w.w { left: -5px; }
.ed-sb-w.e { right: -5px; }

/* --- Transport --- */
/* Two rows, like the results player: scrub across the top, controls below.
   It did not collapse the way .rv-transport did, but the cause is the same and
   the result was cramped: play 44, the clock 90, four 36px toggles, Crop 55 and
   six gaps leave about 143px of a 560px bar for the scrubber, which is where
   every frame of a clip has to be found. Two of those buttons are added by
   editor.js, so the row is fuller than the markup reads. */
.ed-transport {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  row-gap: 8px; width: 100%;
  max-width: 560px;
}
.ed-transport .ed-scrub { flex: 1 1 100%; order: -1; }
.ed-play {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--grad-molten, linear-gradient(135deg,#FFCB5C,#FFB020));
  color: var(--on-accent); border: none;
  cursor: pointer; flex: 0 0 auto;
  box-shadow: 0 4px 18px rgba(255,176,32,.3);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.ed-play:hover { transform: scale(1.05); box-shadow: var(--glow-accent); }
.ed-play:active { transform: scale(.97); }
.ed-play .ed-ic { width: 17px; height: 17px; vertical-align: 0; }
/* Scrub bar — a slim custom track with an amber-ringed thumb. */
.ed-scrub {
  flex: 1 1 auto; -webkit-appearance: none; appearance: none;
  height: 24px; background: transparent; cursor: pointer;   /* tall hit area, slim painted track */
}
.ed-scrub:focus-visible { outline: none; box-shadow: var(--ed-focus-ring); border-radius: 12px; }
.ed-scrub::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: var(--surface3); }
.ed-scrub::-moz-range-track { height: 5px; border-radius: 3px; background: var(--surface3); }
.ed-scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; box-sizing: border-box;
  width: 14px; height: 14px; border-radius: 50%; margin-top: -4.5px;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 1px 5px rgba(0,0,0,.5);
  transition: transform var(--dur-fast) var(--ease-out);
}
.ed-scrub::-webkit-slider-thumb:hover { transform: scale(1.15); }
.ed-scrub::-moz-range-thumb {
  box-sizing: border-box; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 1px 5px rgba(0,0,0,.5);
}
.ed-time {
  font-family: var(--font-mono); font-size: 11px;
  font-variant-numeric: tabular-nums; color: var(--text-2);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 4px 10px;
  min-width: 90px; text-align: center; flex: 0 0 auto;
}
.ed-mute {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto;
  background: var(--surface2); color: var(--muted);
  border: 1px solid var(--border); cursor: pointer;
  transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.ed-mute:hover { color: var(--text); border-color: var(--border-strong); }
.ed-mute .ed-ic { width: 16px; height: 16px; }
.ed-mute.ed-muted { color: var(--danger); border-color: rgba(251,93,93,.4); }

/* Framing toggle is a text pill (Crop / Blur), not an icon. */
.ed-frame {
  height: 36px; padding: 0 12px; border-radius: 18px; flex: 0 0 auto;
  background: var(--surface2); color: var(--muted);
  border: 1px solid var(--border); cursor: pointer;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.ed-frame:hover { color: var(--text); border-color: var(--border-strong); }
.ed-frame.ed-on { color: var(--accent); border-color: rgba(255,176,32,.5); }

/* Full-screen preview button — same round style as the other transport chips. */
.ed-fs {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto;
  background: var(--surface2); color: var(--muted);
  border: 1px solid var(--border); cursor: pointer;
  transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.ed-fs:hover { color: var(--text); border-color: var(--border-strong); }

/* Full-screen: grow the wrapper to fill the screen on black and let the stage
   stay a centred 9:16 box (as tall as the viewport, minus room for the transport
   bar). Because every overlay is positioned relative to .ed-stage's pixel size,
   scaling the stage uniformly keeps the preview WYSIWYG — just bigger. The
   transport rides inside the wrapper, so play/scrub/mute all work full-screen. */
.ed-stage-wrap:fullscreen, .ed-stage-wrap:-webkit-full-screen {
  width: 100vw; height: 100vh; background: #000;
  padding: 12px; gap: 10px; justify-content: center;
}
.ed-stage-wrap:fullscreen .ed-stage,
.ed-stage-wrap:-webkit-full-screen .ed-stage {
  height: calc(100vh - 96px); max-height: calc(100vh - 96px);
}

/* --- Inspector --- */
.ed-inspector {
  flex: 0 0 300px; padding: 16px;
  background: var(--surface); border-left: 1px solid var(--border);
  overflow-y: auto;
}
.ed-insp-empty { color: var(--muted); font-size: 13px; margin-top: 20px; text-align: center; line-height: 1.5; }
.ed-insp-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted);
  margin-bottom: 14px; padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}
.ed-insp-note { color: var(--muted); font-size: 12px; line-height: 1.5; margin-bottom: 12px; }
.ed-insp-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-2); margin-bottom: 12px; cursor: pointer;
}
.ed-insp-check:hover { color: var(--text); }
.ed-insp-check input { width: auto; accent-color: var(--accent); }
.ed-val { color: var(--accent); font-variant-numeric: tabular-nums; }
.ed-insp-field input[type="color"] {
  height: 36px; padding: 3px; cursor: pointer; border-radius: var(--r-sm);
}
.ed-insp-field input[type="range"] { accent-color: var(--accent); padding: 0; border: none; background: transparent; }
.ed-insp-field { margin-bottom: 13px; }

/* Title/subtitle style presets (P1 #7): a scrollable grid of swatch chips. */
.ed-tp-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
  max-height: 168px; overflow-y: auto; padding: 2px;
}
.ed-tp-chip {
  padding: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface2); cursor: pointer; overflow: hidden;
  transition: border-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
.ed-tp-chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.ed-tp-swatch {
  display: flex; align-items: center; justify-content: center; gap: 2px;
  height: 34px; font-size: 15px; font-weight: 800; line-height: 1;
}
.ed-tp-swatch i { font-size: 10px; font-style: normal; font-weight: 700; }

.ed-insp-field label {
  display: block; font-size: 10.5px; font-weight: 600;
  letter-spacing: .03em; color: var(--muted); margin-bottom: 5px;
}
.ed-insp-field input, .ed-insp-field select, .ed-insp-field textarea {
  width: 100%; background: var(--ed-card); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 10px;
  font: inherit; font-size: 12.5px;
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.ed-insp-field input:focus-visible, .ed-insp-field select:focus-visible, .ed-insp-field textarea:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: var(--ed-focus-ring);
}
.ed-insp-row { display: flex; gap: 8px; }
/* Two style fields side-by-side (outline colour+width, box colour+opacity). */
.ed-insp-row > .ed-insp-field { flex: 1; min-width: 0; margin-bottom: 0; }
.ed-insp-delete {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 8px; padding: 9px;
  background: rgba(251,93,93,.06); color: var(--danger);
  border: 1px solid rgba(251,93,93,.35); border-radius: var(--r-sm); cursor: pointer;
  font-size: 12px; font-weight: 600;
  transition: background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.ed-insp-delete:hover { background: rgba(251,93,93,.13); border-color: var(--danger); }

/* --- Timeline --- */
.ed-timeline {
  flex: 0 0 auto;
  background: var(--surface); border-top: 1px solid var(--border);
  overflow: hidden; position: relative;
}
.ed-tl-zoom {
  position: absolute; top: 2px; right: 10px; z-index: 6;
  display: flex; gap: 2px; padding: 2px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--r-pill);
}
.ed-tl-zoom button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 18px; line-height: 1; padding: 0;
  background: transparent; color: var(--muted);
  border: none; border-radius: var(--r-pill); cursor: pointer; font-size: 13px;
  transition: color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
.ed-tl-zoom .ed-ic { width: 12px; height: 12px; vertical-align: 0; }
.ed-tl-zoom button:hover { color: var(--text); background: var(--surface3); }
.ed-track-video {
  background-repeat: no-repeat; background-position: left center;
  background-color: #121016; opacity: .92;
}
/* One block per cut on the video lane. Below the trim handles (which are
   appended after and carry a higher z-index) so dragging still works. */
.ed-vseg {
  position: absolute; top: 3px; bottom: 3px; z-index: 1;
  box-sizing: border-box; overflow: hidden;
  border-left: 2px solid var(--accent, #FFB020);
  border-radius: 3px;
  background: linear-gradient(90deg, rgba(255,176,32,.22), rgba(255,176,32,.06) 60%, transparent);
}
.ed-vseg.alt { background: linear-gradient(90deg, rgba(255,203,92,.26), rgba(255,203,92,.08) 60%, transparent); }
.ed-vseg-lbl {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
  font-size: 10px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
  color: var(--text, #EDE6DA); text-shadow: 0 1px 2px rgba(0,0,0,.8);
  pointer-events: none;
}

/* Editable cuts: one block per clip with edge handles. Below the lane's
   own trim handles (z 4) on legacy reels; on editable reels those are not built. */
.ed-vseg.ed-clip { cursor: pointer; overflow: visible; transition: box-shadow var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); }
.ed-vseg.ed-clip:hover { border-left-color: var(--accent2, #FFCB5C); box-shadow: inset 0 0 0 1px rgba(255,176,32,.35); }
.ed-vseg.ed-clip.selected {
  box-shadow: inset 0 0 0 1.5px var(--accent, #FFB020), 0 3px 12px rgba(0,0,0,.45);
  background: linear-gradient(90deg, rgba(255,176,32,.34), rgba(255,176,32,.14) 60%, rgba(255,176,32,.06));
  z-index: 3;
}
.ed-vseg.ed-clip.ed-drag-active { opacity: .92; z-index: 4; }
.ed-vseg-thumb { position: absolute; top: 0; bottom: 0; background-repeat: no-repeat; opacity: .55; pointer-events: none; border-radius: 3px; overflow: hidden; }
.ed-vseg-part { position: absolute; top: 2px; bottom: 2px; width: 0; border-left: 1px dashed rgba(255,203,92,.6); pointer-events: none; }
.ed-vseg-h { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; z-index: 2; touch-action: none; }
.ed-vseg-h.l { left: 0; } .ed-vseg-h.r { right: 0; }
.ed-vseg-h::after {
  content: ''; position: absolute; top: 50%; transform: translateY(-50%);
  width: 2px; height: 12px; border-radius: 2px; background: rgba(255,255,255,.8);
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-out);
}
.ed-vseg-h.l::after { left: 3px; } .ed-vseg-h.r::after { right: 3px; }
.ed-vseg.ed-clip:hover .ed-vseg-h::after, .ed-vseg.ed-clip.selected .ed-vseg-h::after { opacity: .9; }
.ed-vseg-h.at-limit::after { background: #ff8f8f; opacity: 1; }
.ed-vseg-tip {
  position: absolute; top: -22px; transform: translateX(-50%); z-index: 6; display: none;
  padding: 1px 8px; border-radius: 6px; font-size: 11px; font-weight: 700;
  color: #12100a; background: var(--accent, #FFB020); white-space: nowrap; pointer-events: none;
}
.ed-combine-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; color: var(--text, #EDE6DA);
  border: 1px solid var(--border, rgba(255,255,255,.14)); border-radius: var(--r-pill);
  padding: 8px 14px; cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap;
  transition: background var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.ed-combine-btn:hover:not(:disabled) { background: var(--surface2); border-color: var(--accent, #FFB020); }
.ed-combine-btn:disabled { opacity: .45; cursor: not-allowed; }
.ed-insp-btn {
  background: transparent; color: var(--text, #EDE6DA);
  border: 1px solid var(--border, rgba(255,255,255,.14)); border-radius: var(--r-pill);
  padding: 7px 12px; cursor: pointer; font-size: 12px; font-weight: 600;
}
.ed-insp-btn:disabled { opacity: .45; cursor: not-allowed; }

/* Fit all lanes (Beats, Video, Captions, Text, Clips, Stickers, Zoom, Audio);
   scroll the lanes vertically only when the viewport is too short to show them. */
.ed-tl-head {
  display: flex; align-items: flex-start;
  max-height: min(340px, calc(100vh - 340px));
  overflow-y: auto; overflow-x: hidden;
}
.ed-track-labels {
  flex: 0 0 120px; border-right: 1px solid var(--border);
  background: var(--surface);
}
/* Frozen top-left corner, kept aligned with the pinned ruler. The label
   column has no overflow, so CSS `sticky` pins to the .ed-tl-head scrollport. */
.ed-track-labels::before {
  content: ''; display: block; position: sticky; top: 0; z-index: 3;
  height: var(--ed-ruler-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.ed-track-label {
  height: 34px; display: flex; align-items: center; gap: 7px;
  padding: 0 12px; font-size: 11px; font-weight: 500;
  letter-spacing: .02em; color: var(--muted);
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.ed-track-label .ed-ic { width: 13px; height: 13px; }
.ed-tl-scroll { flex: 1 1 auto; position: relative; overflow-x: auto; overflow-y: hidden; }
.ed-ruler {
  position: relative; height: var(--ed-ruler-h); z-index: 4; touch-action: none;
  background: var(--surface); will-change: transform;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 9px; color: var(--faint, #62626E);
}
.ed-ruler .tick {
  position: absolute; top: 0; height: var(--ed-ruler-h);
  border-left: 1px solid rgba(255,255,255,.06);
  padding-left: 4px; line-height: calc(var(--ed-ruler-h) - 2px);
}
.ed-tracks { position: relative; }
.ed-track-wave { background: rgba(255,255,255,.015); overflow: hidden; }
.ed-wave-canvas { display: block; height: 34px; }
/* Snap guide + right-click context menu (Phase 4) */
.ed-snap-guide {
  position: absolute; top: 0; height: 100%; width: 1px;
  background: var(--accent); box-shadow: 0 0 4px var(--accent);
  pointer-events: none; z-index: 5;
}
.ed-ctxmenu {
  position: fixed; z-index: 350; min-width: 190px;   /* above modals (340), below toasts (400) */
  background: rgba(26,26,32,.94);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 4px; box-shadow: 0 12px 38px rgba(0,0,0,.55);
}
.ed-ctx-item {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  background: transparent; border: none; color: var(--text);
  border-radius: 6px; cursor: pointer; font-size: 12.5px;
}
.ed-ctx-item:hover { background: rgba(255,255,255,.08); }
.ed-ctx-item.danger { color: #ff8f8f; }
.ed-ctx-item.danger:hover { background: rgba(255,90,90,.14); }
.ed-track {
  position: relative; height: 34px;
  border-bottom: 1px solid rgba(255,255,255,.03);
}
/* Blocks: tinted glass with a colour-coded edge bar — the track colour reads
   as an accent, not a paint bucket. `--blk` is set by the per-track class. */
.ed-block {
  position: absolute; top: 4px; height: 26px; box-sizing: border-box;
  border-radius: 6px; font-size: 10.5px; font-weight: 500; color: var(--text-2);
  padding: 0 7px 0 10px; display: flex; align-items: center;
  overflow: hidden; white-space: nowrap; cursor: grab;
  background: color-mix(in srgb, var(--blk, #888) 13%, #141419);
  border: 1px solid color-mix(in srgb, var(--blk, #888) 30%, transparent);
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ed-block::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--blk, #888); opacity: .9;
}
.ed-block:hover {
  border-color: color-mix(in srgb, var(--blk, #888) 60%, transparent);
  color: var(--text);
}
.ed-block.selected {
  border-color: var(--accent); color: var(--text);
  box-shadow: 0 0 0 1px var(--accent), 0 3px 12px rgba(0,0,0,.45);
  z-index: 3;
}
.ed-block-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.ed-block .ed-trim { position: absolute; top: 0; width: 7px; height: 100%; cursor: ew-resize; z-index: 2; }
.ed-block .ed-trim.l { left: 0; } .ed-block .ed-trim.r { right: 0; }
/* Trim grips appear on hover/selection so resting blocks stay clean. */
.ed-block .ed-trim::after {
  content: ''; position: absolute; top: 50%; transform: translateY(-50%);
  width: 2px; height: 12px; border-radius: 2px;
  background: rgba(255,255,255,.75); opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.ed-block .ed-trim.l::after { left: 4px; }
.ed-block .ed-trim.r::after { right: 4px; }
.ed-block:hover .ed-trim::after, .ed-block.selected .ed-trim::after { opacity: .8; }
.ed-block-captions { --blk: var(--track-captions); }
/* Caption cues sit shoulder-to-shoulder — tone them down so the lane reads as
   one calm track instead of a chain of bright pills. */
.ed-block-captions {
  background: color-mix(in srgb, var(--track-captions) 8%, #141419);
  border-color: color-mix(in srgb, var(--track-captions) 20%, transparent);
}
.ed-block-text     { --blk: var(--track-text); }
.ed-block-stickers { --blk: var(--track-stickers); }
.ed-block-zoom     { --blk: var(--track-zoom); }
.ed-block-audio    { --blk: var(--track-audio); }
.ed-block-video    { --blk: var(--track-video); }

.ed-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--accent); pointer-events: none; z-index: 5;
  box-shadow: 0 0 6px rgba(255,176,32,.5);
}
.ed-playhead::before {
  content: ''; position: absolute; top: -1px; left: -4px;
  width: 10px; height: 10px; border-radius: 2px;
  background: var(--accent); transform: rotate(45deg);
  transform-origin: center; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}

/* Phase 6 UX polish additions */
.ed-tool { padding: 7px 9px; background: transparent; border-color: transparent; }
.ed-tool:hover { background: var(--surface2); border-color: var(--border); }
.ed-export-btn.ed-exporting {
  background-image: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent));
  background-size: 200% 100%;
  animation: rc-shimmer 1.1s linear infinite;
}
body.ed-dragging { cursor: grabbing; }
body.ed-dragging, body.ed-dragging * { user-select: none; }
.ed-block.ed-drag-active {
  opacity: .92; border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 20px rgba(0,0,0,.55); z-index: 4;
}
.ed-el:active { cursor: grabbing; }

/* Pointer-drag targets must not let touch scroll/zoom hijack the gesture. */
.ed-el, .ed-block, .ed-block .ed-trim, .ed-sb-move, .ed-sb-h, .ed-vseg.ed-clip, .ed-vseg-h { touch-action: none; }

/* Mobile sheet chrome (grab handle + Done) — injected into .ed-panels by JS;
   only shown on the phone bottom-sheet layout below. */
.ed-sheet-bar { display: none; }

/* ===========================================================================
   OpusClip-style 3-pane shell — transcript · preview · rail+panels
   =========================================================================== */
@keyframes edPanelIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }

/* --- Left: transcript --- */
.ed-transcript {
  flex: 0 0 312px; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
}
.ed-tr-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 15px 18px 11px; border-bottom: 1px solid var(--border);
}
.ed-tr-title { font-family: var(--font-display); font-weight: 600; font-size: 13px; }
.ed-tr-hint { font-size: 10.5px; color: var(--faint, #62626E); }
.ed-tr-body {
  flex: 1 1 auto; overflow-y: auto; padding: 10px 10px 40px;
  display: flex; flex-direction: column; gap: 2px;
}
/* Script line-cards — a RaveClip take, not a flat transcript paragraph. */
.ed-tr-line {
  display: flex; gap: 10px; padding: 8px 10px;
  border-radius: var(--r-sm); border-left: 2px solid transparent; cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.ed-tr-line:hover { background: var(--surface2); }
.ed-tr-line.active { background: var(--accent-softer); border-left-color: var(--accent); }
.ed-tr-time {
  flex: 0 0 auto; align-self: flex-start; margin-top: 2px;
  font-family: var(--font-mono); font-size: 9.5px; color: var(--muted);
  background: var(--surface2); border: 1px solid transparent;
  border-radius: var(--r-pill); padding: 2px 7px;
  cursor: pointer; font-variant-numeric: tabular-nums;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.ed-tr-time:hover { color: var(--accent); border-color: var(--accent); }
.ed-tr-line.active .ed-tr-time { color: var(--accent); }
.ed-tr-text { flex: 1 1 auto; min-width: 0; font-size: 13px; line-height: 1.6; color: var(--text-2); }
.ed-tr-word {
  border-radius: 4px; padding: 1px 2px; cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.ed-tr-word:hover { background: var(--accent-softer); color: var(--text); }
.ed-tr-word.active {
  background: var(--grad-molten); color: #17130A; font-weight: 600;
  box-shadow: 0 2px 10px rgba(255,176,32,.3);
}

/* --- Right: contextual panels + icon rail --- */
.ed-right { flex: 0 0 372px; display: flex; min-height: 0; min-width: 0; }
/* Tablet: 312 + 372px of side panes left a ~216px 9:16 stage at 900px wide.
   Drop the transcript pane and slim the right pane so the preview gets room. */
@media (min-width: 769px) and (max-width: 1100px) {
  .ed-transcript { display: none; }
  .ed-right { flex-basis: 320px; }
}
.ed-panels {
  flex: 1 1 auto; min-width: 0; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--border);
}
.ed-panels > .ed-panel, .ed-panels > #ed-inspector { display: none; }
/* The show-rule must ALSO name the id — `.is-active` alone (0,2,0) loses to
   `.ed-panels > #ed-inspector` (1,1,0) and the inspector stays display:none. */
.ed-panels > .is-active, .ed-panels > #ed-inspector.is-active {
  display: block; animation: edPanelIn var(--dur) var(--ease-out);
}
.ed-panel { padding: 16px; }
/* Inspector now lives inside .ed-panels rather than being its own column. */
#ed-inspector { flex: none; width: auto; border-left: none; overflow: visible; }
.ed-panel-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted); margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}

.ed-rail {
  flex: 0 0 72px; display: flex; flex-direction: column; gap: 3px;
  padding: 10px 6px; overflow-y: auto;
  background: var(--surface); border-left: 1px solid var(--border);
}
.ed-rail-btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border: none; border-radius: var(--r-sm);
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 9.5px; font-weight: 600; letter-spacing: .02em;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.ed-rail-btn .ed-ic { width: 19px; height: 19px; }
.ed-rail-btn:hover { color: var(--text); background: var(--surface2); }
.ed-rail-btn.active { color: var(--accent); background: var(--accent-softer); }
.ed-rail-btn.active::before {
  content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 2.5px;
  border-radius: 2px; background: var(--grad-molten);
}
.ed-rail-btn:active { transform: scale(.94); }

/* The add-tools now live in the right rail — hide the redundant top-bar copies
   (kept in the DOM so the rail can trigger their existing handlers). Undo/redo/
   reset (.ed-tool) and Export stay in the top bar. */
.ed-top-actions .ed-add:not(.ed-tool) { display: none; }

/* --- Caption preset gallery --- */
.ed-preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ed-preset {
  display: flex; flex-direction: column; gap: 7px; padding: 8px;
  background: var(--ed-card); border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; text-align: center;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.ed-preset:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--sh-md); }
.ed-preset.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 16px rgba(255,176,32,.18); }
.ed-preset-prev {
  display: grid; place-items: center; height: 58px; border-radius: var(--r-sm);
  background: var(--ed-tile); overflow: hidden;
}
.ed-preset-prev b { font-family: var(--font-display); font-size: 22px; letter-spacing: .5px; }
.ed-preset-name { font-size: 11px; font-weight: 600; color: var(--text-2); }
/* per-preset preview flavor */
.ed-prev-viral_pop_v2 .ed-preset-prev b { color: #FFDD00; -webkit-text-stroke: 1.5px #111; }
.ed-prev-white .ed-preset-prev b { color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.ed-prev-highlight .ed-preset-prev b { color: #111; background: #FFDD00; padding: 1px 8px; border-radius: 4px; }
.ed-prev-karaoke_box .ed-preset-prev b { color: #fff; background: #16a34a; padding: 1px 8px; border-radius: 4px; }
.ed-prev-big_bold .ed-preset-prev b { color: #fff; font-size: 26px; -webkit-text-stroke: 2px #000; }
.ed-prev-viral_pop .ed-preset-prev b { color: var(--accent); -webkit-text-stroke: 1.5px #111; }

/* Hover = a live motion preview so each style explains itself. */
.ed-lib-hint { font-size: 11px; color: var(--muted); margin: -4px 0 12px; }
.ed-preset-prev { position: relative; }
.ed-preset-prev b { display: inline-block; }
@keyframes edPop   { 0%,100% { transform: scale(1); } 45% { transform: scale(1.16); } }
@keyframes edPunch { 0% { transform: scale(.72); opacity: .35; } 60% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
@keyframes edFlash { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.55); } }
@keyframes edShine { to { transform: translateX(150%); } }
.ed-prev-viral_pop_v2:hover .ed-preset-prev b,
.ed-prev-viral_pop:hover .ed-preset-prev b { animation: edPop .6s var(--ease-out) infinite; }
.ed-prev-big_bold:hover .ed-preset-prev b { animation: edPunch .55s var(--ease-out) infinite; }
.ed-prev-highlight:hover .ed-preset-prev b { animation: edFlash .7s var(--ease-in-out) infinite; }
.ed-prev-white:hover .ed-preset-prev b { animation: edPop .8s var(--ease-out) infinite; }
/* karaoke: a shine sweeps across, evoking a word-by-word fill */
.ed-prev-karaoke_box .ed-preset-prev::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 42%, rgba(255,255,255,.42) 50%, transparent 58%);
  transform: translateX(-150%);
}
.ed-prev-karaoke_box:hover .ed-preset-prev::after { animation: edShine .8s var(--ease-out) infinite; }

/* Catalog-driven caption swatches — each renders a sample line in the preset's
   real look and animates on hover / while selected, driven by descriptor vars
   (--sw-color / --sw-emph) so nothing here re-hardcodes a preset's facts. */
.ed-sw { position: relative; }
.ed-sw-prev {
  display: grid; place-items: center; height: 58px; border-radius: var(--r-sm);
  background: var(--ed-tile); overflow: hidden;
  font-size: 18px; letter-spacing: .5px; line-height: 1.1; padding: 4px 6px;
  /* keep the outline stroke behind the fill so a heavy stroke doesn't swallow
     the coloured text (same reason as the canvas caption). */
  paint-order: stroke fill;
}
.ed-sw-prev.up { text-transform: uppercase; }
/* Wrap the sample line inside the tile — clipped words sold no preset. */
.ed-sw-prev { font-size: 15px; }
.ed-sw-line { display: inline-block; white-space: normal; max-width: 100%; }
.ed-sw-w { display: inline-block; }
.ed-sw-blurb {
  font-size: 10px; color: var(--muted); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
/* pop: words scale-pop, staggered by inline animation-delay */
.ed-sw-pop:hover .ed-sw-w, .ed-sw-pop.active .ed-sw-w {
  animation: swPop .9s var(--ease-out) infinite;
}
.ed-sw-hasemph.ed-sw-pop:hover .ed-sw-w:last-child,
.ed-sw-hasemph.ed-sw-pop.active .ed-sw-w:last-child { color: var(--sw-emph); }
/* highlight: each word lights to the accent one at a time */
.ed-sw-highlight:hover .ed-sw-w, .ed-sw-highlight.active .ed-sw-w {
  animation: swLite 1.5s var(--ease-in-out) infinite;
}
/* karaoke: the accent fills each word left to right, as the \kf sweep does */
.ed-sw-karaoke:hover .ed-sw-w, .ed-sw-karaoke.active .ed-sw-w {
  background-image: linear-gradient(90deg, var(--sw-emph) 0 50%, var(--sw-color) 50% 100%);
  background-size: 200% 100%; background-position: 100% 0;
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
  animation: swSweep 1.6s linear infinite;
}
/* fade: the whole sample line fades + rises in */
.ed-sw-fade:hover .ed-sw-line, .ed-sw-fade.active .ed-sw-line {
  animation: swFade 1.6s var(--ease-out) infinite;
}
/* none: the style is static, so the preview only breathes, it never pops */
.ed-sw-none:hover .ed-sw-w { animation: swStill 1.8s var(--ease-in-out) infinite; }
@keyframes swPop  { 0%,100% { transform: scale(1); } 40% { transform: scale(1.15); } }
@keyframes swFade { 0% { opacity: 0; transform: translateY(24%); } 32%,100% { opacity: 1; transform: none; } }
@keyframes swLite { 0%,100% { color: var(--sw-color); } 50% { color: var(--sw-emph); } }
@keyframes swStill { 0%,100% { opacity: 1; } 50% { opacity: .72; } }
@keyframes swSweep { 0%,15% { background-position: 100% 0; } 70%,100% { background-position: 0 0; } }

.ed-fontrow { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-fontchip {
  padding: 7px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: 15px;
  background: var(--ed-card); color: var(--text-2); border: 1px solid var(--border);
  transition: transform var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.ed-fontchip:hover { color: var(--text); border-color: var(--border-strong); transform: scale(1.07); }

/* --- Transitions library (hover any card to preview its motion) --- */
.ed-trans-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ed-trans {
  display: flex; flex-direction: column; gap: 7px; padding: 8px;
  background: var(--ed-card); border: 1px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; text-align: center;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.ed-trans:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--sh-md); }
.ed-trans.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 16px rgba(255,176,32,.18); }
.ed-trans-prev { position: relative; height: 52px; border-radius: var(--r-sm); overflow: hidden; background: #0F0D10; }
.ed-trans-prev i { position: absolute; inset: 0; }
.ed-tx-a { background: linear-gradient(135deg, #2a2013, #14100a); }   /* outgoing shot */
.ed-tx-b { background: var(--grad-molten); opacity: 0; }             /* incoming shot */
.ed-tx-veil { background: #000; opacity: 0; }                        /* dip / flash overlay */

@keyframes txFade    { 0%{opacity:0} 45%,55%{opacity:1} 100%{opacity:0} }
@keyframes txSlide   { 0%{transform:translateX(100%);opacity:1} 45%,55%{transform:translateX(0)} 100%{transform:translateX(-100%)} }
@keyframes txSlideUp { 0%{transform:translateY(100%);opacity:1} 45%,55%{transform:translateY(0)} 100%{transform:translateY(-100%)} }
@keyframes txZoom    { 0%{transform:scale(.2);opacity:0} 45%,55%{transform:scale(1);opacity:1} 100%{transform:scale(1.6);opacity:0} }
@keyframes txWhip    { 0%{transform:translateX(70%);filter:blur(6px);opacity:0} 45%{transform:translateX(0);filter:blur(0);opacity:1} 100%{transform:translateX(-70%);filter:blur(6px);opacity:0} }
@keyframes txGlitch  { 0%,100%{opacity:0;transform:translateX(0)} 20%{opacity:1;transform:translateX(-3px)} 30%{transform:translateX(3px)} 45%{transform:translateX(-2px)} 55%,80%{opacity:1;transform:translateX(0)} }
@keyframes txVeilDip { 0%,100%{opacity:0} 50%{opacity:1} }
@keyframes txVeilFlash { 0%,46%,54%,100%{opacity:0} 50%{opacity:.9} }
@keyframes txReveal  { 0%,49%{opacity:0} 50%,100%{opacity:1} }

.ed-tx-fade:hover .ed-tx-b    { animation: txFade 1.4s var(--ease-in-out) infinite; }
.ed-tx-slide:hover .ed-tx-b   { animation: txSlide 1.4s var(--ease-out) infinite; }
.ed-tx-slideup:hover .ed-tx-b { animation: txSlideUp 1.4s var(--ease-out) infinite; }
.ed-tx-zoom:hover .ed-tx-b    { animation: txZoom 1.4s var(--ease-out) infinite; }
.ed-tx-whip:hover .ed-tx-b    { animation: txWhip 1.1s var(--ease-out) infinite; }
.ed-tx-glitch:hover .ed-tx-b  { animation: txGlitch 1.1s steps(1,end) infinite; }
.ed-tx-dip:hover .ed-tx-veil  { animation: txVeilDip 1.6s var(--ease-in-out) infinite; }
.ed-tx-dip:hover .ed-tx-b     { animation: txReveal 1.6s step-end infinite; }
.ed-tx-flash .ed-tx-veil { background: #fff; }
.ed-tx-flash:hover .ed-tx-veil { animation: txVeilFlash 1.4s var(--ease-out) infinite; }
.ed-tx-flash:hover .ed-tx-b   { animation: txReveal 1.4s step-end infinite; }
/* "B-roll" tag + locked (between-shot) cards + the None (off) swatch. */
.ed-tx-tag {
  font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent2); background: var(--accent-softer);
  padding: 1px 5px; border-radius: var(--r-pill); vertical-align: middle;
}
.ed-trans.ed-tx-locked { opacity: .72; }
.ed-trans.ed-tx-locked:hover { opacity: 1; }
.ed-tx-none .ed-tx-a {
  background: repeating-linear-gradient(45deg, #17141b, #17141b 8px, #121016 8px, #121016 16px);
}

/* --- Music library --- */
.ed-music-grid { display: grid; gap: 8px; }
.ed-music {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; text-align: left;
  background: var(--ed-card); border: 1px solid var(--border); border-radius: var(--r-md); cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur) var(--ease-out);
}
.ed-music:hover { border-color: var(--border-strong); transform: translateX(2px); }
.ed-music.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ed-music-ic {
  display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 50%; background: var(--surface2); color: var(--accent);
}
.ed-music-ic .ed-ic { width: 16px; height: 16px; }
.ed-music.active .ed-music-ic { background: var(--grad-molten); color: var(--on-accent); }
.ed-music-txt { display: flex; flex-direction: column; min-width: 0; }
.ed-music-txt b { font-size: 13px; font-weight: 600; color: var(--text); }
.ed-music-txt i { font-size: 11px; color: var(--muted); font-style: normal; }
.ed-music-file {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  padding: 9px 12px; background: var(--ed-card); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: 12px; color: var(--text-2);
}
.ed-music-file .ed-ic { color: var(--accent); flex: 0 0 auto; }

/* --- B-Roll library (your own footage) --- */
.ed-broll-adds { display: grid; gap: 8px; }
.ed-broll-add {
  display: flex; align-items: center; gap: 12px; padding: 12px; text-align: left;
  background: var(--ed-card); border: 1px dashed var(--border-strong); border-radius: var(--r-md);
  color: var(--text); cursor: pointer;
  transition: border-color var(--dur) var(--ease-out), background var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.ed-broll-add:hover { border-color: var(--accent); background: var(--accent-softer); transform: translateY(-1px); }
.ed-broll-add .ed-ic { width: 20px; height: 20px; color: var(--accent); flex: 0 0 auto; }
.ed-broll-add span { display: flex; flex-direction: column; min-width: 0; }
.ed-broll-add b { font-size: 13px; font-weight: 600; }
.ed-broll-add i { font-size: 11px; color: var(--muted); font-style: normal; }
.ed-broll-list { display: flex; flex-direction: column; gap: 6px; }
.ed-broll-row {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; text-align: left;
  background: var(--ed-card); border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-2); cursor: pointer;
  transition: border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.ed-broll-row:hover { border-color: var(--border-strong); color: var(--text); }
.ed-broll-row.active { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent); }
.ed-broll-row .ed-ic { width: 15px; height: 15px; color: var(--accent); flex: 0 0 auto; }
.ed-broll-name { flex: 1 1 auto; min-width: 0; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-broll-tag {
  flex: 0 0 auto; font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent2); background: var(--accent-softer); padding: 1px 6px; border-radius: var(--r-pill);
}
.ed-broll-prompt {
  width: 100%; resize: vertical; min-height: 54px;
  background: var(--ed-card); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 9px 11px; font: inherit; font-size: 13px; line-height: 1.5;
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.ed-broll-prompt:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ed-focus-ring); }
.ed-broll-genrow { display: flex; gap: 8px; margin-top: 8px; }
.ed-broll-genrow .ed-add:disabled { opacity: .5; cursor: default; }
.ed-broll-msg {
  margin-top: 10px; padding: 9px 11px; border-radius: var(--r-sm);
  font-size: 12px; line-height: 1.45; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-2);
}
.ed-broll-msg.is-busy { border-color: var(--accent); color: var(--accent2); }
.ed-broll-msg.is-warn { border-color: var(--warn); color: var(--warn); }
.ed-broll-msg.is-error { border-color: var(--danger); color: var(--danger); }
.ed-fontchip.active { color: var(--accent); border-color: var(--accent); }

/* --- Coming-soon panel --- */
.ed-soon-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--on-accent); background: var(--grad-molten);
  padding: 2px 7px; border-radius: var(--r-pill);
}
.ed-soon { text-align: center; padding: 34px 16px; color: var(--muted); }
.ed-soon .ed-ic { width: 30px; height: 30px; color: var(--accent); opacity: .8; margin-bottom: 10px; }
.ed-soon p { font-size: 13px; color: var(--text-2); line-height: 1.5; margin: 0 0 6px; }
.ed-soon-sub { font-size: 11px; color: var(--faint); }

/* ===========================================================================
   Phone editor (≤768px) — ONE coherent layout:

     topbar → stage (flexes) → transport → compact timeline
     tool bar fixed at the very bottom; tool panels open as bottom SHEETS
     above it (editor.js closes them on open + toggles on re-tap).
   =========================================================================== */
@media (max-width: 768px) {
  /* Topbar: one row — Back · save state · undo/redo · Export */
  #reel-editor-screen { --ed-sheet-h: 36vh; --ed-ruler-h: 30px; }
  .ed-topbar { height: 52px; padding: 0 8px; gap: 6px; }
  .ed-title { display: none; }
  .ed-save-status {
    margin-left: 0; min-width: 0; max-width: 64px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .ed-top-actions { gap: 6px; flex: 0 0 auto; }
  /* The top bar is a single non-wrapping row. Every control kept in it on a
     phone is width Export does not have, and Export is the one control the
     whole screen exists for — so the rare actions move behind "..." and Back
     loses its redundant label (the arrow says it). Measured: the row needed
     447px on a 360px screen and Export was entirely off screen. */
  .ed-topbar #ed-back span { display: none; }
  .ed-topbar #ed-back { padding: 0 10px; }
  #ed-help, #ed-project, #ed-combine { display: none; }
  .ed-more-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; min-height: 44px; flex: 0 0 auto;
    background: transparent; color: var(--text-2);
    border: 1px solid var(--border); border-radius: var(--r-sm);
    font-size: 17px; line-height: 1; cursor: pointer;
  }
  .ed-more-btn:hover { color: var(--text); border-color: var(--border-strong); }
  .ed-ctx-item { padding: 11px 14px; font-size: 14px; }   /* finger sized */
  .ed-add, .ed-export-btn, .ed-tl-zoom button { min-height: 44px; }
  .ed-add.ed-tool { min-width: 44px; }
  .ed-tl-zoom button { min-width: 34px; }

  /* Column layout; the transcript pane is desktop-only */
  .ed-main { flex-direction: column; min-height: 0; }
  .ed-transcript { display: none; }
  .ed-stage-wrap { flex: 1 1 auto; min-height: 140px; padding: 8px 10px; gap: 8px; }
  .ed-stage { flex: 1 1 auto; height: auto; max-height: none; min-height: 0; }
  /* Transport under the preview overflowed ~130px (play + scrub + time + mutes +
     crop + fullscreen never wrapped). Wrap it; scrubber gets its own top row. */
  .ed-transport { gap: 6px 5px; width: 100%; }
  /* (the scrubber's own row is the base rule now, at every width) */
  /* Fixed-width clock so "9.9 / 32.1" → "10.0 / 32.1" never re-wraps the row. */
  .ed-time { min-width: 0; width: 76px; box-sizing: border-box; text-align: center; font-size: 9.5px; padding: 3px 4px; }
  .ed-play { width: 40px; height: 40px; }
  .ed-mute, .ed-fs { width: 34px; height: 34px; }
  .ed-frame { height: 34px; padding: 0 9px; }

  /* CapCut-style: an open sheet sits over the bottom of the screen. Reserve
     exactly its height on .ed-main so the preview flexes into the rest and stays
     FULLY above the sheet (captions live at the frame bottom) — the video keeps
     as much size as possible; the sheet is what stays compact. The timeline the
     sheet would cover is dropped. min-height keeps a usable preview when the
     on-screen keyboard eats the viewport. */
  #reel-editor-screen.ed-sheet-open .ed-main {
    padding-bottom: calc(var(--ed-sheet-h) + 56px + env(safe-area-inset-bottom, 0px));
  }
  #reel-editor-screen.ed-sheet-open .ed-stage-wrap { min-height: 150px; }
  #reel-editor-screen.ed-sheet-open .ed-timeline { display: none; }

  /* The right column dissolves — its children reposition below */
  .ed-right { display: contents; }

  /* Compact timeline; bottom padding clears the fixed tool bar */
  .ed-timeline { padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); }
  .ed-tl-head { max-height: min(240px, 34vh); }
  .ed-track-labels { flex: 0 0 64px; }
  .ed-track-label { padding: 0 6px; gap: 4px; font-size: 10px; }
  /* Thumb-sized lanes + blocks; the waveform lane keeps its 34px canvas. */
  .ed-track, .ed-track-label { height: 44px; }
  .ed-track-wave, .ed-track-labels .ed-track-label:first-of-type { height: 34px; }
  .ed-block { top: 4px; height: 36px; font-size: 12px; }
  /* Lanes with nothing on them are noise on a phone; they reappear on first add. */
  .ed-track-empty { display: none; }
  /* Trim grips: only on the selected block (an unselected block is one big move
     target) and wide enough for a finger. */
  .ed-block:not(.selected) .ed-trim { display: none; }
  .ed-block .ed-trim { width: min(20px, 30%); }   /* never eat a short block's move zone */
  .ed-block .ed-trim.l::after { left: 45%; } .ed-block .ed-trim.r::after { right: 45%; }
  .ed-topbar .ghost-btn { min-height: 44px; }
  .ed-insp-check { min-height: 40px; }
  .ed-insp-check input { width: 20px; height: 20px; }

  /* Tool bar: fixed at the bottom, horizontally swipeable, always reachable */
  .ed-rail {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 230;
    flex-direction: row; gap: 0; overflow-x: auto; overflow-y: hidden;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding: 4px 6px calc(env(safe-area-inset-bottom, 0px));
    border-left: none; border-top: 1px solid var(--border);
    background: rgba(22,22,28,.96);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    scrollbar-width: none;
  }
  .ed-rail::-webkit-scrollbar { display: none; }
  .ed-rail-btn { flex: 1 1 0; min-width: 0; padding: 5px 2px; gap: 3px; }
  .ed-rail-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .ed-rail-btn.active::before {
    left: 12px; right: 12px; top: auto; bottom: 0; width: auto; height: 3px;
    border-radius: 3px 3px 0 0;
  }

  /* Panels become bottom sheets above the tool bar. A sheet only exists
     while a panel is active — editor.js opens the editor with none active
     and re-tapping the active tool closes it. */
  .ed-panels {
    position: fixed; left: 0; right: 0; z-index: 225;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    max-height: var(--ed-sheet-h); overflow-y: auto; overscroll-behavior: contain;
    border-left: none; border-top: 1px solid var(--border-strong);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -16px 44px rgba(0,0,0,.55);
  }
  .ed-panels:not(:has(> .is-active)) { display: none; }

  /* Sheet chrome shared by every panel: sticky grab handle + Done (swipe down
     also closes — see edEnsureSheetBar). 16px inputs stop iOS focus-zoom. */
  .ed-sheet-bar {
    position: sticky; top: 0; z-index: 2;
    display: flex; align-items: center; justify-content: center;
    min-height: 40px; padding: 6px 8px 0; background: var(--surface);
  }
  .ed-sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border-strong); }
  .ed-sheet-bar .ed-sheet-done { position: absolute; right: 4px; top: 0; }
  .ed-sheet-done {
    background: transparent; border: none; color: var(--accent);
    font-weight: 600; font-size: 15px; padding: 8px 14px;
    min-height: 40px; cursor: pointer;
  }
  .ed-insp-field input, .ed-insp-field select, .ed-insp-field textarea { padding: 9px 10px; font-size: 16px; }
  .ed-insp-delete { padding: 11px; }
}

/* --- Reliability pass (2026-08-12): state-derived UI --------------------- */
/* An explicitly-disabled element stays on the timeline but reads as off. */
.ed-block-off { opacity: .38; }
.ed-block-off .ed-block-lbl { text-decoration: line-through; }

/* Music panel: the "music is off" state (delete = real state, not a hidden icon). */
.ed-music-offnote {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; margin-bottom: 12px; border-radius: var(--r-md);
  background: var(--ed-card); border: 1px solid var(--border);
  color: var(--text-2); font-size: 12.5px; line-height: 1.45;
}
.ed-music-offnote .ed-ic { flex: 0 0 auto; margin-top: 1px; color: var(--muted); }
.ed-music-offnote b { color: var(--text); }

/* Title/subtitle quick-position buttons (Top / Middle / Bottom). */
.ed-pos { flex: 1; justify-content: center; }
.ed-pos.active { border-color: var(--accent); color: var(--accent); background: var(--accent-softer); }

/* Bold / Italic / Underline toggles (P2 #8). */
.ed-biu-row { gap: 6px; }
.ed-biu {
  flex: 1; height: 36px; border-radius: var(--r-sm); cursor: pointer;
  background: var(--ed-card); color: var(--text-2); border: 1px solid var(--border);
  font-size: 16px; line-height: 1;
  transition: border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}
.ed-biu:hover { color: var(--text); border-color: var(--border-strong); }
.ed-biu.active { border-color: var(--accent); color: var(--accent); background: var(--accent-softer); }

/* --- Tool libraries (2026-08-13): Text · Stickers · Sounds · Zoom -------- */
/* Text style preset tiles — sample rendered in the preset's REAL style. */
.ed-tp-sample {
  font-size: 15px; letter-spacing: .4px; line-height: 1.2; max-width: 100%;
  text-transform: uppercase; paint-order: stroke fill; white-space: nowrap;
}
.ed-tp:hover .ed-tp-sample { animation: swPop .8s var(--ease-out) infinite; }

/* Meme stinger cards — previews mirror the export's styled drawtext. */
.ed-stinger-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ed-st-wasted {
  font-family: 'ReelAnton', 'Anton', sans-serif; font-size: 19px;
  letter-spacing: 4px; color: #c8c8c8;
  background: rgba(0,0,0,.55); padding: 4px 12px; border-radius: 4px;
  text-shadow: 0 0 3px #101010;
}
.ed-st-react {
  font-family: 'ReelAnton', 'Anton', sans-serif; font-size: 19px;
  letter-spacing: 2px; color: #fff; paint-order: stroke fill;
  -webkit-text-stroke: 1.6px #000;
  text-shadow: 0 2px 6px rgba(0,0,0,.8);
}
.ed-stinger:hover .ed-st-wasted { animation: edStFade 1.2s var(--ease-out) infinite; }
.ed-stinger:hover .ed-st-react { animation: swPop .7s var(--ease-out) infinite; }
@keyframes edStFade { 0% { opacity: 0; transform: scale(1.25); } 35%, 100% { opacity: 1; transform: scale(1); } }

/* Emoji wall */
.ed-emoji-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.ed-emoji-btn {
  display: grid; place-items: center; aspect-ratio: 1; font-size: 19px;
  background: var(--ed-card); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer; padding: 0;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur) var(--ease-out),
              background var(--dur) var(--ease-out);
}
.ed-emoji-btn:hover {
  transform: scale(1.18); border-color: var(--accent);
  background: var(--accent-softer); z-index: 1;
}
.ed-emoji-btn:active { transform: scale(.95); }

/* Sound-effect rows — ▶ preview + whole-row add. */
.ed-sfx-list { display: flex; flex-direction: column; gap: 6px; }
.ed-sfx-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--ed-card); border: 1px solid var(--border);
  border-radius: var(--r-md); cursor: pointer;
  transition: border-color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.ed-sfx-row:hover { border-color: var(--border-strong); transform: translateX(2px); }
.ed-sfx-row:hover .ed-sfx-add { color: var(--accent); }
.ed-sfx-play {
  display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 auto;
  border-radius: 50%; background: var(--surface2); color: var(--accent);
  border: 1px solid var(--border); cursor: pointer; padding: 0;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out);
}
.ed-sfx-play:hover { border-color: var(--accent); }
.ed-sfx-play.is-playing { background: var(--grad-molten); color: var(--on-accent); border-color: transparent; }
.ed-sfx-play .ed-ic { width: 12px; height: 12px; }
.ed-sfx-txt { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.ed-sfx-txt b { font-size: 12.5px; font-weight: 600; color: var(--text); }
.ed-sfx-txt i { font-size: 10.5px; color: var(--muted); font-style: normal; }
.ed-sfx-add { color: var(--muted); flex: 0 0 auto; transition: color var(--dur) var(--ease-out); }
.ed-sfx-add .ed-ic { width: 15px; height: 15px; }

/* Zoom punch cards — the little frame zooms by the preset's real strength. */
.ed-zoom-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ed-zp-prev { position: relative; overflow: hidden; }
.ed-zp-frame {
  position: absolute; inset: 8px; border-radius: 4px;
  background:
    linear-gradient(140deg, rgba(255,176,32,.28), transparent 55%),
    linear-gradient(320deg, rgba(255,255,255,.12), transparent 50%),
    #201a12;
  border: 1px solid rgba(255,255,255,.14);
  transform-origin: 60% 40%;
}
.ed-zp:hover .ed-zp-frame { animation: edZpPunch 1s var(--ease-out) infinite; }
.ed-zp-x {
  position: relative; z-index: 1; font-family: var(--font-mono);
  font-size: 12px; font-weight: 700; color: var(--text);
  text-shadow: 0 1px 4px rgba(0,0,0,.7);
}
@keyframes edZpPunch {
  0%, 18% { transform: scale(1); }
  32%, 68% { transform: scale(var(--zp, 1.35)); }
  85%, 100% { transform: scale(1); }
}

/* --- Safe zones + transport toggles (2026-08-13) ------------------------- */
/* Danger areas where platform chrome (TikTok/Reels/Shorts) sits over the
   video: top status strip, right action rail, bottom caption + nav. Numbers
   are the common denominator of the three platforms' published safe areas. */
.ed-safezones { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.ed-sz {
  position: absolute;
  background: repeating-linear-gradient(135deg,
    rgba(251,93,93,.16) 0 6px, rgba(251,93,93,.05) 6px 12px);
  outline: 1px dashed rgba(251,93,93,.45);
}
.ed-sz-top { left: 0; right: 0; top: 0; height: 6%; }
.ed-sz-right { right: 0; width: 13%; top: 34%; height: 46%; }
.ed-sz-bottom { left: 0; right: 0; bottom: 0; height: 15%; }
/* The keep-inside frame — content in here is safe on every platform. */
.ed-sz-border {
  position: absolute; left: 4%; right: 14%; top: 7%; bottom: 16%;
  border: 1.5px dashed rgba(255,255,255,.35); border-radius: 10px;
}

/* Transport toggles (safe zones / loop) share .ed-mute chrome; ed-on = lit. */
.ed-mute.ed-on { color: var(--accent); border-color: rgba(255,176,32,.5); }

/* --- AI Voiceover panel (#16) ------------------------------------------- */
.ed-vo-voice, .ed-vo-script {
  width: 100%; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.16); border-radius: 8px;
  padding: 9px 11px; color: #fff; font: inherit; font-size: 13px;
}
.ed-vo-script { min-height: 96px; resize: vertical; line-height: 1.5; }
.ed-vo-voice:focus-visible, .ed-vo-script:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ed-focus-ring); }
.ed-vo-sub { font-weight: 400; color: rgba(255,255,255,.5); font-size: 11px; }
.ed-vo-apply { justify-content: center; }
.ed-vo-note { margin-top: 8px; font-size: 12px; color: rgba(255,255,255,.6); min-height: 16px; }

/* --- CapCut-style drag-to-trim on the Video lane ------------------------ */
/* No overflow:hidden — the end handles sit half-outside the lane and the size
   tooltip floats above it. */
.ed-vtrim-dim {
  position: absolute; top: 0; height: 100%; z-index: 2;
  background: rgba(8,6,12,.72); backdrop-filter: saturate(.4) brightness(.5);
  pointer-events: none;
}
.ed-vtrim-handle {
  position: absolute; top: 0; height: 100%; width: 14px; margin-left: -7px;
  z-index: 4; cursor: ew-resize; display: flex; align-items: center;
  justify-content: center; touch-action: none;
}
.ed-vtrim-handle::before {
  content: ''; width: 4px; height: 60%; border-radius: 3px;
  background: var(--accent); box-shadow: 0 0 0 1px rgba(0,0,0,.4);
}
.ed-vtrim-handle::after {           /* a wider grab bar so the ends are obvious */
  content: ''; position: absolute; top: 0; height: 100%; width: 3px;
  background: var(--accent); opacity: .85;
}
.ed-vtrim-handle.left::after { left: 5px; }
.ed-vtrim-handle.right::after { right: 5px; }
.ed-vtrim-handle:hover::before { filter: brightness(1.15); }
.ed-vtrim-tip {
  position: absolute; top: -19px; transform: translateX(-50%); z-index: 6;
  display: none; padding: 1px 7px; border-radius: 6px; font-size: 11px;
  font-weight: 700; color: #12100a; background: var(--accent); white-space: nowrap;
  pointer-events: none;
}

/* Voice picker inside the editor: the shared .vo-* rows (style.css) are built on
   the --surface tokens for the setup rail; on the editor's darker translucent
   panel they need this lighter re-skin. The values intentionally differ from the
   base rules, so this block is NOT redundant. */
.ed-vo-voicelist .vo-voice-row {
  background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.14);
}
.ed-vo-voicelist .vo-voice-row:hover { border-color: rgba(255,255,255,.3); }
.ed-vo-voicelist .vo-voice-row.selected {
  border-color: var(--accent); background: rgba(255,176,32,.14);
}
.ed-vo-voicelist .vo-voice-name { color: #fff; }
.ed-vo-voicelist .vo-voice-tag { color: rgba(255,255,255,.55); border-color: rgba(255,255,255,.18); }
.ed-vo-voicelist .vo-play { background: rgba(0,0,0,.35); border-color: rgba(255,255,255,.22); }
.ed-vo-voicelist .vo-play:hover { background: var(--accent); color: #12100a; }
.ed-vo-voicelist { max-height: 190px; }

/* ============================================================================
   Editor tool sheets on a PHONE — compact, tap-first cards (2026-08-27).
   The library panels (Captions/Transitions/Zoom/Text presets) used desktop-sized
   cards: a big preview tile + name + a 2-line DESCRIPTION, plus a "hover a style
   to preview" hint. On touch there's no hover, so the descriptions + hint are
   dead weight and made the sheet a very long scroll (the Captions sheet was
   ~2400px). Drop the hint + descriptions, shrink the tiles, and show the big
   caption/text grids 3-up so a whole library is a glance, not a marathon.
   ============================================================================ */
@media (max-width: 600px) {
  .ed-applyall-btn { padding: 0 12px; min-height: 44px; font-size: 16px; }
  .ed-applyall-btn .ed-applyall-lbl { display: none; }   /* icon-only; aria-label names it */
  .ed-panels .ed-panel-head { font-size: 15px; }
  .ed-panels .ed-lib-hint { display: none; }        /* no hover on touch */
  .ed-panels .ed-sw-blurb { display: none; }         /* 2-line description → desktop only */

  /* Caption + text preset libraries: 3-up, compact. */
  #ed-panel-captions .ed-preset-grid,
  #ed-panel-text .ed-preset-grid { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .ed-preset-grid, .ed-trans-grid { gap: 8px; }
  .ed-preset, .ed-trans { padding: 5px; gap: 4px; }
  .ed-preset-prev, .ed-sw-prev, .ed-trans-prev { height: 40px; }
  .ed-preset-prev b { font-size: 17px; }
  .ed-sw-prev { font-size: 12.5px; padding: 3px 4px; }
  .ed-preset-name { font-size: 10px; line-height: 1.15; }

  /* Sound-effect rows: keep name + preview + add; drop the description subtitle. */
  .ed-panels .ed-sfx-txt i { display: none; }
  .ed-panels .ed-sfx-row { padding: 8px 10px; }
}

/* ---------------------------------------------------------------------------
   First-run tour. Above the editor (200) and its menus (350), below toasts
   (400) so a save confirmation still reads. The dim is one box-shadow spread
   off the highlight box, so there is exactly one element to move per step.
   --------------------------------------------------------------------------- */
.ed-tour { position: fixed; inset: 0; z-index: 360; }
.ed-tour-hole {
  position: fixed; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(6, 6, 10, .72), 0 0 0 2px var(--accent) inset;
  transition: left .22s var(--ease-out), top .22s var(--ease-out),
              width .22s var(--ease-out), height .22s var(--ease-out);
}
.ed-tour-card {
  position: fixed; width: min(320px, calc(100vw - 24px));
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: 16px 18px 14px; box-shadow: 0 18px 44px rgba(0, 0, 0, .6);
  transition: left .22s var(--ease-out), top .22s var(--ease-out);
}
.ed-tour-card h3 {
  margin: 0 0 6px; font-size: 15px; font-weight: 750; letter-spacing: .1px;
}
.ed-tour-card p {
  margin: 0 0 14px; font-size: 13px; line-height: 1.55; color: var(--text-2);
}
.ed-tour-foot { display: flex; align-items: center; gap: 12px; }
.ed-tour-dots { display: flex; gap: 5px; margin-right: auto; }
.ed-tour-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong);
}
.ed-tour-dots i.on { background: var(--accent); }
.ed-tour-btns { display: flex; gap: 8px; }
.ed-tour-btns button {
  border-radius: var(--r-xs); padding: 6px 13px; font-size: 12.5px;
  font-weight: 650; cursor: pointer; border: 1px solid var(--border);
  background: transparent; color: var(--text-2);
}
.ed-tour-btns button:hover { color: var(--text); border-color: var(--border-strong); }
.ed-tour-next {
  background: var(--accent) !important; color: var(--on-accent) !important;
  border-color: transparent !important;
}
.ed-tour-skip { border-color: transparent !important; }
/* Overflow menu. Desktop has room for everything, so it only exists on a
   phone, where the top bar is Back, undo/redo, this, and Export. */
.ed-more-btn { display: none; }

.ed-help {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  font-size: 13px; font-weight: 700; cursor: pointer; line-height: 1;
}
.ed-help:hover { color: var(--accent); border-color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .ed-tour-hole, .ed-tour-card { transition: none; }
}

/* ---------------------------------------------------------------------------
   Sticker + sound libraries. Both grew from a handful of hardcoded entries to
   130 and 41, which is the point at which a flat list stops working and you
   need categories and a search box.
   --------------------------------------------------------------------------- */
.ed-lib-search { position: relative; margin: 0 0 10px; }
.ed-lib-search input {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px 9px 32px; font-size: 13px;
  background: var(--field-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  -webkit-appearance: none; appearance: none;
}
.ed-lib-search input:focus { outline: none; border-color: var(--accent); }
.ed-lib-search input::placeholder { color: var(--faint); }
.ed-lib-search-ic {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none; display: flex;
}
.ed-lib-search-ic .ed-ic { width: 14px; height: 14px; }

.ed-lib-cats {
  display: flex; gap: 6px; overflow-x: auto; margin: 0 0 10px;
  padding-bottom: 2px; scrollbar-width: none;
}
.ed-lib-cats::-webkit-scrollbar { display: none; }
.ed-lib-cat {
  flex: 0 0 auto; padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-2); font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.ed-lib-cat:hover { color: var(--text); border-color: var(--border-strong); }
.ed-lib-cat.is-on {
  background: var(--accent); color: var(--on-accent); border-color: transparent;
}

.ed-gif-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ed-gif {
  display: flex; flex-direction: column; gap: 3px; padding: 4px;
  background: var(--ed-card, var(--surface2)); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer; text-align: center;
  /* Every tile the same height whatever its picture or the length of its name,
     so the grid reads as a grid. */
  height: 92px; overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-out),
              border-color var(--dur) var(--ease-out);
}
.ed-gif:hover { transform: translateY(-2px); border-color: var(--accent); }
.ed-gif:active { transform: scale(.97); }
.ed-gif-img {
  width: 100%; flex: 1 1 auto; min-height: 0; object-fit: contain;
  /* A chequerboard so a cut-out sticker reads as transparent rather than as a
     white box that will bake into the video. */
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.05) 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  border-radius: var(--r-xs);
}
.ed-gif-name {
  flex: 0 0 auto; font-size: 9.5px; line-height: 1.15; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ed-lib-more {
  width: 100%; margin-top: 9px; padding: 9px;
  background: transparent; border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm); color: var(--text-2);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.ed-lib-more:hover { color: var(--accent); border-color: var(--accent); }
.ed-lib-empty {
  padding: 22px 12px; text-align: center; color: var(--muted);
  font-size: 12.5px; line-height: 1.5;
}

@media (max-width: 600px) {
  /* Four across on a phone: the sheet is short, so more per row means less
     scrolling to see the library. */
  .ed-gif-grid { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .ed-gif { padding: 3px; height: 76px; }
  .ed-gif-name { display: none; }        /* the picture is the label */
  .ed-lib-search input { font-size: 16px; }   /* 16px stops iOS focus-zoom */
  .ed-lib-cat { padding: 7px 12px; }          /* finger sized */
}

/* --- Freeze frames ------------------------------------------------------
   A held frame is drawn OVER the clip it interrupts, in a colour that is not
   the clip amber, so it reads as "the reel stops here" rather than as another
   piece of footage. */
.ed-freeze {
  position: absolute; top: 1px; bottom: 1px; z-index: 3;
  box-sizing: border-box; cursor: ew-resize; touch-action: none;
  border-radius: 3px;
  border: 1px solid #7fd7ff;
  background: repeating-linear-gradient(
    135deg, rgba(127,215,255,.42) 0 5px, rgba(127,215,255,.16) 5px 10px);
  display: flex; align-items: center; justify-content: center;
  min-width: 6px; overflow: hidden;
}
.ed-freeze:hover, .ed-freeze:focus-visible { border-color: #b9ecff; background:
  repeating-linear-gradient(135deg, rgba(127,215,255,.58) 0 5px, rgba(127,215,255,.24) 5px 10px); }
.ed-freeze:focus-visible { outline: 2px solid var(--accent, #FFB020); outline-offset: 1px; }
.ed-freeze.selected {
  border-color: var(--accent, #FFB020);
  box-shadow: 0 0 0 1px var(--accent, #FFB020), 0 2px 10px rgba(0,0,0,.35);
}
.ed-freeze.ed-drag-active { z-index: 5; opacity: .95; }
.ed-freeze.at-limit { border-color: #ff8f8f; }
.ed-freeze-lbl {
  font-size: 9px; font-weight: 700; color: #04222e; letter-spacing: .02em;
  background: rgba(185,236,255,.9); border-radius: 2px; padding: 0 3px;
  white-space: nowrap; pointer-events: none;
}
/* The grip on the far edge. The whole band drags, but without something to
   aim at nobody discovers that the length is theirs to set. */
.ed-fz-h {
  position: absolute; top: 0; bottom: 0; right: 0; width: 7px;
  pointer-events: none; border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, rgba(127,215,255,0), rgba(185,236,255,.85));
  opacity: 0; transition: opacity var(--dur-fast) var(--ease-out);
}
.ed-fz-h::after {
  content: ''; position: absolute; top: 50%; right: 2px; transform: translateY(-50%);
  width: 2px; height: 11px; border-radius: 2px; background: #04222e;
}
.ed-freeze:hover .ed-fz-h, .ed-freeze.selected .ed-fz-h,
.ed-freeze:focus-visible .ed-fz-h, .ed-freeze.ed-drag-active .ed-fz-h { opacity: 1; }

.ed-fz-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 6px; padding: 8px 11px; font: inherit; font-size: 13px;
  cursor: pointer; border-radius: 7px; box-sizing: border-box; min-height: 40px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text-2);
}
.ed-fz-item:hover { color: var(--text); border-color: var(--border-strong); }
.ed-fz-item:focus-visible { outline: 2px solid var(--accent, #FFB020); outline-offset: 2px; }
.ed-fz-item.selected { color: var(--text); border-color: var(--accent, #FFB020); }
.ed-fz-dur { font-weight: 700; color: #7fd7ff; margin-left: auto; }
.ed-fz-x {
  flex: none; width: 28px; height: 28px; display: flex; align-items: center;
  justify-content: center; font: inherit; font-size: 17px; line-height: 1;
  cursor: pointer; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--text-2);
}
.ed-fz-x:hover { color: #ffd9d9; border-color: #b45c5c; background: rgba(180,92,92,.16); }

@media (max-width: 600px) {
  /* Menu rows and list rows are chosen with a thumb on a phone, so they need
     finger height rather than mouse height. */
  .ed-ctx-item { padding: 12px 14px; font-size: 14.5px; min-height: 44px; }
  .ed-fz-item { min-height: 48px; padding: 10px 12px; font-size: 14.5px; }
  .ed-fz-x { width: 44px; height: 44px; font-size: 20px; }
  .ed-freeze { min-width: 16px; }        /* still grabbable when the hold is short */
  .ed-fz-h { width: 10px; opacity: 1; }  /* no hover on a phone: always visible */
}
