/* ═══════════════════════════════════════════════
   MPEG Studio – Editor de Vídeo
   Premium Dark Theme
═══════════════════════════════════════════════ */

/* ─── Tokens ─── */
:root {
  --bg-base: #0a0b0f;
  --bg-surface: #111318;
  --bg-panel: #13151c;
  --bg-elevated: #1a1d28;
  --bg-hover: #1f2233;

  --accent: #7c5ff5;
  --accent-light: #a78bfa;
  --accent-glow: rgba(124, 95, 245, 0.3);
  --cyan: #22d3ee;
  --cyan-glow: rgba(34, 211, 238, 0.2);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;

  --text-primary: #f0f0f8;
  --text-secondary: #9ca3b8;
  --text-muted: #4b5268;
  --border: rgba(255, 255, 255, 0.07);
  --border-bright: rgba(255, 255, 255, 0.14);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.8);

  --topbar-h: 52px;
  --toolbar-h: 44px;
  --playback-h: 56px;
  --timeline-h: 220px;
  --panel-left-w: 260px;
  --panel-right-w: 260px;
  --panel-right-actual: var(--panel-right-w);
  --panel-left-actual: var(--panel-left-w);
  --track-label-w: 110px;
  --track-h: 48px;
}

/* ─── Reset ─── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  user-select: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
}

input,
select,
textarea {
  font: inherit;
  color: inherit;
}

input[type="range"] {
  cursor: pointer;
}

select {
  cursor: pointer;
}

/* ─── Scrollbars ─── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #2a2d3e;
  border-radius: 3px;
}

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

/* ═══ TOP BAR ═══ */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  color: var(--text-secondary);
  padding-right: 16px;
  border-right: 1px solid var(--border);
}

.logo strong {
  color: var(--text-primary);
}

.menu-tabs {
  display: flex;
  gap: 2px;
}

.tab {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.2s;
}

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

.tab.active {
  color: var(--accent-light);
  background: rgba(124, 95, 245, 0.15);
}

.project-name {
  font-size: 12.5px;
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: all 0.2s;
  outline: none;
  min-width: 120px;
  text-align: center;
}

.project-name:focus {
  border-color: var(--accent);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-icon.active {
  background: rgba(124, 95, 245, 0.2);
  color: var(--accent-light);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #5b3fd4 100%);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.2s;
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 24px var(--accent-glow);
}

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-bright);
}

.btn-secondary.full-width {
  width: 100%;
  justify-content: center;
}

/* ═══ EDITOR LAYOUT ═══ */
.editor-layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--panel-left-actual) 1fr var(--panel-right-actual);
  min-height: 0;
  overflow: hidden;
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.editor-layout.hide-right {
  --panel-right-actual: 0px;
}

.editor-layout.hide-right .panel-right {
  display: none;
}

.editor-layout.hide-left {
  --panel-left-actual: 0px;
}

.editor-layout.hide-left .panel-left {
  display: none;
}

/* ═══ PANELS ═══ */
.panel-left,
.panel-right {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-right {
  border-right: none;
  border-left: 1px solid var(--border);
}

.panel-header {
  padding: 14px 14px 10px;
  flex-shrink: 0;
}

.panel-header h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.panel-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.ptab {
  flex: 1;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
}

.ptab:hover {
  color: var(--text-secondary);
}

.ptab.active {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Drop Zone */
.drop-zone {
  margin: 0 10px 10px;
  padding: 18px 12px;
  border: 2px dashed var(--border-bright);
  border-radius: var(--radius-md);
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  flex-shrink: 0;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(124, 95, 245, 0.06);
}

.drop-zone.drag-over {
  transform: scale(1.01);
}

.drop-icon svg {
  stroke: var(--text-muted);
  margin-bottom: 8px;
}

.drop-zone p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.drop-zone p span {
  color: var(--text-secondary);
}

.link-label {
  color: var(--accent-light);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Media list */
.media-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.media-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: grab;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.media-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.2s;
}

.media-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-bright);
}

.media-item:hover::before {
  background: var(--accent);
}

.media-item.selected {
  border-color: var(--accent);
  background: rgba(124, 95, 245, 0.1);
}

.media-item.selected::before {
  background: var(--accent);
}

.media-thumb {
  width: 44px;
  height: 36px;
  border-radius: 5px;
  background: var(--bg-base);
  overflow: hidden;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-thumb canvas {
  width: 100%;
  height: 100%;
}

.media-thumb svg {
  opacity: 0.4;
}

.media-info {
  flex: 1;
  min-width: 0;
}

.media-name {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.media-type-badge {
  font-size: 9px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.badge-video {
  background: rgba(124, 95, 245, 0.2);
  color: var(--accent-light);
}

.badge-photo {
  background: rgba(34, 211, 238, 0.15);
  color: var(--cyan);
}

.badge-audio {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.panel-bottom {
  padding: 10px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

/* ═══ CENTER PANEL ═══ */
.panel-center {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  overflow: hidden;
}

/* Toolbar */
.toolbar {
  height: var(--toolbar-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 4px;
  flex-shrink: 0;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px;
  border-right: 1px solid var(--border);
}

.tool-group:last-child {
  border-right: none;
}

.tool-group.spacer {
  flex: 1;
  justify-content: center;
  border-right: none;
}

.tool-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 0.18s;
}

.tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tool-btn.active {
  background: rgba(124, 95, 245, 0.2);
  color: var(--accent-light);
}

.time-display {
  font-family: 'Outfit', 'Inter', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px var(--cyan-glow);
}

.time-sep {
  color: var(--text-muted);
  margin: 0 6px;
  font-weight: 400;
  font-size: 14px;
}

.time-display.dim {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 400;
  text-shadow: none;
}

.zoom-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 6px;
}

.zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  outline: none;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  cursor: pointer;
}

.zoom-val {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
  min-width: 36px;
}

/* Preview */
.preview-container {
  flex: 1;
  display: grid;
  place-items: center;
  background: #080a10;
  overflow: hidden;
  position: relative;
}

.preview-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(124, 95, 245, 0.05) 0%, transparent 65%),
    radial-gradient(ellipse at 80% 80%, rgba(34, 211, 238, 0.04) 0%, transparent 50%);
  pointer-events: none;
}

.preview-canvas-wrapper {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16/9;
  width: min(100%, calc((100vh - var(--topbar-h) - var(--toolbar-h) - var(--playback-h) - var(--timeline-h) - 20px) * 16 / 9));
}

#preview-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
}

.preview-overlay-items {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.empty-preview {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(10, 11, 15, 0.8);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.empty-preview .empty-icon svg {
  stroke: var(--text-muted);
}

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

.empty-preview span {
  color: var(--text-muted);
  font-size: 12px;
}

/* Playback controls */
.playback-controls {
  height: var(--playback-h);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 16px;
  flex-shrink: 0;
}

.ctrl-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all 0.18s;
}

.ctrl-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.play-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #5b3fd4);
  color: #fff !important;
  box-shadow: 0 0 20px var(--accent-glow);
  transition: all 0.2s;
}

.play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 30px var(--accent-glow);
}

.ctrl-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 70px;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
}

.speed-select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-secondary);
  outline: none;
}

.speed-select:hover {
  border-color: var(--border-bright);
}

/* ═══ PROPERTIES PANEL ═══ */
.props-content {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
}

.props-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0.35;
}

.props-empty svg {
  stroke: var(--text-muted);
}

.props-empty p {
  font-size: 12px;
  text-align: center;
  color: var(--text-muted);
}

/* Property groups */
.prop-group {
  margin-bottom: 16px;
}

.prop-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.prop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.prop-label {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 70px;
  flex-shrink: 0;
}

.prop-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.prop-input:focus {
  border-color: var(--accent);
}

.prop-slider {
  width: 100%;
}

/* ═══ TIMELINE ═══ */
.timeline-section {
  height: var(--timeline-h);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.timeline-header {
  height: 28px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tl-left-pad {
  width: var(--track-label-w);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
}

.tl-btn {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--text-muted);
  transition: all 0.18s;
}

.tl-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tl-ruler {
  flex: 1;
  height: 100%;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.ruler-canvas {
  height: 100%;
}

/* Timeline body */
.timeline-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.track-labels {
  width: var(--track-label-w);
  flex-shrink: 0;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.track-label {
  height: var(--track-h);
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
  gap: 8px;
}

.track-label-icon svg {
  stroke: var(--text-muted);
  flex-shrink: 0;
}

.track-label-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-mute {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 10px;
  transition: all 0.15s;
}

.track-mute:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.track-mute.active {
  background: var(--danger);
  color: #fff;
}

.tracks-area {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  position: relative;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.08) 0.5px, transparent 0.5px) 
      0 0 / var(--tl-cell-dot, 20px) 100%,
    repeating-linear-gradient(to right,
      transparent 0,
      transparent calc(var(--tl-cell, 100px) - 1.5px),
      rgba(255, 255, 255, 0.15) calc(var(--tl-cell, 100px) - 1.5px),
      rgba(255, 255, 255, 0.15) var(--tl-cell, 100px));
}

.tl-track {
  height: var(--track-h);
  position: relative;
  border-bottom: 1px solid var(--border);
}

/* Clips */
.tl-clip {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  min-width: 20px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  user-select: none;
  border: 1px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.tl-clip.video-clip {
  background: linear-gradient(135deg, rgba(124, 95, 245, 0.6), rgba(90, 64, 200, 0.4));
  border-color: rgba(124, 95, 245, 0.4);
}

.tl-clip.photo-clip {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.5), rgba(14, 165, 233, 0.35));
  border-color: rgba(34, 211, 238, 0.4);
}

.tl-clip.audio-clip {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.5), rgba(22, 163, 74, 0.35));
  border-color: rgba(34, 197, 94, 0.4);
}

.tl-clip.text-clip {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.5), rgba(217, 119, 6, 0.35));
  border-color: rgba(245, 158, 11, 0.4);
}

.tl-clip:hover {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.tl-clip.selected {
  border-color: rgba(255, 255, 255, 0.5) !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.clip-label {
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.clip-thumb-bg {
  position: absolute;
  inset: 0;
  opacity: 0.15;
}

.clip-thumb-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.clip-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.15s;
  z-index: 2;
}

.clip-handle:hover {
  background: rgba(255, 255, 255, 0.4);
}

.clip-handle-left {
  left: 0;
  border-radius: 6px 0 0 6px;
}

.clip-handle-right {
  right: 0;
  border-radius: 0 6px 6px 0;
}

/* Playhead */
.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  left: 0;
  z-index: 50;
  pointer-events: none;
}

.playhead-head {
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--cyan);
  line-height: 1;
}

.playhead-readout {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--cyan);
  color: #000;
  font-family: 'Outfit', 'Inter', monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
  box-shadow: 0 2px 10px var(--cyan-glow);
  z-index: 100;
  pointer-events: none;
}

.playhead-line {
  position: absolute;
  top: 8px;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1.5px;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan-glow);
}

/* ═══ MODALS ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  z-index: 999;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
  overflow: hidden;
}

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

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  transition: all 0.18s;
}

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

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-group.half {
  flex: 1;
}

.form-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-control {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

.form-control:focus {
  border-color: var(--accent);
}

select.form-control option {
  background: var(--bg-panel);
}

.color-input {
  height: 36px;
  padding: 4px;
  cursor: pointer;
}

.export-info {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(34, 211, 238, 0.06);
  border: 1px solid rgba(34, 211, 238, 0.15);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.export-info svg {
  stroke: var(--cyan);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ═══ TOAST ═══ */
.toast-container {
  position: fixed;
  bottom: calc(var(--timeline-h) + 12px);
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  color: var(--text-primary);
  animation: slideLeft 0.25s ease;
  max-width: 300px;
  backdrop-filter: blur(8px);
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.info {
  border-left: 3px solid var(--accent-light);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast-fade {
  animation: fadeOutRight 0.3s ease forwards;
}

/* Context menu */
.context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 900;
  min-width: 170px;
  animation: fadeIn 0.12s ease;
}

.ctx-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: left;
  transition: all 0.15s;
}

.ctx-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.ctx-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ═══ KEYFRAMES ═══ */
/* Vault Modal Specifics */
.large-modal {
  width: 720px;
  height: 600px;
  display: flex;
  flex-direction: column;
}

.large-modal .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Vault filters tabs */
.vault-filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.vtab {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s;
}

.vtab:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
}

.vtab.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.vault-filters {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  padding-bottom: 20px;
}

.vault-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  display: flex;
  flex-direction: column;
}

.vault-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--bg-hover);
  box-shadow: var(--shadow-md);
}

.vault-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.vault-item.selected::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--accent);
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: bold;
}

.vault-thumb {
  aspect-ratio: 16 / 10;
  background: #000;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.vault-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vault-thumb svg {
  opacity: 0.3;
}

.vault-info {
  padding: 8px 10px;
}

.vault-name {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.vault-meta {
  font-size: 9px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

@keyframes slideUp {
  from {
    transform: translateY(12px);
    opacity: 0
  }

  to {
    transform: translateY(0);
    opacity: 1
  }
}

@keyframes slideLeft {
  from {
    transform: translateX(16px);
    opacity: 0
  }

  to {
    transform: translateX(0);
    opacity: 1
  }
}

@keyframes fadeOutRight {
  from {
    transform: translateX(0);
    opacity: 1
  }

  to {
    transform: translateX(24px);
    opacity: 0
  }
}

/* ═══ PROGRESS BAR (export) ═══ */
.export-progress {
  height: 4px;
  background: var(--bg-base);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.export-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  border-radius: 2px;
  transition: width 0.25s;
  animation: shimmer 1.5s infinite linear;
  background-size: 200% 100%;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0
  }

  100% {
    background-position: -200% 0
  }
}

/* ═══ RESIZE HANDLE ═══ */
.resize-x {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  z-index: 10;
}

/* ═══ PHOTO FRAME in preview ═══ */
.photo-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* ═══ Waveform placeholder ═══ */
.waveform-inner {
  display: flex;
  align-items: center;
  gap: 1px;
  height: 20px;
  padding: 0 4px;
  opacity: 0.5;
  pointer-events: none;
  position: absolute;
  inset: 0;
  justify-content: center;
}

.wf-bar {
  width: 2px;
  background: currentColor;
  border-radius: 1px;
}

/* --- Topbar sep --- */
.topbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
  flex-shrink: 0;
}

/* --- Subtitle clip --- */
.tl-clip.subtitle-clip {
  background: linear-gradient(135deg, rgba(249, 115, 22, .5), rgba(234, 88, 12, .35));
  border-color: rgba(249, 115, 22, .4);
}

/* --- Prop section tabs --- */
.prop-section-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 12px;
}

.prop-section-tab {
  flex: 1;
  padding: 5px 4px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  transition: all .18s;
  text-align: center;
}

.prop-section-tab:hover {
  color: var(--text-secondary);
}

.prop-section-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* --- Filter sliders --- */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.filter-label {
  font-size: 10px;
  color: var(--text-muted);
  min-width: 55px;
  flex-shrink: 0;
}

.filter-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  outline: none;
}

.filter-slider.brightness {
  background: linear-gradient(90deg, #1a1a2e, #ffec99);
}

.filter-slider.contrast {
  background: linear-gradient(90deg, #555, #fff);
}

.filter-slider.saturation {
  background: linear-gradient(90deg, #888, #f87171);
}

.filter-slider.hue {
  background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}

.filter-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(0, 0, 0, .5);
}

.filter-val {
  font-size: 10px;
  color: var(--text-muted);
  min-width: 28px;
  text-align: right;
}

.btn-filter-reset {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  margin-top: 4px;
}

.btn-filter-reset:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

/* --- Toggle switch --- */
.kb-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.kb-toggle-label {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
}

.toggle-switch {
  position: relative;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-base);
  border-radius: 9px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all .2s;
}

.toggle-switch input:checked+.toggle-slider {
  background: rgba(124, 95, 245, .3);
  border-color: var(--accent);
}

.toggle-switch input:checked+.toggle-slider::before {
  transform: translateX(16px);
  background: var(--accent-light);
}

.kb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.kb-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kb-field label {
  font-size: 10px;
  color: var(--text-muted);
}

.kb-field input {
  width: 100%;
}

/* --- Transition selectors --- */
.trans-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.trans-label {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 50px;
}

.trans-select {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
}

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

.trans-dur {
  width: 50px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text-primary);
  outline: none;
}

select.trans-select option {
  background: var(--bg-panel);
}

/* --- Audio vol --- */
.vol-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vol-icon {
  color: var(--success);
  flex-shrink: 0;
}

.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  outline: none;
}

.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--success);
  cursor: pointer;
  border: 2px solid var(--bg-panel);
}

/* --- Clip decorators --- */
.trans-in-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(to top right, rgba(255, 255, 255, 0.25) 50%, transparent 50%);
  pointer-events: none;
  border-radius: 4px 0 0 4px;
  z-index: 1;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.trans-out-bar {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(to top left, rgba(255, 255, 255, 0.25) 50%, transparent 50%);
  pointer-events: none;
  border-radius: 0 4px 4px 0;
  z-index: 1;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.tl-clip.kb-active::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 18px;
  font-size: 9px;
  color: var(--cyan);
  opacity: .8;
  pointer-events: none;
}

.clip-missing-badge {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 9px;
  background: var(--danger);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  z-index: 3;
  color: #fff;
}

/* DB List */
.db-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
}

.db-project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.db-project-item:hover {
  border-color: var(--accent);
  background: rgba(167, 139, 250, 0.1);
}

.db-project-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.db-project-name {
  font-weight: 600;
  color: var(--text-primary);
}

.db-project-date {
  font-size: 11px;
  color: var(--text-muted);
}

.db-project-actions {
  display: flex;
  gap: 8px;
}

.btn-delete-db {
  padding: 6px;
  border-radius: 4px;
  color: var(--danger);
  opacity: 0.6;
}

.btn-delete-db:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.1);
}

/* Final UI Polish */
.panel-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.panel-header-top h3 {
  margin-bottom: 0 !important;
}

.btn-import-library {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-light);
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(124, 95, 245, 0.08);
  border: 1px solid rgba(124, 95, 245, 0.1);
  transition: all 0.2s;
  cursor: pointer;
}

.btn-import-library:hover {
  background: rgba(124, 95, 245, 0.15);
  transform: translateY(-1px);
}

.btn-import-library svg {
  stroke: currentColor;
}