* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Warm, cozy, cute palette */
  --bg-main: #fff4e6; /* Cozy warm cream */
  --bg-panel: #ffffff;
  --bg-dark: #4a3f35;
  
  /* Neubrutalism relies on strong, dark borders. We use dark brown for cuteness */
  --border: #4a3f35;
  --border-dark: #2d2424;
  
  --text-primary: #4a3f35;
  --text-secondary: #7a6a5d;
  --text-muted: #b8aba0;
  
  /* Cute Bubblegum Pink Accent */
  --accent: #ff8fab; 
  --accent-hover: #ff7597;
  --accent-light: #ffe5ec;
  
  --danger: #ff5c5c;
  --warning: #ffb703;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* ========== MAIN LAYOUT ========== */
.editor-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.editor-main {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0; /* Important for flex children */
}

/* ========== LEFT PANEL - VIDEO PREVIEW ========== */
.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  min-width: 0;
  min-height: 0; /* Important for flex children */
  overflow: hidden;
}

.preview-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px; 
  
  /* Cute warm cream background with brown dots */
  background-color: var(--bg-main);
  background-image: radial-gradient(var(--text-muted) 2px, transparent 2px);
  background-size: 30px 30px;
  
  min-height: 0; 
  overflow: hidden;
}

.video-frame {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  /* Softer, cleaner shadow for the light theme */
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.15), 0 4px 10px -5px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 0, 0, 0.05);
  max-width: 100%;
  max-height: 100%;
}

.video-background {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.video-window {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  /* Force GPU compositing for buttery smooth zooms */
  will-change: transform;
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.video-window video {
  /* DO NOT USE display: none; It puts the video decoder to sleep! */
  position: absolute;
  opacity: 0.001; /* Invisible to user, but Chrome thinks it's visible */
  width: 1px;
  height: 1px;
  pointer-events: none;
  z-index: -1;
}

.video-window canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px;
  background: rgba(74, 63, 53, 0.04) !important; /* Soft, shaded warm tint */
  border-radius: 20px !important;
  border: 3px dashed rgba(74, 63, 53, 0.25) !important; /* Cute dashed border */
}

.empty-state-icon {
  font-size: 56px;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 800 !important;
  color: var(--text-primary) !important; /* Dark text instead of white */
}

.empty-state p {
  color: var(--text-secondary) !important;
  font-size: 14px;
  font-weight: 500 !important;
}

.load-buttons {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* ========== TIMELINE TOOLBAR - CURSORFLY STYLE ========== */
.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0; /* Don't shrink the toolbar */
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 8px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-panel);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.toolbar-btn:hover {
  background: var(--bg-main);
  border-color: var(--border-dark);
  transform: translateY(-1px);
}

.toolbar-btn:active {
  transform: translateY(0);
}

.toolbar-btn.primary-action {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.toolbar-btn.primary-action:hover {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.toolbar-btn.icon-only {
  padding: 8px;
  width: 36px;
  height: 36px;
}

.toolbar-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.zoom-count-badge {
  padding: 6px 12px;
  background: var(--accent-light);
  color: var(--accent-hover);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* ========== SIMPLE TIMELINE WITH TRIM HANDLES ========== */
.timeline-container.simple-timeline {
  background: #f5f5f5;
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  flex-shrink: 0;
}

.simple-timeline .timeline-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.simple-timeline .play-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #4ade80;
  border: none;
  border-radius: 50%;
  color: #000;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.simple-timeline .play-btn:hover {
  background: #22c55e;
  transform: translateY(-1px);
}

.simple-timeline .play-btn svg {
  width: 14px;
  height: 14px;
  margin-left: 2px;
}

.simple-timeline .time-display {
  font-size: 13px;
  font-family: 'Courier New', monospace;
  color: var(--text-primary);
  flex-shrink: 0;
}

.simple-timeline .time-display .current,
.simple-timeline .time-display .current-ms {
  color: var(--text-primary);
  font-weight: 600;
}

.simple-timeline .time-display .time-separator {
  color: var(--text-muted);
  font-weight: 400;
}

.simple-timeline .reset-btn {
  margin-left: auto;
  padding: 6px 12px;
  font-size: 12px;
  gap: 6px;
  background: #666;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.simple-timeline .reset-btn:hover {
  background: #555;
}

.simple-timeline .reset-btn svg {
  width: 12px;
  height: 12px;
}

/* Timeline container */
.timeline-container-inner {
  position: relative;
  height: 80px;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
}
.clip-track {
  position: absolute;
  top: 18px;
  left: 10px;
  right: 10px;
  height: 18px;
  z-index: 8;
}
.clip-segment {
  position: absolute;
  top: 0;
  height: 18px;
  border-radius: 999px;
  border: 1.5px solid #4a3f35;
  background: linear-gradient(135deg, #ffe4ee 0%, #ff9db8 100%);
  color: #4a3f35;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(74, 63, 53, 0.18);
  user-select: none;
  overflow: hidden;
  white-space: nowrap;
  transition: left 160ms cubic-bezier(0.2, 0.8, 0.2, 1), width 160ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 120ms ease, box-shadow 120ms ease, filter 120ms ease, background 120ms ease;
}
.clip-segment.placeholder {
  background: rgba(74, 63, 53, 0.08);
  border: 1.5px dashed rgba(74, 63, 53, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.5);
}
.clip-segment.selected {
  background: linear-gradient(135deg, #4a3f35 0%, #2d2424 100%);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 143, 171, 0.28), 0 3px 0 rgba(74, 63, 53, 0.2);
  transform: translateY(-1px);
}
.clip-segment:hover {
  filter: saturate(1.08);
  transform: translateY(-1px);
}
.clip-segment.dragging {
  opacity: 0.7;
  transform: scale(0.98);
  cursor: grabbing;
}
.clip-segment.dragging-floating {
  position: absolute !important;
  top: 0 !important;
  z-index: 20 !important;
  pointer-events: none;
  transform: translateX(-50%) scale(1.02);
  box-shadow: 0 12px 24px rgba(74, 63, 53, 0.18), 0 3px 0 rgba(74, 63, 53, 0.18);
}
.clip-segment .clip-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
}
.clip-segment .clip-handle.left { left: 0; }
.clip-segment .clip-handle.right { right: 0; }
.clip-segment .clip-grip {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.8);
  box-shadow: 0 0 0 1px rgba(74,63,53,0.18);
}
/* Zoom Track & Segments */
.zoom-track {
  position: absolute;
  top: 40px; /* Below playhead timeline */
  left: 0;
  right: 0;
  height: 28px;
  z-index: 10;
}
.zoom-segment {
  position: absolute;
  top: 2px;
  height: 24px;
  background: #f3f4f6; /* Grey default */
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: all 0.15s;
  z-index: 1;
  overflow: hidden; 
  min-width: 16px;
}
.zoom-segment.selected {
  background: #d1fae5; /* Green when selected */
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  z-index: 2; /* Brings active segment to front */
}
.zoom-segment:active { cursor: grabbing; }

.zoom-segment-label {
  font-size: 11px;
  color: #6b7280; /* Grey text default */
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  pointer-events: none;
}
.zoom-segment.selected .zoom-segment-label {
  color: #065f46; /* Green text when selected */
}
.zoom-segment-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  cursor: ew-resize;
  border-radius: 4px;
}
.zoom-segment-handle:hover { background: rgba(5, 150, 105, 0.1); }
.left-handle { left: 0; }
.right-handle { right: 0; }

/* Zoom Properties Popup */
.zoom-popup {
  position: absolute;
  right: 24px;
  top: 80px;
  width: 280px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  z-index: 1000;
  padding: 16px;
}
.zoom-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.zoom-popup-header h4 { font-size: 15px; font-weight: 600; }
.zoom-popup-close { background: #f3f4f6; border: none; font-size: 16px; width: 24px; height: 24px; border-radius: 4px; cursor: pointer; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.zoom-popup-close:hover { background: #e5e7eb; color: var(--text-primary); }
.zoom-popup-section { margin-bottom: 16px; }
.zoom-popup-section:last-child { margin-bottom: 0; }
.zoom-popup-section label { display: block; font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.zoom-toggle-group { display: flex; background: #f3f4f6; padding: 4px; border-radius: 8px; gap: 4px; }
.zoom-toggle-btn { flex: 1; padding: 6px; border: none; background: transparent; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--text-secondary); cursor: pointer; transition: 0.15s; }
.zoom-toggle-btn.active { background: white; color: var(--text-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.zoom-toggle-btn[data-type="segment"].active { background: #d1fae5; color: #059669; }
.depth-control { display: flex; gap: 12px; align-items: center; }

.timeline {
  position: relative;
  height: 100%;
  width: 100%;
}

.time-markers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 16px;
  display: flex;
  justify-content: space-between;
  padding: 0 40px;
}

.time-marker {
  position: relative;
  font-size: 9px;
  color: #666;
  font-weight: 500;
}

.time-marker::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 4px;
  background: #ddd;
}

/* =========================================
   1. TIMELINE CONTAINER & SPILL FIXES
   ========================================= */
.timeline-container-inner {
  overflow: visible !important; /* Prevents playhead/handles from getting chopped off */
}

.clip-track, .zoom-track, .blur-track {
  /* Chops off horizontal bleed, but allows vertical drop shadows to show! */
  clip-path: inset(-30px 0px -30px 0px) !important;
}

.clip-segment {
  /* Removed 'left' and 'width' transitions to stop clips from sliding & overlapping when split */
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease, background 120ms ease !important;
  min-width: 16px !important; /* Keeps tiny clips clickable */
}


/* =========================================
   2. TRIM HANDLES (Full-Height End Caps)
   ========================================= */
.trim-handle {
  position: absolute;
  top: -3px; 
  bottom: -3px; 
  width: 26px; 
  /* A cozy, warm pastel peach/cream color that perfectly matches your palette */
  background: #ffe3d4 !important; 
  border: 3px solid var(--border) !important;
  z-index: 30; 
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  padding: 0 !important;
  /* Removed the transition so the color stays perfectly solid */
}

/* Left Handle */
.trim-handle-left {
  left: 0; /* REMOVED !important so Javascript can drag it */
  transform: translateX(-100%);
  border-radius: 12px 0 0 12px !important;
  border-right: none !important; 
}

/* Right Handle */
.trim-handle-right {
  right: 0; /* REMOVED !important so Javascript can drag it */
  left: auto; /* REMOVED !important so Javascript can drag it */
  transform: translateX(100%);
  border-radius: 0 12px 12px 0 !important;
  border-left: none !important; 
}

/* The solid cut-line edge that touches the active video area */
.trim-handle-left::after {
  content: ''; position: absolute; right: 0; top: 0; bottom: 0;
  width: 3px; background: var(--border);
}

.trim-handle-right::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--border);
}


/* Scissor Icon & Grips */
.trim-handle .scissor-icon {
  position: static !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  width: 100% !important;
  height: auto !important;
  border-radius: 0 !important;
  transform: none !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px; 
}

.trim-handle .scissor-icon svg {
  width: 14px !important;
  height: 14px !important;
  fill: var(--text-primary) !important;
}

.trim-handle .scissor-icon::before,
.trim-handle .scissor-icon::after {
  content: '';
  display: block;
  width: 10px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  opacity: 0.6;
}

/* Hide floating labels */
.trim-label { display: none !important; }


/* =========================================
   3. GRAY TRIMMED ZONES
   ========================================= */
.trimmed-area {
  z-index: 29;
  background: repeating-linear-gradient(
    45deg,
    rgba(74, 63, 53, 0.08),
    rgba(74, 63, 53, 0.08) 10px,
    rgba(74, 63, 53, 0.15) 10px,
    rgba(74, 63, 53, 0.15) 20px
  ) !important;
}

.trimmed-left {
  border-right: none !important;
  border-top-left-radius: 9px !important;
  border-bottom-left-radius: 9px !important;
}

.trimmed-right {
  border-left: none !important;
  border-top-right-radius: 9px !important;
  border-bottom-right-radius: 9px !important;
}
/* =========================================
   FIX HANDLE CLIPPING & WHITE SPACE GAPS
   ========================================= */

/* 1. Give the timeline wrapper more horizontal padding so the handles don't hit the screen edges */
.timeline-container.simple-timeline {
  padding: 16px 40px !important; 
}

/* 2. Stretch the tracks completely to the edges to eliminate the white gap */
.clip-track, .zoom-track, .blur-track {
  left: 0 !important;
  right: 0 !important;
}

/* 3. Align the time markers so they clear the thick rounded borders */
.time-markers {
  padding: 0 12px !important; 
}

/* Ensure the first and last timestamps don't shift their text out of bounds */
.time-marker:first-child {
  transform: translateX(2px);
}
.time-marker:last-child {
  transform: translateX(-2px);
}


.playhead {
  position: absolute;
  top: 0; /* Changed from 16px to 0 for full vertical span */
  bottom: 0;
  width: 2px;
  background: #4ade80;
  z-index: 15; /* Increased to stay above handles */
  pointer-events: none;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.playhead::before {
  content: '';
  position: absolute;
  top: 0; /* Align perfectly with the top edge */
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 8px solid #4ade80;
}



/* Timeline track */
.simple-timeline .timeline-track {
  position: absolute;
  top: 0; /* Full height */
  left: 0; /* Removed 40px left */
  right: 0; /* Removed 40px right */
  bottom: 0;
  cursor: pointer;
  z-index: 1; /* Keep it underneath the draggable handles */
}

/* Playhead */
.simple-timeline .timeline-playhead {
  position: absolute;
  top: 16px;
  bottom: 0;
  width: 2px;
  background: #4ade80;
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}

.simple-timeline .timeline-playhead::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #ef4444;
}

/* ========== RIGHT SIDEBAR ========== */
.sidebar {
  width: 320px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Scrollable sidebar content */
.sidebar-content-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Section divider */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.export-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  margin-bottom: 0;
}

.export-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.export-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Panel sections */
.panel-section {
  margin-bottom: 24px;
}

.panel-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Aspect ratio dropdown */
.aspect-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: all 0.15s;
}

.aspect-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Background options */
.bg-tabs {
  display: flex;
  background: var(--bg-main);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
}

.bg-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.bg-tab:hover {
  color: var(--text-primary);
}

.bg-tab.active {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.bg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.bg-option {
  aspect-ratio: 1;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s, box-shadow 0.1s;
  background-size: cover;
  background-position: center;
}

.bg-option:hover {
  transform: scale(1.05);
}

.bg-option.selected {
  border-color: #ffffff; 
  box-shadow: 0 0 0 2px var(--accent); 
  transform: scale(0.95);
}

.bg-upload {
  background: var(--bg-main);
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 20px;
}

.bg-upload:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Color picker grid */
.color-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-option {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.color-option:hover {
  transform: scale(1.15);
}

.color-option.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--bg-panel);
}

/* Settings rows */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 14px;
  color: var(--text-primary);
}

.setting-select {
  padding: 8px 12px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  min-width: 130px;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-main);
  border: 1px solid var(--border);
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent);
  border-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
  background-color: white;
}

/* Modal Styles */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-panel);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 420px;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover:not(:disabled) {
  background: var(--bg-main);
  color: var(--text-primary);
}

.modal-close:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.modal-body {
  padding: 24px;
}

.export-option {
  margin-bottom: 20px;
}

.export-option:last-child {
  margin-bottom: 0;
}

.export-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.export-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

.export-select:focus {
  border-color: var(--accent);
}

.export-info {
  background: var(--bg-main);
  padding: 12px 16px;
  border-radius: 10px;
  margin-top: 20px;
}

.export-info span {
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.btn-secondary {
  padding: 10px 20px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: white;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

.setting-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--border);
  border-radius: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.setting-toggle.active {
  background: var(--accent);
}

.setting-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.setting-toggle.active::after {
  left: 25px;
}

/* Buttons */
.btn {
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: var(--bg-main);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 16px;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
}

.hidden {
  display: none !important;
}

/* Gradient backgrounds */
.bg-grad-1 { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.bg-grad-2 { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.bg-grad-3 { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.bg-grad-4 { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.bg-grad-5 { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }
.bg-grad-6 { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); }
.bg-grad-7 { background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); }
.bg-grad-8 { background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%); }
.bg-grad-9 { background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); }
.bg-grad-10 { background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%); }
.bg-grad-11 { background: linear-gradient(135deg, #fccb90 0%, #d57eeb 100%); }
.bg-grad-12 { background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%); }

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* =========================================
   NEUBRUTALISM THEME OVERRIDES
   ========================================= */

/* 1. Hard Borders & Flat Shadows for all UI Elements */
.btn, .toolbar-btn, .export-btn, .setting-select, .aspect-select, 
.toggle-slider, .zoom-popup, .bg-option, .color-option, .export-select, 
.zoom-segment, .play-btn {
  border: 2px solid var(--border) !important;
  box-shadow: 3px 3px 0px var(--border) !important;
  border-radius: 8px !important;
  transition: transform 0.1s ease, box-shadow 0.1s ease !important;
}

/* Remove background images from buttons, but LEAVE the .bg-option gradients alone! */
.btn, .toolbar-btn, .export-btn, .setting-select, .aspect-select, 
.toggle-slider, .export-select, .play-btn {
  background-image: none !important; 
}

/* 2. Interactive Bouncy Click Effects */
.btn:active, .toolbar-btn:active, .export-btn:active, 
.bg-option:active, .zoom-popup-close:active, .play-btn:active {
  transform: translate(3px, 3px) !important;
  box-shadow: 0px 0px 0px var(--border) !important;
}

.btn:hover, .export-btn:hover {
  transform: translate(-2px, -2px) !important;
  box-shadow: 5px 5px 0px var(--border) !important;
}

/* 3. Primary Buttons & Accent Colors */
.btn-primary, .export-btn, .toolbar-btn.primary-action {
  background: var(--accent) !important;
  color: var(--border) !important;
  font-weight: 800 !important;
  letter-spacing: 0.5px;
}

/* 4. Toggles & Selects */
.toggle-slider:before {
  border: 2px solid var(--border);
  background-color: white;
  box-shadow: 1px 1px 0px var(--border);
}
.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent) !important;
}

/* 5. Structural Borders */
.sidebar { 
  border-left: 3px solid var(--border) !important; 
}
.timeline-container.simple-timeline { 
  border-top: 3px solid var(--border) !important; 
  background: white !important; 
}

/* 6. Video Frame & Popups (Thicker shadows for big elements) */
/* 6. Video Frame & Popups */
.video-frame {
  /* Clean, realistic shadow so users know this border is NOT exported */
  border: 1px solid rgba(0, 0, 0, 0.05) !important;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
  border-radius: 12px !important;
}

.zoom-popup {
  box-shadow: 6px 6px 0px var(--border) !important;
  border-width: 3px !important;
}

/* 7. Cute Zoom Segments */
.zoom-segment {
  background: #bde0fe !important; /* Cute baby blue default */
  box-shadow: 2px 2px 0px var(--border) !important;
  border-radius: 6px !important;
}
.zoom-segment.selected {
  background: var(--accent-light) !important;
  border-color: var(--border) !important;
  box-shadow: 4px 4px 0px var(--border) !important;
}
.zoom-segment-label {
  color: var(--text-primary) !important;
  font-weight: 800 !important;
}

/* 8. Tabs in Popups */
.zoom-toggle-btn.active {
  border: 2px solid var(--border);
  box-shadow: 2px 2px 0px var(--border);
  background: var(--accent-light) !important;
  color: var(--text-primary) !important;
  font-weight: 700;
}

/* =========================================
   9. CUTE TIMELINE & CONTROLS POLISH
   ========================================= */

/* Fix the Toolbar Button Alignment & Shapes */
#addSegmentBtn, #deleteSegmentBtn {
  height: 36px;
  background: white !important;
  color: var(--text-primary) !important;
}

#deleteSegmentBtn:disabled {
  background: #e5e7eb !important;
  box-shadow: 0px 0px 0px var(--border) !important;
  transform: translate(3px, 3px) !important; /* Keep it pressed down */
  border-color: var(--text-muted) !important;
}

/* Fix the Play Button (Make it a cute square) */
.simple-timeline .play-btn {
  width: 40px !important;
  height: 40px !important;
  border-radius: 8px !important;
  background: var(--accent) !important;
  color: var(--border) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Cute Time Display Tag */
.simple-timeline .time-display {
  background: white;
  border: 2px solid var(--border);
  box-shadow: 3px 3px 0px var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 13px;
  color: var(--text-primary);
  margin-left: 12px;
}

/* Fix the Reset Button */
.simple-timeline .reset-btn {
  background: white !important;
  color: var(--text-primary) !important;
  border: 2px solid var(--border) !important;
  box-shadow: 3px 3px 0px var(--border) !important;
  border-radius: 8px !important;
  font-weight: 700 !important;
  height: 36px;
  margin-left: auto; /* Pushes it to the right correctly */
}

/* Big Bouncy Timeline Track */
.timeline-container-inner {
  border: 3px solid var(--border) !important;
  box-shadow: 6px 6px 0px var(--border) !important;
  border-radius: 12px !important;
  background: #ffffff !important;
  margin-top: 12px;
  height: 110px !important; /* INCREASED: Fits 2 tracks perfectly! */
}
/* ADDED: Second Track for Blurs */
.blur-track {
  position: absolute;
  top: 72px; /* Sits right underneath the zoom track */
  left: 0;
  right: 0;
  height: 28px;
  z-index: 10;
}

/* Cute Playhead (Replaces the old green triangle with a pink circle) */
.playhead {
  background: var(--accent) !important;
  width: 4px !important;
  margin-left: -2px !important; /* Centers it perfectly */
  border-left: 1px solid var(--border) !important;
  border-right: 1px solid var(--border) !important;
  box-shadow: none !important;
  z-index: 25 !important;
}
.playhead::before {
  content: '' !important;
  position: absolute !important;
  top: -6px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  width: 14px !important;
  height: 14px !important;
  background: var(--accent) !important;
  border: 2px solid var(--border) !important;
  border-radius: 50% !important; /* Cute circle */
  box-sizing: border-box !important;
}

/* Neubrutalist Scissors */
.scissor-icon {
  background: var(--accent-light) !important;
  border: 2px solid var(--border) !important;
  box-shadow: 2px 2px 0px var(--border) !important;
  border-radius: 6px !important;
  width: 26px !important; 
  height: 26px !important;
}
.scissor-icon svg {
  fill: var(--text-primary) !important;
}



/* =========================================
   10. DRAGGABLE TARGET PICKER UI
   ========================================= */
.target-picker-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg-dark);
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: crosshair;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.1);
}

#targetPickerCanvas {
  width: 100%;
  height: 100%;
  /* Stretches safely to match our 0 to 1 coordinate math */
  display: block; 
}

.target-picker-box {
  position: absolute;
  width: 40%;
  height: 40%;
  border: 2px solid var(--danger);
  background: rgba(255, 92, 92, 0.2);
  transform: translate(-50%, -50%);
  pointer-events: none; /* Let the container handle mouse tracking */
  display: flex;
  align-items: center;
  justify-content: center;
  /* Darkens everything outside the red box like a spotlight! */
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5); 
}

.target-picker-bullseye {
  width: 16px;
  height: 16px;
  border: 3px solid var(--danger);
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
/* =========================================
   11. ROTATO-STYLE DEVICE MOCKUPS
   ========================================= */

/* The 3D Perspective Wrapper */
.is-3d-tilt {
  transform: perspective(1500px) rotateY(-24deg) rotateX(15deg) rotateZ(4deg) !important;
  transform-style: preserve-3d;
  box-shadow: -20px 40px 60px rgba(0,0,0,0.3) !important;
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* MacBook Pro Frame */
.mockup-macbook {
  border: 1.5vw solid #1a1a1a !important;
  border-bottom: 2.2vw solid #1a1a1a !important;
  border-radius: 1vw !important;
  background: #000;
}
.mockup-macbook::after {
  content: '';
  position: absolute;
  bottom: -2.2vw;
  left: 50%;
  transform: translateX(-50%);
  width: 15%;
  height: 0.4vw;
  background: #333;
  border-radius: 1vw;
  z-index: 5;
}

/* Smartphone Frame */
.mockup-iphone {
  border: 1.2vw solid #111111 !important;
  border-radius: 2vw !important;
  background: #000;
}
.mockup-iphone::after {
  content: '';
  position: absolute;
  /* Dynamic Island Notch */
  top: -1.2vw;
  left: 50%;
  transform: translateX(-50%);
  width: 25%;
  height: 1.5vw;
  background: #000;
  border-radius: 1vw;
  z-index: 5;
}
/* =========================================
   12. RENDER OVERLAY UI
   ========================================= */
.render-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background-color: var(--bg-main);
  background-image: radial-gradient(var(--text-muted) 2px, transparent 2px);
  background-size: 30px 30px;
  z-index: 9999999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.export-card {
  background: #ffffff;
  border: 3px solid var(--border);
  box-shadow: 8px 8px 0px var(--border);
  border-radius: 12px;
  /* INCREASED padding for more height, and max-width for more width */
  padding: 56px 48px;
  width: 100%;
  max-width: 750px; 
  text-align: center;
}
.export-card h1 { margin-top: 0; font-weight: 800; font-size: 28px; }
.status-text { font-size: 16px; font-weight: 700; margin-bottom: 20px; color: var(--text-secondary); }
.progress-container {
  width: 100%; height: 30px; background: #f3f4f6; border: 3px solid var(--border);
  border-radius: 8px; overflow: hidden; margin-bottom: 20px; position: relative;
}
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-right: 3px solid var(--border); transition: width 0.2s ease; }
.progress-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-weight: 800; font-size: 14px; color: var(--text-primary); }
.button-group { display: flex; gap: 16px; justify-content: center; }
.btn-bug { background: #ffb703; color: var(--text-primary); }
.btn-download { background: #10b981; color: white; border-color: #065f46; box-shadow: 4px 4px 0px #065f46 !important;}
/* Clean, cute hover state for the Back to Editor button */
#backToEditorBtn {
  background: #ffffff !important;
  color: var(--text-primary) !important;
}

#backToEditorBtn:hover {
  background: var(--accent-light) !important; /* Cute light pink on hover! */
  color: var(--text-primary) !important;
}

/* =========================================
   13. SMART BLUR & DROPDOWN UI
   ========================================= */
.segment-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; background: white;
  border: 3px solid var(--border); box-shadow: 4px 4px 0px var(--border);
  border-radius: 8px; display: flex; flex-direction: column; z-index: 1000;
  min-width: 160px; padding: 6px; gap: 4px;
}
.segment-dropdown button {
  background: transparent; border: none; font-weight: 700; color: var(--text-primary);
  text-align: left; padding: 10px 12px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; gap: 8px; transition: 0.1s;
}
.segment-dropdown button:hover { background: var(--bg-main); transform: translateX(2px); }

/* Purple Blur Segments */
.zoom-segment[data-type="blur"] { background: #e0c3fc !important; border-color: #b185db !important; }
.zoom-segment[data-type="blur"].selected { background: #d57eeb !important; border-color: var(--border) !important; box-shadow: 4px 4px 0px var(--border) !important; }
.zoom-segment[data-type="blur"] .zoom-segment-label { color: #5a189a !important; }

/* =========================================
   14. PRO BADGES & LICENSE UI
   ========================================= */
.pro-badge {
  background: var(--warning);
  color: var(--text-primary);
  font-size: 10px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  border: 1.5px solid var(--border);
  box-shadow: 2px 2px 0px var(--border);
  vertical-align: middle;
  display: inline-block;
  letter-spacing: 0.5px;
}

/* Locked state for Pro features */
.pro-locked {
  opacity: 0.6;
  cursor: pointer !important;
}
.pro-locked * {
  pointer-events: none; /* Forces the click to hit the wrapper so we can show the modal */
}

/* Unlock Pro Button in Sidebar */
.btn-unlock {
  width: 100%;
  background: var(--warning) !important;
  color: var(--text-primary) !important;
  margin-bottom: 16px;
  font-size: 15px !important;
  font-weight: bold;
  animation: gentleBounce 2s infinite;
}

@keyframes gentleBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); box-shadow: 6px 6px 0px var(--border) !important; }
}

/* License Input Box */
.license-input {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  font-family: monospace;
  border: 3px solid var(--border);
  border-radius: 8px;
  background: var(--bg-main);
  color: var(--text-primary);
  margin-top: 16px;
  margin-bottom: 16px;
  text-align: center;
  box-shadow: inset 2px 2px 0px rgba(0,0,0,0.05);
}
.license-input:focus { outline: none; border-color: var(--accent); }

/* Fix Cancel/Secondary Buttons turning dark on hover */
.btn-secondary, #closeLicenseModal, #cancelExport {
  background: #ffffff !important;
  color: var(--text-primary) !important;
  border-color: var(--text-primary) !important;
}

.btn-secondary:hover, #closeLicenseModal:hover, #cancelExport:hover {
  background: var(--bg-main) !important; /* Gentle cream color on hover */
  color: var(--text-primary) !important;
}
.color-grid-small {
  grid-template-columns: repeat(6, 1fr); /* 6 small cubes per row */
  gap: 6px;
}
.color-grid-small .bg-option {
  border-width: 1.5px !important;
  box-shadow: 1.5px 1.5px 0px var(--border) !important;
  border-radius: 4px !important;
}
.color-grid-small .bg-option:hover {
  transform: scale(1.15) !important;
}
/* =========================================
   15. VOLUME SLIDER UI
   ========================================= */
.volume-slider {
  appearance: none; 
  -webkit-appearance: none;
  width: 70px;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  outline: none;
  border: 1.5px solid var(--border) !important;
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1) !important;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--border);
  cursor: pointer;
  box-shadow: 1.5px 1.5px 0px var(--border);
  transition: transform 0.1s;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.volume-slider:disabled::-webkit-slider-thumb {
  background: #cbd5e1;
  cursor: not-allowed;
  box-shadow: none;
}

#muteBtn {
  transition: transform 0.15s;
}

#muteBtn:hover {
  transform: scale(1.1);
}

#muteBtn:active {
  transform: scale(0.95);
}
/* =========================================
   16. LICENSE MODAL LINKS
   ========================================= */
#forgotLicenseLink:hover {
  color: var(--text-primary) !important;
}


/* =========================================
   17. SUPPORT MODAL LINKS
   ========================================= */
.support-link {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
}

.support-link:hover {
  color: var(--accent);
  text-decoration: underline;
  transform: translateY(-1px);
}