/* ==========================================================================
   VibeCut — Modern Glassmorphic Video Editor UI
   v4.0 — Mobile-First, dvh-safe, zoom-resilient, trendy dark design
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
  --bg-app: #08090e;
  --bg-surface: #111219;
  --bg-elevated: #1a1c28;
  --bg-modal: #14151f;
  --bg-glass: rgba(17, 18, 25, 0.92);
  --bg-dock: rgba(10, 11, 18, 0.97);
  --bg-drawer: rgba(10, 12, 20, 0.98);
  --bg-drawer-tab: rgba(18, 20, 32, 0.85);

  --border-light: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-active: #8b5cf6;

  --text-main: #f1f5f9;
  --text-muted: #8892a4;
  --slider-track: rgba(255, 255, 255, 0.10);

  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-cyan: #38bdf8;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-yellow: #facc15;

  --grad-primary: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  --grad-magic: linear-gradient(135deg, #f43f5e 0%, #a855f7 100%);

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-brand: 'Outfit', sans-serif;

  /* Dock safe sizing */
  --dock-primary-h: 54px;
  --dock-tab-h: 22px;
  --topbar-h: 52px;
  /* Toast & Popout Tokens */
  --bg-toast: rgba(20, 21, 31, 0.94);
  --text-toast: #f1f5f9;
  --border-toast: var(--accent-purple);
  --bg-popout-hdr: rgba(18, 20, 30, 0.85);
  --border-popout-hdr: var(--border-medium);
  --grad-brand: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

:root[data-theme="light"], html[data-theme="light"], [data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-elevated: #e8edf5;
  --bg-modal: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.94);
  --bg-dock: rgba(255, 255, 255, 0.97);
  --bg-drawer: rgba(248, 250, 252, 0.98);
  --bg-drawer-tab: rgba(241, 245, 249, 0.95);

  --border-light: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.16);
  --border-active: #7c3aed;

  --text-main: #0f172a;
  --text-muted: #475569;
  --slider-track: rgba(0, 0, 0, 0.08);
  --bg-toast: rgba(255, 255, 255, 0.98);
  --text-toast: #0f172a;
  --border-toast: rgba(139, 92, 246, 0.45);
  --bg-popout-hdr: #ffffff;
  --border-popout-hdr: rgba(0, 0, 0, 0.12);
  --grad-brand: linear-gradient(135deg, #0f172a 0%, #334155 100%);
}

/* --------------------------------------------------------------------------
   Reset & Base
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* dvh = Dynamic Viewport Height — accounts for mobile chrome/nav bars */
html {
  height: 100%;
  height: 100dvh;
}

body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  /* Subtle grain texture for premium feel */
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
}

/* --------------------------------------------------------------------------
   Ambient Lighting Orbs
   -------------------------------------------------------------------------- */
.vc-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.vc-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.18;
}

.orb-1 {
  width: min(380px, 60vw);
  height: min(380px, 60vw);
  background: #ec4899;
  top: -80px;
  left: -40px;
}

.orb-2 {
  width: min(420px, 65vw);
  height: min(420px, 65vw);
  background: #8b5cf6;
  bottom: -80px;
  right: -40px;
}

/* --------------------------------------------------------------------------
   Top Bar
   -------------------------------------------------------------------------- */
.vc-topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(6px, 2.5vw, 16px);
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border-light);
  gap: 6px;
  flex-shrink: 0;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  }

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-title {
  display: flex;
  align-items: center;
}

/* Premium gradient brand name */
.brand-name {
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: clamp(17px, 4vw, 22px);
  letter-spacing: -0.03em;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-accent {
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-hub {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  text-decoration: none;
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1.5vw, 8px);
  flex-shrink: 0;
}

.btn-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px clamp(8px, 2vw, 12px);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-pill:hover {
  background: var(--bg-elevated);
  border-color: var(--border-medium);
}

.btn-save {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px clamp(10px, 2.5vw, 14px);
  border-radius: var(--radius-full);
  background: var(--grad-primary);
  border: none;
  color: #ffffff;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: clamp(11px, 2.5vw, 13px);
  cursor: pointer;
  box-shadow: 0 2px 14px rgba(236, 72, 153, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-save:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 18px rgba(236, 72, 153, 0.55);
}

.btn-save:active {
  transform: scale(0.97);
}

.btn-icon {
  width: clamp(30px, 7vw, 36px);
  height: clamp(30px, 7vw, 36px);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.btn-icon:hover {
  background: var(--bg-elevated);
}

.hamburger-symbol {
  font-size: 16px;
  line-height: 1;
}

.btn-icon .icon-moon { display: block; }
.btn-icon .icon-sun { display: none; }
[data-theme="light"] .btn-icon .icon-moon { display: none; }
[data-theme="light"] .btn-icon .icon-sun { display: block; }

/* Hide ratio label text on very small screens */
@media (max-width: 399px) {
  #labelRatio {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Dropdown Menu
   -------------------------------------------------------------------------- */
.vc-dropdown-menu {
  position: fixed;
  top: calc(var(--topbar-h) + 6px);
  right: 12px;
  width: min(240px, calc(100vw - 24px));
  background: var(--bg-modal);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  display: none;
  z-index: 2500;
}

.vc-dropdown-menu.show {
  display: block;
  animation: slideDown 0.15s ease;
}

.dropdown-content {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.menu-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 4px 8px;
  letter-spacing: 0.5px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  min-height: 44px;
}

.menu-item:hover {
  background: var(--bg-elevated);
}

.menu-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 0;
}

/* --------------------------------------------------------------------------
   Main Stage — Flex column, fills remaining space
   -------------------------------------------------------------------------- */
.vc-main-stage {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Player Section — Flex ratio based, no fixed vh heights
   -------------------------------------------------------------------------- */
.stage-player-section {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2dvh, 16px) clamp(8px, 3vw, 14px) clamp(4px, 1dvh, 10px);
  overflow: hidden;
  min-height: 0;
}

/* Player wrapper: width-constrained, aspect-ratio drives height */
.player-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: clamp(10px, 3vw, 18px);
  background: #000000;
  overflow: hidden;
  /* Animated gradient border for premium look */
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 16px 48px -10px rgba(0, 0, 0, 0.85),
    0 0 30px -10px rgba(139, 92, 246, 0.2);
  border: 1px solid transparent;
  background-clip: padding-box;
  /* Width-first sizing — height flows from aspect-ratio */
  width: 100%;
  max-width: min(calc(38dvh * (16 / 9)), 100%); /* default 16:9 */
  transition: max-width 0.25s ease, border-radius 0.25s ease;
}

/* Subtle animated gradient border overlay */
.player-wrapper::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.25), rgba(139, 92, 246, 0.25), rgba(56, 189, 248, 0.1));
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.player-wrapper:hover::after {
  opacity: 1;
}

/* Aspect ratio variants — max-width scales width for different ratios */
.player-wrapper.ratio-9-16 {
  aspect-ratio: 9 / 16;
  max-width: min(calc(38dvh * (9 / 16)), 100%);
}
.player-wrapper.ratio-16-9 {
  aspect-ratio: 16 / 9;
  max-width: min(calc(38dvh * (16 / 9)), 100%);
}
.player-wrapper.ratio-1-1 {
  aspect-ratio: 1 / 1;
  max-width: min(38dvh, 100%);
}
.player-wrapper.ratio-4-5 {
  aspect-ratio: 4 / 5;
  max-width: min(calc(38dvh * (4 / 5)), 100%);
}

/* When empty state is active, release rigid aspect-ratio lock and provide comfortable adaptive height */
.player-wrapper.empty-active,
.player-wrapper:has(#playerEmptyState:not([style*="display: none"])) {
  aspect-ratio: auto !important;
  min-height: 200px;
  max-height: none;
  width: min(calc(38dvh * (16 / 9)), 100%);
  overflow: visible;
}

.player-wrapper.empty-active #previewCanvas {
  display: none !important;
}


#previewCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Empty State */
.player-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(10px, 2dvh, 16px) clamp(8px, 2.5vw, 16px);
  background: var(--bg-surface);
  z-index: 25;
  color: var(--text-main);
  user-select: none;
  overflow-y: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  box-sizing: border-box;
}

.player-wrapper.empty-active .player-empty-state {
  position: relative !important;
  inset: auto !important;
  min-height: 200px;
}

.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: min(390px, 94%);
  margin: auto 0;
  padding: clamp(10px, 1.8dvh, 16px) clamp(12px, 3vw, 20px);
  border-radius: var(--radius-md);
  background: rgba(139, 92, 246, 0.05);
  border: 1.5px dashed rgba(139, 92, 246, 0.38);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.empty-icon-ring {
  width: clamp(30px, 4.5dvh, 40px);
  height: clamp(30px, 4.5dvh, 40px);
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.16);
  border: 2px solid rgba(139, 92, 246, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.35);
  margin-bottom: clamp(3px, 0.8dvh, 6px);
  flex-shrink: 0;
}

.empty-icon {
  width: clamp(16px, 2.5dvh, 20px);
  height: clamp(16px, 2.5dvh, 20px);
  color: var(--accent-purple);
}

.empty-title {
  font-size: clamp(14px, 3.4vw, 17px);
  font-weight: 800;
  font-family: var(--font-brand);
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: clamp(2px, 0.6dvh, 4px);
  line-height: 1.2;
}

.empty-description {
  font-size: clamp(10.5px, 2.2vw, 12px);
  color: var(--text-muted);
  max-width: 290px;
  line-height: 1.35;
  margin-bottom: clamp(6px, 1.2dvh, 10px);
}

.btn-empty-import {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: clamp(7px, 1.4dvh, 10px) clamp(16px, 3.5vw, 24px);
  border-radius: var(--radius-full);
  background: var(--grad-primary);
  color: #ffffff;
  font-size: clamp(11.5px, 2.2vw, 13px);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(236, 72, 153, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 38px;
}

.btn-empty-import:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(236, 72, 153, 0.6);
}

.btn-empty-import:active {
  transform: scale(0.97);
}

.empty-hints {
  margin-top: clamp(4px, 1dvh, 8px);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  opacity: 0.85;
}

/* Subtitle Overlay */
.video-subtitle-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
}

.subtitle-text {
  text-align: center;
  font-family: var(--font-brand);
  font-weight: 800;
  line-height: 1.25;
}

.subtitle-text.style-mrbeast {
  color: var(--accent-yellow);
  font-size: 26px;
  text-transform: uppercase;
  text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
}

.subtitle-text.style-karaoke {
  color: var(--accent-cyan);
  font-size: 24px;
  text-shadow: 0 0 14px #06b6d4;
}

.subtitle-text.style-minimal {
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 18px;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px 14px;
  border-radius: var(--radius-full);
}

/* Player Badges */
.badge-blur {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(139, 92, 246, 0.85);
  backdrop-filter: blur(6px);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10;
}

.badge-overlay-active {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(5, 150, 105, 0.9);
  backdrop-filter: blur(8px);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.badge-audio-active {
  position: absolute;
  top: 40px;
  left: 10px;
  background: rgba(30, 58, 138, 0.9);
  backdrop-filter: blur(8px);
  color: #93c5fd;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.mini-eq-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.mini-eq-bars span {
  width: 2.5px;
  background: #38bdf8;
  border-radius: 1px;
}

.mini-eq-bars .bar1 { height: 60%; animation: eqBounce 0.5s ease-in-out infinite alternate; }
.mini-eq-bars .bar2 { height: 100%; animation: eqBounce 0.4s ease-in-out infinite alternate-reverse; }
.mini-eq-bars .bar3 { height: 75%; animation: eqBounce 0.6s ease-in-out infinite alternate; }

@keyframes eqBounce {
  0% { height: 25%; }
  100% { height: 100%; }
}

/* Loading Indicator */
.player-loading {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #ffffff;
  font-size: 12px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Player Control Bar
   -------------------------------------------------------------------------- */
.player-bar {
  display: flex;
  align-items: center;
  gap: clamp(6px, 2vw, 10px);
  margin-top: clamp(6px, 1.5dvh, 10px);
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 5px clamp(10px, 3vw, 14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.btn-player {
  width: clamp(30px, 7vw, 36px);
  height: clamp(30px, 7vw, 36px);
  min-width: 30px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-player:hover, .btn-player.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.btn-play-large {
  width: clamp(36px, 8vw, 44px);
  height: clamp(36px, 8vw, 44px);
  min-width: 36px;
  border-radius: 50%;
  background: var(--grad-primary);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-play-large:hover {
  transform: scale(1.08);
  box-shadow: 0 0 28px rgba(168, 85, 247, 0.65);
}

.btn-play-large:active {
  transform: scale(0.95);
}

.time-tag {
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 4px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

#timeCurrent {
  color: var(--text-main);
  font-weight: 800;
}

/* --------------------------------------------------------------------------
   Overlay Interactive Inspector / Adjustment Bar
   -------------------------------------------------------------------------- */
.overlay-adjust-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(calc(38dvh * (16 / 9)), 100%);
  margin-top: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 12px rgba(56, 189, 248, 0.2);
  z-index: 30;
  box-sizing: border-box;
  animation: slideDown 0.18s ease;
}

.oab-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.oab-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.oab-tip {
  font-size: 9.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oab-top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.oab-collapse-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.oab-collapse-btn:hover {
  color: var(--text-main);
  background: var(--bg-elevated);
}

.oab-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s ease;
}

.oab-close-btn:hover {
  color: var(--text-main);
}

.overlay-adjust-bar.collapsed {
  gap: 0;
  padding: 6px 12px;
}

.overlay-adjust-bar.collapsed .oab-controls-row {
  display: none !important;
}

.overlay-adjust-bar.collapsed #oabCollapseIcon {
  transform: rotate(180deg);
}

.oab-controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.oab-ctrl-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 120px;
}

.oab-lbl {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.oab-lbl b {
  color: var(--text-main);
  font-weight: 700;
}

.oab-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-elevated);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.oab-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.6);
}

.oab-pills-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.oab-pill {
  padding: 2px 7px;
  font-size: 9.5px;
  font-weight: 700;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.oab-pill:hover,
.oab-pill.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.oab-del-btn {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-red);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: background 0.15s ease;
}

.oab-del-btn:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* --------------------------------------------------------------------------
   Timeline Section — flex: 1 fills remaining space
   -------------------------------------------------------------------------- */
.stage-timeline-section {
  flex: 1 1 0;
  min-height: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  padding: clamp(6px, 1.5dvh, 12px) clamp(6px, 2vw, 10px) clamp(8px, 2dvh, 12px);
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1dvh, 8px);
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   Pop-Out Timeline Studio (Fullscreen overlay)
   -------------------------------------------------------------------------- */
.timeline-popout-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-popout-hdr);
  border: 1px solid var(--border-popout-hdr);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.stage-timeline-section.popped-out .timeline-popout-header {
  display: flex;
}

.popout-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.popout-header-emoji { font-size: 20px; line-height: 1; }

.popout-header-title {
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: 14px;
  color: var(--text-main);
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.popout-header-subtitle {
  font-size: 10px;
  color: var(--text-muted);
}

.popout-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-popout-play {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad-primary);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(236, 72, 153, 0.4);
  transition: transform 0.15s ease;
}

.btn-popout-play:hover { transform: scale(1.08); }
.btn-popout-play:active { transform: scale(0.95); }

.btn-popout-play svg, .btn-popout-play i {
  width: 14px;
  height: 14px;
}

.popout-time-tag {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  letter-spacing: 0.3px;
}

.btn-popout-done {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #10b981;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-popout-done:hover, .btn-popout-done:active {
  background: #10b981;
  color: #ffffff;
}

.btn-popout-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 20px;
  font-family: inherit;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-popout-close:hover, .btn-popout-close:active {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* Popped-Out full-screen workspace */
.stage-timeline-section.popped-out {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1300 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-height: none !important;
  margin: 0 !important;
  padding: max(12px, env(safe-area-inset-top, 12px)) 12px max(16px, env(safe-area-inset-bottom, 16px)) !important;
  background: #090a12 !important;
  backdrop-filter: blur(28px) !important;
  -webkit-backdrop-filter: blur(28px) !important;
  border: none !important;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8) !important;
  display: flex !important;
  flex-direction: column !important;
  animation: timelinePopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

[data-theme="light"] .stage-timeline-section.popped-out {
  background: #f8fafc !important;
}

@keyframes timelinePopIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.stage-timeline-section.popped-out .timeline-scroll-box {
  flex: 1 1 0 !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  padding: 12px 10px 24px !important;
  background: rgba(0, 0, 0, 0.35) !important;
  border-radius: var(--radius-md) !important;
}

[data-theme="light"] .stage-timeline-section.popped-out .timeline-scroll-box {
  background: rgba(0, 0, 0, 0.04) !important;
}

body.timeline-studio-open {
  overflow: hidden !important;
}

/* --------------------------------------------------------------------------
   Timeline Toolbar
   -------------------------------------------------------------------------- */
.timeline-toolbar-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 4px;
  gap: 8px;
  flex-shrink: 0;
}

.timeline-zoom-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
}

.btn-zoom-step {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.15s ease;
  min-width: 28px;
  min-height: 28px;
}

.btn-zoom-step:hover, .btn-zoom-step:active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.12);
}

.zoom-icon {
  width: 12px;
  height: 12px;
}

.zoom-slider {
  width: clamp(50px, 12vw, 80px);
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-purple);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}

.zoom-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 20px;
  cursor: pointer;
  padding: 1px 3px;
  border-radius: 4px;
}

.zoom-label:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.timeline-toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.timeline-status-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.22);
  color: var(--accent-purple);
  white-space: nowrap;
}

.btn-timeline-focus {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.32);
  color: var(--accent-purple);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  min-height: 28px;
}

.btn-timeline-focus i, .btn-timeline-focus svg {
  width: 11px;
  height: 11px;
}

.btn-timeline-focus:hover, .btn-timeline-focus:active,
.btn-timeline-focus.active {
  background: var(--accent-purple);
  color: #ffffff;
  border-color: var(--accent-purple);
}

/* --------------------------------------------------------------------------
   Timeline Scroll Box
   -------------------------------------------------------------------------- */
.timeline-scroll-box {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
  -webkit-overflow-scrolling: touch;
  padding: 8px 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border-light);
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
}

.timeline-scroll-box::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.timeline-scroll-box::-webkit-scrollbar-track { background: transparent; }

.timeline-scroll-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.timeline-scroll-box::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.38);
}

.timeline-aligned-tracks {
  position: relative;
  min-width: 100%;
  padding: 6px 8px 28px;
}

/* Shared Time Ruler */
.timeline-ruler {
  position: relative;
  height: 20px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

.ruler-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border-light);
}

.ruler-tick.major {
  background: rgba(255, 255, 255, 0.28);
}

.ruler-label {
  position: absolute;
  top: 2px;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  transform: translateX(-50%);
  user-select: none;
}

/* Playhead Needle */
.timeline-needle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
  z-index: 50;
  pointer-events: none;
  transform: translateX(-1px);
}

.needle-top {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 10px;
  background: #ef4444;
  clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
}

.needle-body {
  width: 100%;
  height: 100%;
}

/* Track Blocks */
.timeline-track-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  margin-bottom: 6px;
}

.mt-2 { margin-top: 8px; }

.empty-track-msg {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  color: var(--text-muted);
  padding: 6px 10px;
  line-height: 1.35;
  user-select: none;
}

.track-label-bar {
  position: sticky;
  left: 0;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 4px 8px 4px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-light);
  box-shadow: 4px 0 14px rgba(0, 0, 0, 0.15);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
  width: fit-content;
  min-height: 30px;
}

.track-label-title {
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0.2px;
}

.btn-add-track-item {
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: var(--radius-full);
  color: var(--accent-purple);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  min-height: 24px;
}

.btn-add-track-item:hover {
  background: var(--accent-purple);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.45);
}

/* Timeline Selection Glow */
.timeline-clip-card.selected,
.timeline-overlay-card.selected,
.audio-block-card.selected,
.timeline-sfx-pin.selected {
  outline: 2px solid #ffffff !important;
  box-shadow: 0 0 22px rgba(139, 92, 246, 0.95), inset 0 0 8px rgba(255, 255, 255, 0.22) !important;
  z-index: 30 !important;
}

/* Clips Strip */
.clips-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
  height: 50px;
}

.timeline-clip-card {
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3730a3 0%, #4f46e5 50%, #7c3aed 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  padding: 0 10px;
  cursor: pointer;
  position: relative;
  color: #ffffff;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.timeline-clip-card:hover { transform: translateY(-1px); }

.clip-card-info {
  display: flex;
  flex-direction: column;
  pointer-events: none;
  gap: 1px;
}

.clip-card-name {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.clip-card-dur {
  font-size: 9.5px;
  opacity: 0.85;
  font-weight: 600;
}

.clip-trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 12px;
  background: rgba(255, 255, 255, 0.28);
  cursor: ew-resize;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.clip-trim-handle::after {
  content: '';
  width: 2px;
  height: 14px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 1px;
}

.clip-trim-handle:hover { background: rgba(255, 255, 255, 0.85); }
.clip-trim-handle:hover::after { background: #333; }

.clip-trim-handle.handle-left { left: 0; border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
.clip-trim-handle.handle-right { right: 0; border-top-right-radius: 10px; border-bottom-right-radius: 10px; }

.btn-timeline-trans {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--accent-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.btn-timeline-trans:hover {
  transform: scale(1.15);
  background: var(--accent-purple);
  color: #ffffff;
}

/* Overlays Strip */
.overlays-strip {
  position: relative;
  height: 42px;
  background: rgba(16, 185, 129, 0.05);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(16, 185, 129, 0.28);
}

.timeline-overlay-card {
  position: absolute;
  top: 3px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #059669, #0d9488);
  border: 1px solid rgba(255, 255, 255, 0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  user-select: none;
  overflow: hidden;
  z-index: 5;
}

.timeline-overlay-card.secondary {
  background: linear-gradient(135deg, #7c3aed, #db2777);
  border-color: rgba(236, 72, 153, 0.4);
}

.overlay-card-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.btn-del-mini {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  cursor: pointer;
  padding: 1px 4px;
  margin-left: 4px;
}

.btn-del-mini:hover { color: #ffffff; }

.timeline-clip-card .btn-del-mini {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 20;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  margin: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}

.timeline-clip-card .btn-del-mini:hover {
  background: rgba(239, 68, 68, 0.9);
  transform: scale(1.15);
}

/* Audio Tracks */
.audio-track-strip {
  position: relative;
  height: 34px;
  background: rgba(56, 189, 248, 0.04);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(56, 189, 248, 0.22);
}

.audio-block-card {
  position: absolute;
  top: 2px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  user-select: none;
  cursor: pointer;
}

.audio-block-card.voice {
  background: linear-gradient(90deg, #0284c7, #0369a1);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.audio-block-card.music {
  background: linear-gradient(90deg, #6366f1, #4f46e5);
  border: 1px solid rgba(165, 180, 252, 0.4);
}

.audio-waveform-canvas {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  opacity: 0.35;
  pointer-events: none;
}

/* SFX Strip */
.sfx-track-strip {
  position: relative;
  height: 32px;
  background: rgba(236, 72, 153, 0.04);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(236, 72, 153, 0.22);
}

.timeline-sfx-pin {
  position: absolute;
  top: 2px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  user-select: none;
}

.timeline-sfx-pin:hover { transform: scale(1.05); }

/* --------------------------------------------------------------------------
   Audio Mixer VU
   -------------------------------------------------------------------------- */
.slider-meter-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.live-vu-meter {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  position: relative;
}

.vu-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #f59e0b, #ef4444);
  border-radius: 2px;
  transition: width 0.1s ease;
}

/* --------------------------------------------------------------------------
   Bottom Action Dock
   -------------------------------------------------------------------------- */
.vc-action-dock {
  background: var(--bg-dock);
  backdrop-filter: blur(28px) saturate(1.5);
  -webkit-backdrop-filter: blur(28px) saturate(1.5);
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 100;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.22);
  /* Safe area for iPhone notch/home bar */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  flex-shrink: 0;
}

/* Drawer Toggle Handle */
.dock-drawer-tab {
  height: var(--dock-tab-h);
  min-height: var(--dock-tab-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  background: var(--bg-drawer-tab);
  border-bottom: 1px solid var(--border-light);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
  transition: all 0.15s ease;
}

.dock-drawer-tab:hover {
  background: rgba(139, 92, 246, 0.12);
  color: var(--accent-purple);
}

.drawer-drag-pill {
  width: 32px;
  height: 4px;
  background: var(--border-medium);
  border-radius: var(--radius-full);
}

.drawer-tab-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.drawer-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.25s ease;
}

.vc-action-dock.drawer-open .drawer-chevron {
  transform: rotate(180deg);
}

/* Expandable Drawer Content */
.dock-drawer-content {
  max-height: 0;
  overflow: hidden;
  background: var(--bg-drawer);
  border-bottom: 1px solid var(--border-light);
  transition: max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1), padding 0.3s ease;
}

.vc-action-dock.drawer-open .dock-drawer-content {
  max-height: 230px;
  padding: 10px 14px 12px;
  overflow-y: auto;
}

.drawer-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

.drawer-section-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.btn-drawer-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 30px;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-drawer-close:hover {
  color: var(--text-main);
  background: var(--bg-elevated);
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.drawer-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 44px;
}

.drawer-btn:hover {
  border-color: var(--accent-purple);
  background: var(--bg-elevated);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.drawer-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-icon-wrap i {
  width: 18px;
  height: 18px;
}

/* 5 Core Primary Tools Bar */
.dock-primary-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  height: var(--dock-primary-h);
  padding: 2px clamp(2px, 1vw, 6px);
  box-sizing: border-box;
  width: 100%;
}

.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  height: 100%;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: clamp(8.5px, 2.2vw, 10.5px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 2px 1px;
  position: relative;
  min-width: 0;
  box-sizing: border-box;
}

.dock-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
}

/* Active glow state for dock buttons */
.dock-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  transform: translateY(-1px);
}

.dock-btn:active {
  transform: scale(0.95);
}

/* Glow effect on active dock buttons */
.dock-btn:active::before,
.dock-btn.active::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.15);
  box-shadow: inset 0 0 12px rgba(139, 92, 246, 0.25);
}

.dock-icon {
  width: clamp(16px, 4vw, 20px);
  height: clamp(16px, 4vw, 20px);
}

.dock-btn.highlight-sound { color: #38bdf8; }
.dock-btn.highlight-sound:hover { background: rgba(56, 189, 248, 0.1); }

.dock-btn.danger { color: #f87171; }
.dock-btn.danger:hover { background: rgba(239, 68, 68, 0.1); }

.dock-btn.highlight-overlay { color: #10b981; }
.dock-btn.highlight-overlay:hover { background: rgba(16, 185, 129, 0.1); }

.dock-btn.highlight-sfx { color: #38bdf8; }
.dock-btn.highlight-sfx:hover { background: rgba(56, 189, 248, 0.1); }

.dock-btn.highlight-magic { color: var(--accent-pink); }
.dock-btn.highlight-magic:hover { background: rgba(236, 72, 153, 0.1); }

.drawer-icon {
  width: 20px;
  height: 20px;
}

/* --------------------------------------------------------------------------
   Popups & Modals
   -------------------------------------------------------------------------- */
dialog.vc-popup {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: none;
  margin: 0;
  padding: clamp(12px, 3dvh, 24px) clamp(12px, 3.5vw, 20px);
  padding-bottom: max(clamp(16px, 3dvh, 24px), env(safe-area-inset-bottom, 16px));
  padding-top: max(clamp(12px, 2.5dvh, 20px), env(safe-area-inset-top, 12px));
  box-sizing: border-box;
  display: none;
  align-items: center; /* Perfectly centered within viewport on all devices */
  justify-content: center;
  z-index: 1000;
  color: var(--text-main);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

dialog.vc-popup[open] {
  display: flex;
}

.popup-box {
  width: 100%;
  max-width: 480px;
  background: var(--bg-modal);
  color: var(--text-main);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px -8px rgba(0, 0, 0, 0.65), 0 0 24px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  max-height: min(85dvh, calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 36px));
  margin: auto 0;
  box-sizing: border-box;
}

.popup-box::before {
  display: none;
}

@keyframes modalScaleIn {
  from { transform: scale(0.95) translateY(12px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.popup-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.popup-emoji { font-size: 22px; }

.popup-title-group h3 {
  font-family: var(--font-brand);
  font-size: clamp(14px, 3.5vw, 16px);
  font-weight: 800;
  color: var(--text-main);
}

.popup-title-group p {
  font-size: 11px;
  color: var(--text-muted);
}

.popup-close {
  background: var(--bg-elevated);
  border: none;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.popup-close:hover {
  color: var(--text-main);
  background: var(--bg-surface);
}

.popup-body {
  padding: 16px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
}

.popup-body::-webkit-scrollbar { width: 4px; }
.popup-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Popup Content Elements
   -------------------------------------------------------------------------- */
.info-card {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--accent-green);
}

.info-icon { width: 22px; height: 22px; flex-shrink: 0; }

.info-card strong { display: block; font-size: 12px; font-weight: 700; }
.info-card p { font-size: 11px; color: var(--text-main); }

.setting-item { display: flex; flex-direction: column; gap: 6px; }

.setting-item label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

.label-row span { color: var(--text-main); }

.label-row strong {
  color: var(--accent-purple) !important;
  font-weight: 800;
  font-size: 12px;
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
}

.option-pills, .speed-grid, .bg-options-grid, .trans-options-grid, .ratio-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pill-btn, .speed-card, .bg-card, .trans-card, .ratio-card, .style-card {
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
  min-height: 44px;
}

.pill-btn:hover, .speed-card:hover, .bg-card:hover, .trans-card:hover, .ratio-card:hover, .style-card:hover {
  border-color: var(--border-active);
}

.pill-btn.active, .speed-card.active, .bg-card.active, .trans-card.active, .ratio-card.active, .style-card.active {
  background: rgba(139, 92, 246, 0.15);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

.speed-num {
  font-size: 16px;
  font-weight: 800;
  font-family: var(--font-brand);
}

.bg-emoji, .trans-emoji, .ratio-emoji { font-size: 20px; }

.style-cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.preview-text { font-weight: 800; font-size: 11px; }
.yellow-pop { color: var(--accent-yellow); }
.cyan-glow { color: var(--accent-cyan); }
.white-clean { color: #ffffff; }

/* Range Slider */
.clean-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  outline: none;
  cursor: pointer;
  margin: 6px 0 4px;
}

.clean-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 3.5px solid var(--accent-purple);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.clean-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  border: 3.5px solid var(--accent-purple);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.clean-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 14px rgba(139, 92, 246, 0.6);
}

/* Toggle Switch */
.friendly-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  gap: 12px;
}

.friendly-switch-row strong { display: block; font-size: 12px; color: var(--text-main); }
.friendly-switch-row p { font-size: 10.5px; color: var(--text-muted); }

.clean-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 24px;
  flex-shrink: 0;
}

.clean-switch input { opacity: 0; width: 0; height: 0; }

.switch-ball {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-full);
  transition: 0.2s;
}

.switch-ball:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #ffffff;
  border-radius: 50%;
  transition: 0.2s;
}

input:checked + .switch-ball { background: var(--accent-purple); }
input:checked + .switch-ball:before { transform: translateX(16px); }

/* Record Voice */
.record-voice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.btn-record-voice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  min-height: 36px;
}

.record-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.btn-record-voice.recording .record-dot {
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.record-timer {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

/* Big Action Button */
.btn-big-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-purple);
  border: none;
  color: #ffffff;
  font-family: var(--font-brand);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 46px;
}

.btn-big-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

.btn-big-action.btn-magic {
  background: var(--grad-magic);
  box-shadow: 0 4px 14px rgba(244, 63, 94, 0.35);
}

.btn-big-action.btn-download {
  background: var(--accent-green);
  text-decoration: none;
}

/* Subtitle list */
.simple-captions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.caption-line-row { display: flex; gap: 6px; align-items: center; }

.caption-line-input {
  flex: 1;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  font-size: 12px;
  min-height: 36px;
}

.btn-text-action {
  background: transparent;
  border: none;
  color: var(--accent-purple);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  padding: 4px 0;
}

/* Upload Drop Card */
.upload-drop-card {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: var(--bg-elevated);
  transition: border-color 0.15s ease;
}

.upload-drop-card:hover { border-color: var(--accent-purple); }

.upload-icon { width: 32px; height: 32px; color: var(--accent-purple); }

/* Sample Pills */
.sample-label { font-size: 11px; font-weight: 700; color: var(--text-muted); }

.sample-pills-row { display: flex; flex-direction: column; gap: 6px; }

.sample-pill-btn {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
  transition: border-color 0.15s ease;
}

.sample-pill-btn:hover { border-color: var(--border-active); }

/* SFX Grid */
.sfx-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sfx-card {
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
  min-height: 80px;
}

.sfx-card:hover {
  border-color: var(--accent-pink);
  background: rgba(236, 72, 153, 0.1);
}

.sfx-emoji { font-size: 22px; }

/* Save Summary */
.save-summary-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.summary-line span { color: var(--text-muted); }

.save-progress-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.progress-bar-bg {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--grad-primary);
  border-radius: var(--radius-full);
  transition: width 0.1s linear;
}

.save-completed-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#finalVideoPlayer {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-sm);
  background: #000;
}

.success-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-green);
  font-weight: 700;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.vc-toast {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background-color: var(--bg-toast);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-toast);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  color: var(--text-toast);
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 14px rgba(139, 92, 246, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 2000;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.vc-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --------------------------------------------------------------------------
   Timeline Focus Mode (expands timeline, shrinks player)
   -------------------------------------------------------------------------- */
.vc-main-stage.timeline-focused .stage-player-section {
  padding: 4px 8px 2px !important;
}

.vc-main-stage.timeline-focused .player-wrapper {
  max-width: min(calc(12dvh * (16 / 9)), 100%) !important;
}

.vc-main-stage.timeline-focused .player-wrapper.ratio-9-16 {
  max-width: min(calc(12dvh * (9 / 16)), 100%) !important;
}

.vc-main-stage.timeline-focused .player-wrapper.ratio-1-1 {
  max-width: min(12dvh, 100%) !important;
}

.vc-main-stage.timeline-focused .player-empty-state {
  display: none !important;
}

.vc-main-stage.timeline-focused .player-bar {
  margin-top: 2px !important;
  padding: 2px 8px !important;
  transform: scale(0.9);
}

.vc-main-stage.timeline-focused .stage-timeline-section {
  flex: 1 1 0 !important;
}

/* --------------------------------------------------------------------------
   Responsive Breakpoints (Mobile, Zoom & Height Resilience)
   -------------------------------------------------------------------------- */

/* Tablets and large screens */
@media (max-width: 768px) {
  .stage-timeline-section {
    padding: 6px 6px 8px;
    gap: 4px;
  }
  .timeline-scroll-box {
    padding: 6px 4px 10px;
  }
  .timeline-aligned-tracks {
    padding: 4px 6px 14px;
  }
}

/* Mobile Screens (≤ 580px - All phones like iPhone 12-16, Galaxy S21-S24, Pixel) */
@media (max-width: 580px) {
  :root {
    --topbar-h: 46px;
    --dock-primary-h: 50px;
    --dock-tab-h: 20px;
  }

  .vc-topbar {
    padding: 0 6px;
    gap: 4px;
  }

  .brand-name {
    font-size: clamp(14px, 4vw, 17px);
  }

  .topbar-right {
    gap: 4px;
  }

  /* In mobile: Hide text in ratio picker, show clean icon pill */
  #labelRatio {
    display: none !important;
  }

  .btn-pill#btnRatioPicker {
    padding: 5px 8px;
    min-width: 32px;
    justify-content: center;
  }

  .btn-save {
    padding: 5px 10px;
    font-size: 11.5px;
  }

  .btn-icon {
    width: 30px;
    height: 30px;
  }

  /* Compact player section */
  .stage-player-section {
    padding: 4px 6px 3px;
  }

  .player-bar {
    margin-top: 4px;
    padding: 3px 8px;
    gap: 4px;
  }

  /* Compact timeline */
  .stage-timeline-section {
    padding: 4px 5px 6px;
    gap: 3px;
  }

  .timeline-toolbar-bar {
    padding: 0 2px 2px;
    gap: 4px;
  }

  .zoom-slider {
    width: 44px;
  }

  /* Shorten status pill on mobile so Pop Out button always has room */
  .timeline-status-pill {
    max-width: 105px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 2px 6px;
    font-size: 9px;
  }

  .btn-timeline-focus {
    padding: 2px 7px;
    font-size: 9.5px;
  }

  .timeline-scroll-box {
    padding: 4px 3px 8px;
  }

  .timeline-aligned-tracks {
    padding: 4px 4px 12px;
  }

  .timeline-track-block {
    margin-bottom: 3px;
  }

  .track-label-bar {
    padding: 2px 5px 2px 4px;
    gap: 4px;
    min-height: 26px;
    font-size: 10.5px;
  }

  .btn-add-track-item {
    padding: 2px 5px;
    font-size: 9px;
  }

  /* Dock compact */
  .dock-drawer-tab {
    height: var(--dock-tab-h);
    font-size: 10px;
  }

  .dock-primary-bar {
    padding: 2px 2px;
  }

  .dock-btn {
    font-size: 9px;
  }

  .dock-icon {
    width: 18px;
    height: 18px;
  }

  .popup-body {
    padding: 12px 14px;
    gap: 10px;
  }

  .popup-header {
    padding: 12px 14px 10px;
  }
}

/* Very small phones (≤ 400px - iPhone SE, small viewports, high zoom) */
@media (max-width: 400px) {
  .timeline-status-pill {
    display: none !important;
  }

  .brand-name {
    font-size: 15px;
  }

  .dock-btn {
    font-size: 8px;
  }

  .dock-icon {
    width: 16px;
    height: 16px;
  }

  .drawer-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Height-Constrained Resilience (Browser Zoom e.g. 150-200%, Landscape Phones, Split Screen) */
@media (max-height: 640px) {
  :root {
    --dock-primary-h: 46px;
    --dock-tab-h: 18px;
    --topbar-h: 44px;
  }

  .stage-player-section {
    padding: 2px 6px 2px !important;
  }

  .player-wrapper {
    max-width: min(calc(24dvh * (16 / 9)), 100%) !important;
  }

  .player-wrapper.ratio-9-16 {
    max-width: min(calc(24dvh * (9 / 16)), 100%) !important;
  }

  .player-wrapper.ratio-1-1 {
    max-width: min(24dvh, 100%) !important;
  }

  .player-wrapper.ratio-4-5 {
    max-width: min(calc(24dvh * (4 / 5)), 100%) !important;
  }

  .player-bar {
    margin-top: 3px !important;
    padding: 2px 8px !important;
    transform: scale(0.9);
  }

  .stage-timeline-section {
    padding: 2px 5px 3px !important;
    gap: 2px !important;
  }
}

@media (max-height: 500px) {
  :root {
    --dock-primary-h: 42px;
    --dock-tab-h: 16px;
    --topbar-h: 40px;
  }

  .stage-player-section {
    padding: 1px 4px 1px !important;
  }

  .player-wrapper {
    max-width: min(calc(20dvh * (16 / 9)), 100%) !important;
  }

  .player-wrapper.ratio-9-16 {
    max-width: min(calc(20dvh * (9 / 16)), 100%) !important;
  }

  .player-wrapper.ratio-1-1 {
    max-width: min(20dvh, 100%) !important;
  }

  .player-wrapper.ratio-4-5 {
    max-width: min(calc(20dvh * (4 / 5)), 100%) !important;
  }
}

/* Larger tablet / desktop */
@media (min-width: 768px) {
  .drawer-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* --------------------------------------------------------------------------
   Wave & Volume Envelope Studio
   -------------------------------------------------------------------------- */
.track-label-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-track-action-pill {
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.25);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.3;
  min-height: 24px;
}

.btn-track-action-pill:hover {
  background: rgba(56, 189, 248, 0.24);
  transform: translateY(-1px);
}

.btn-track-action-pill:active { transform: translateY(0); }

.shape-glyph {
  font-size: 13px;
  margin-right: 4px;
  display: inline-block;
  opacity: 0.9;
}

/* Wave Studio Popup */
.popup-wide .popup-box {
  max-width: 820px;
  width: 95vw;
}

.wave-studio-box {
  background: var(--bg-modal);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-medium);
}

.wave-studio-canvas-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.wave-canvas-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.wave-clock-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(56, 189, 248, 0.2);
}

.wave-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
  animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.wave-hint-text { font-size: 11px; color: var(--text-muted); }

.wave-canvas-viewport {
  position: relative;
  width: 100%;
  height: 220px;
  background: #090a10;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}

#waveEditorCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.wave-needle-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ec4899;
  box-shadow: 0 0 10px #ec4899;
  pointer-events: none;
  z-index: 5;
  transform: translateX(-50%);
}

.wave-needle-line::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  background: #ec4899;
  border-radius: 50%;
  box-shadow: 0 0 8px #ec4899;
}

.wave-tooltip-bubble {
  position: absolute;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--accent-cyan);
  color: #f8fafc;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -125%);
  white-space: nowrap;
}

.wave-timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  font-family: monospace;
  padding: 0 4px;
}

.wave-node-control-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
  gap: 8px;
}

.node-info-text { font-size: 12px; color: var(--text-muted); }

.node-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sm-curve {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 34px;
}

.btn-sm-curve:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-sm-curve.btn-delete-node:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.btn-sm-curve:disabled { opacity: 0.35; cursor: not-allowed; }

.curve-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.curve-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all 0.18s ease;
  color: var(--text-main);
  min-height: 80px;
}

.curve-preset-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--accent-purple);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.2);
}

.curve-preset-btn strong { font-size: 12px; margin-top: 4px; }
.curve-preset-btn small { font-size: 10px; color: var(--text-muted); }
.preset-emoji { font-size: 18px; }

.wave-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.btn-preview-envelope {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid var(--accent-purple);
  color: #c4b5fd;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.18s ease;
  min-height: 46px;
}

.btn-preview-envelope:hover {
  background: rgba(139, 92, 246, 0.32);
  transform: translateY(-1px);
}

.btn-preview-envelope.playing {
  background: #ec4899;
  border-color: #ec4899;
  color: #fff;
  box-shadow: 0 0 18px rgba(236, 72, 153, 0.4);
}

/* Export Dropdowns */
#selectExportResolution,
#selectExportFps {
  background-color: #181829 !important;
  color: #ffffff !important;
}

#selectExportResolution option,
#selectExportFps option {
  background-color: #181829 !important;
  color: #ffffff !important;
}

/* Badge Mini */
.badge-mini {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(139, 92, 246, 0.28);
  color: var(--accent-purple);
  white-space: nowrap;
}

/* Popout Animation */
@keyframes popoutSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}


/* ==========================================================================
   VibeCut — Comprehensive Light Theme Mode Overrides
   ========================================================================== */
[data-theme="light"] body {
  background-color: #f1f5f9;
  color: #0f172a;
}

/* Brand Name in Light Mode */
[data-theme="light"] .brand-name {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
}

/* Empty State in Light Mode */
[data-theme="light"] .player-empty-state {
  background: #ffffff !important;
  color: #0f172a !important;
}

[data-theme="light"] .empty-state-card {
  background: rgba(139, 92, 246, 0.04) !important;
  border-color: rgba(124, 58, 237, 0.35) !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06) !important;
}

[data-theme="light"] .empty-title {
  color: #0f172a !important;
}

[data-theme="light"] .empty-description {
  color: #475569 !important;
}

[data-theme="light"] .empty-hints {
  color: #64748b !important;
}

/* Dropdown Menu in Light Mode */
[data-theme="light"] .vc-dropdown-menu {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.16) !important;
}

[data-theme="light"] .menu-item {
  color: #0f172a !important;
}

[data-theme="light"] .menu-item:hover {
  background: #f1f5f9 !important;
}

[data-theme="light"] .menu-section-label {
  color: #64748b !important;
}

[data-theme="light"] .menu-divider {
  background: rgba(0, 0, 0, 0.08) !important;
}

/* Toast in Light Mode */
:root[data-theme="light"] .vc-toast,
html[data-theme="light"] .vc-toast,
[data-theme="light"] #vcToast,
[data-theme="light"] .vc-toast {
  background: rgba(255, 255, 255, 0.98) !important;
  background-color: rgba(255, 255, 255, 0.98) !important;
  color: #0f172a !important;
  border-color: rgba(139, 92, 246, 0.45) !important;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 0 12px rgba(139, 92, 246, 0.2) !important;
}

/* Timeline Studio Popped Out in Light Mode */
[data-theme="light"] .timeline-popout-header {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .popout-header-title {
  color: #0f172a !important;
}

[data-theme="light"] .popout-header-subtitle {
  color: #64748b !important;
}

[data-theme="light"] .popout-time-tag {
  color: #6d28d9 !important;
  background: rgba(139, 92, 246, 0.1) !important;
  border-color: rgba(139, 92, 246, 0.25) !important;
}

[data-theme="light"] .btn-popout-done {
  background: rgba(16, 185, 129, 0.14) !important;
  border-color: rgba(16, 185, 129, 0.35) !important;
  color: #047857 !important;
}

[data-theme="light"] .btn-popout-close {
  background: #f1f5f9 !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #475569 !important;
}

[data-theme="light"] .btn-popout-close:hover {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
  color: #dc2626 !important;
}

/* Timeline Toolbar, Ruler, Ticks & Labels in Light Mode */
[data-theme="light"] .timeline-scroll-box {
  background: rgba(0, 0, 0, 0.02) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent !important;
}

[data-theme="light"] .timeline-scroll-box::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18) !important;
}

[data-theme="light"] .ruler-tick.major {
  background: rgba(0, 0, 0, 0.28) !important;
}

[data-theme="light"] .ruler-tick {
  background: rgba(0, 0, 0, 0.1) !important;
}

[data-theme="light"] .ruler-label {
  color: #64748b !important;
}

[data-theme="light"] .track-label-bar {
  background: rgba(255, 255, 255, 0.95) !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.06) !important;
  color: #0f172a !important;
}

[data-theme="light"] .track-label-title {
  color: #0f172a !important;
}

[data-theme="light"] .timeline-status-pill {
  background: rgba(124, 58, 237, 0.1) !important;
  border-color: rgba(124, 58, 237, 0.25) !important;
  color: #6d28d9 !important;
}

[data-theme="light"] .btn-timeline-focus {
  background: rgba(124, 58, 237, 0.1) !important;
  border-color: rgba(124, 58, 237, 0.25) !important;
  color: #6d28d9 !important;
}

[data-theme="light"] .btn-timeline-focus:hover,
[data-theme="light"] .btn-timeline-focus.active {
  background: #7c3aed !important;
  color: #ffffff !important;
}

[data-theme="light"] .zoom-btn {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #0f172a !important;
}

[data-theme="light"] .zoom-label {
  color: #475569 !important;
}

/* Player Bar in Light Mode */
[data-theme="light"] .player-bar {
  background: rgba(255, 255, 255, 0.94) !important;
  border-color: rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .btn-player:hover,
[data-theme="light"] .btn-player.active {
  color: #0f172a !important;
  background: rgba(0, 0, 0, 0.06) !important;
}

[data-theme="light"] .player-time-display {
  color: #0f172a !important;
}

[data-theme="light"] .time-cur {
  color: #0f172a !important;
}

[data-theme="light"] .time-dur {
  color: #64748b !important;
}

[data-theme="light"] .speed-badge {
  background: #f1f5f9 !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #0f172a !important;
}

/* Action Dock in Light Mode */
[data-theme="light"] .dock-btn:hover {
  background: rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] .dock-drawer-tab {
  background: rgba(241, 245, 249, 0.95) !important;
  color: #475569 !important;
}

[data-theme="light"] .dock-drawer-tab:hover {
  background: rgba(124, 58, 237, 0.08) !important;
  color: #7c3aed !important;
}

[data-theme="light"] .dock-btn.highlight-sound { color: #0284c7 !important; }
[data-theme="light"] .dock-btn.highlight-sound:hover { background: rgba(2, 132, 199, 0.08) !important; }
[data-theme="light"] .dock-btn.danger { color: #dc2626 !important; }
[data-theme="light"] .dock-btn.danger:hover { background: rgba(220, 38, 38, 0.08) !important; }
[data-theme="light"] .dock-btn.highlight-overlay { color: #059669 !important; }
[data-theme="light"] .dock-btn.highlight-overlay:hover { background: rgba(5, 150, 105, 0.08) !important; }
[data-theme="light"] .dock-btn.highlight-sfx { color: #0284c7 !important; }
[data-theme="light"] .dock-btn.highlight-sfx:hover { background: rgba(2, 132, 199, 0.08) !important; }
[data-theme="light"] .dock-btn.highlight-magic { color: #db2777 !important; }
[data-theme="light"] .dock-btn.highlight-magic:hover { background: rgba(219, 39, 119, 0.08) !important; }

/* Modals & Popups in Light Mode */
[data-theme="light"] .popup-box {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.14) !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.16) !important;
}

[data-theme="light"] .popup-header {
  border-color: rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .popup-footer {
  border-color: rgba(0, 0, 0, 0.08) !important;
}

[data-theme="light"] .btn-secondary {
  background: #f1f5f9 !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #0f172a !important;
}

[data-theme="light"] .btn-secondary:hover {
  background: #e2e8f0 !important;
}

[data-theme="light"] .quick-ratio-card {
  background: #ffffff !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
}

[data-theme="light"] .quick-ratio-card.active {
  border-color: var(--accent-purple) !important;
  background: rgba(139, 92, 246, 0.08) !important;
}

[data-theme="light"] .ratio-title {
  color: #0f172a !important;
}

[data-theme="light"] .form-input,
[data-theme="light"] .select-input {
  background: #f8fafc !important;
  border-color: rgba(0, 0, 0, 0.14) !important;
  color: #0f172a !important;
}
