/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body { -webkit-font-smoothing: antialiased; }

::selection { background: rgba(99,102,241,0.35); color: #fff; }

/* ===== Scrollbar ===== */
.custom-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
.custom-scroll::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ===== Topbar buttons ===== */
.topbar-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  color: #a1a1aa; transition: all .15s;
}
.topbar-btn:hover { background: rgba(255,255,255,0.06); color: #e4e4e7; }

/* ===== Mode switcher ===== */
.mode-btn { width: 96px; justify-content: center; }

/* ===== Left tabs ===== */
.left-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 34px; font-size: 11px; font-weight: 500; color: #71717a;
  border-bottom: 2px solid transparent; transition: all .15s;
}
.left-tab:hover { color: #d4d4d8; background: rgba(255,255,255,0.02); }
.left-tab.active { color: #a5b4fc; border-bottom-color: #6366f1; background: rgba(99,102,241,0.06); }

/* ===== Filter chips ===== */
.filter-chip {
  font-size: 10px; font-weight: 500; padding: 3px 8px; border-radius: 999px;
  background: rgba(255,255,255,0.04); color: #a1a1aa; border: 1px solid rgba(255,255,255,0.05);
  transition: all .15s;
}
.filter-chip:hover { background: rgba(255,255,255,0.08); color: #e4e4e7; }
.filter-chip.active { background: rgba(99,102,241,0.18); color: #a5b4fc; border-color: rgba(99,102,241,0.4); }

/* ===== Media grid items ===== */
.media-item {
  position: relative; aspect-ratio: 16/10; border-radius: 8px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06); cursor: pointer; transition: all .2s;
  background: #16161a;
}
.media-item:hover { border-color: rgba(99,102,241,0.5); transform: translateY(-1px); box-shadow: 0 8px 20px -8px rgba(99,102,241,0.4); }
.media-item img { width: 100%; height: 100%; object-fit: cover; }
.media-item .mi-overlay {
  position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.85), transparent 60%);
  display: flex; flex-direction: column; justify-content: flex-end; padding: 6px;
}
.media-item .mi-name { font-size: 10px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-item .mi-meta { font-size: 8.5px; color: #a1a1aa; font-family: 'JetBrains Mono', monospace; }
.media-item .mi-badge {
  position: absolute; top: 5px; left: 5px; font-size: 8px; font-weight: 700; padding: 1px 4px;
  border-radius: 3px; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); color: #fff;
}
.media-item .mi-badge.ai { background: rgba(99,102,241,0.7); }
.media-item .mi-duration {
  position: absolute; top: 5px; right: 5px; font-size: 8px; font-weight: 600; padding: 1px 4px;
  border-radius: 3px; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); color: #fff; font-family: 'JetBrains Mono', monospace;
}

/* ===== AI tool items ===== */
.ai-tool-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px;
  transition: all .15s;
}
.ai-tool-item:hover { background: rgba(255,255,255,0.04); }

/* ===== Effect presets ===== */
.effect-preset {
  position: relative; height: 44px; border-radius: 6px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06); cursor: pointer; transition: all .15s;
}
.effect-preset:hover { border-color: rgba(99,102,241,0.5); transform: translateY(-1px); }
.effect-preset .ep-label {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 2px 5px;
  font-size: 9px; font-weight: 600; color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
}
.effect-preset.selected { border-color: #6366f1; box-shadow: 0 0 0 1px #6366f1; }

/* ===== Transition items ===== */
.trans-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04);
  cursor: pointer; transition: all .15s;
}
.trans-item:hover { background: rgba(255,255,255,0.05); border-color: rgba(99,102,241,0.3); }
.trans-item .trans-icon { width: 26px; height: 18px; border-radius: 3px; background: linear-gradient(135deg, #3a3a46, #2c2c36); position: relative; flex-shrink: 0; }
.trans-item .trans-name { font-size: 11px; color: #d4d4d8; }
.trans-item .trans-dur { font-size: 9px; color: #71717a; font-family: monospace; margin-left: auto; }

/* ===== Monitor pills ===== */
.monitor-pill {
  display: flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px;
  border-radius: 5px; font-size: 10px; font-weight: 500; color: #a1a1aa;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.04);
  transition: all .15s;
}
.monitor-pill:hover { background: rgba(255,255,255,0.07); color: #e4e4e7; }
.monitor-pill.active { background: rgba(99,102,241,0.15); color: #a5b4fc; border-color: rgba(99,102,241,0.4); }

/* ===== Transport buttons ===== */
.transport-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; color: #a1a1aa; transition: all .15s;
}
.transport-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.transport-btn.active { background: rgba(99,102,241,0.18); color: #a5b4fc; }

/* ===== Inspector ===== */
.inspector-section { border-bottom: 1px solid rgba(255,255,255,0.04); }
.inspector-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; cursor: pointer; user-select: none; transition: background .15s;
}
.inspector-header:hover { background: rgba(255,255,255,0.02); }
.inspector-body { animation: slideDown .2s ease; }
.inspector-section.collapsed .inspector-body { display: none; }
.inspector-section.collapsed .chev { transform: rotate(-90deg); }
.chev { transition: transform .2s; }

@keyframes slideDown { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.param-cell {
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); border-radius: 6px;
}
.param-cell span { font-size: 10px; color: #71717a; font-weight: 600; min-width: 12px; }
.param-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-size: 11px; color: #e4e4e7; font-family: 'JetBrains Mono', monospace; text-align: right;
}

.slider-row { display: flex; align-items: center; gap: 8px; }
.slider-label { font-size: 10px; color: #a1a1aa; min-width: 56px; }
.slider-value { font-size: 10px; color: #d4d4d8; font-family: 'JetBrains Mono', monospace; min-width: 36px; text-align: right; }

/* ===== Range slider ===== */
.range-slider {
  -webkit-appearance: none; appearance: none; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.1); outline: none; cursor: pointer;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: #e4e4e7; cursor: pointer; box-shadow: 0 0 0 2px rgba(99,102,241,0); transition: box-shadow .15s;
}
.range-slider::-webkit-slider-thumb:hover { box-shadow: 0 0 0 4px rgba(99,102,241,0.25); }
.range-slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: #e4e4e7; border: none; cursor: pointer;
}
.range-slider.warm { background: linear-gradient(to right, #3b82f6, #f59e0b); }

/* ===== AI toggles ===== */
.ai-toggle {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  background: rgba(255,255,255,0.02); cursor: pointer; transition: all .15s;
}
.ai-toggle:hover { background: rgba(255,255,255,0.05); }
.ai-toggle span { font-size: 11px; color: #d4d4d8; flex: 1; }
.ai-toggle input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 28px; height: 16px; border-radius: 999px;
  background: rgba(255,255,255,0.12); position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0;
}
.ai-toggle input[type="checkbox"]::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; transition: transform .2s;
}
.ai-toggle input[type="checkbox"]:checked { background: linear-gradient(to right, #6366f1, #a78bfa); }
.ai-toggle input[type="checkbox"]:checked::after { transform: translateX(12px); }

/* ===== Anchor dots ===== */
.anchor-dot { width: 6px; height: 6px; border-radius: 2px; background: rgba(255,255,255,0.15); }
.anchor-dot.active { background: #6366f1; }
.anchor-dot:hover { background: rgba(255,255,255,0.4); }

/* ===== Effect stack ===== */
.effect-stack-item {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 6px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05);
  font-size: 11px; color: #d4d4d8;
}
.effect-stack-item:hover { background: rgba(255,255,255,0.06); }

/* ===== Timeline tools ===== */
.tl-tool {
  display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 5px;
  color: #71717a; transition: all .15s;
}
.tl-tool:hover { background: rgba(255,255,255,0.06); color: #e4e4e7; }
.tl-tool.active { background: rgba(99,102,241,0.18); color: #a5b4fc; }
.tl-action {
  display: flex; align-items: center; gap: 4px; height: 26px; padding: 0 8px; border-radius: 5px;
  font-size: 10.5px; font-weight: 500; color: #a1a1aa; transition: all .15s;
}
.tl-action:hover { background: rgba(255,255,255,0.06); color: #e4e4e7; }

/* ===== Track headers ===== */
.track-header {
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.track-header.audio { background: rgba(34,211,238,0.02); }
.track-header.text { background: rgba(167,139,250,0.02); }
.track-label { font-size: 10px; font-weight: 700; color: #a1a1aa; min-width: 22px; font-family: 'JetBrains Mono', monospace; }
.track-controls { display: flex; gap: 2px; }
.tc-btn {
  display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 4px;
  color: #52525b; transition: all .15s;
}
.tc-btn:hover { background: rgba(255,255,255,0.06); color: #d4d4d8; }

/* ===== Track rows ===== */
.track-row {
  position: relative; height: 36px; border-bottom: 1px solid rgba(255,255,255,0.04);
  background-image: repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(255,255,255,0.015) 39px, rgba(255,255,255,0.015) 40px);
}
.track-row.audio { background-color: rgba(34,211,238,0.015); }
.track-row.text { background-color: rgba(167,139,250,0.015); height: 30px; }

/* ===== Clips ===== */
.clip {
  position: absolute; top: 4px; bottom: 4px; border-radius: 5px; overflow: hidden;
  cursor: pointer; transition: all .15s; border: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center;
}
.clip:hover { filter: brightness(1.15); transform: translateY(-1px); z: 5; }
.clip.selected { border-color: #818cf8; box-shadow: 0 0 0 1px #818cf8, 0 4px 14px -4px rgba(99,102,241,0.6); z: 6; }

.clip-video { background: linear-gradient(135deg, #1e3a5f, #0f1d33); }
.clip-broll { background: linear-gradient(135deg, #3d2a4d, #1f1429); }
.clip-audio { background: #16242b; }
.clip-audio.dialogue { background: linear-gradient(135deg, #1a3d3a, #0f2622); }
.clip-audio.music { background: linear-gradient(135deg, #2a1f3d, #16121f); }
.clip-text { background: linear-gradient(135deg, #3d2a4d, #251535); justify-content: center; }

.clip-thumb {
  position: absolute; inset: 0; background-size: cover; background-position: center;
  opacity: 0.55; mix-blend-mode: lighten;
}
.clip-video .clip-thumb, .clip-broll .clip-thumb { opacity: 0.65; }

.clip-label {
  position: relative; z-index: 2; font-size: 9.5px; font-weight: 600; color: #e4e4e7;
  padding: 0 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.clip-text .clip-label { font-size: 9px; color: #ddd6fe; }

.clip-badge {
  position: absolute; top: 3px; right: 4px; font-size: 7.5px; font-weight: 700; padding: 1px 4px;
  border-radius: 3px; background: rgba(0,0,0,0.5); color: #fff; font-family: monospace;
}
.clip-badge.ai { background: rgba(99,102,241,0.8); }

/* ===== Waveform ===== */
.waveform {
  position: absolute; inset: 0; display: flex; align-items: center; gap: 1px; padding: 0 4px;
  opacity: 0.7;
}
.waveform .wf-bar {
  flex: 1; min-width: 1px; background: linear-gradient(to top, #22d3ee, #0891b2); border-radius: 1px;
}
.waveform.dense .wf-bar { background: linear-gradient(to top, #a78bfa, #7c3aed); }

/* ===== Generator: prompt chips ===== */
.prompt-chip {
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
  background: rgba(99,102,241,0.1); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.2);
  transition: all .15s;
}
.prompt-chip:hover { background: rgba(99,102,241,0.2); }

/* ===== Style presets ===== */
.style-card {
  position: relative; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden;
  border: 1.5px solid rgba(255,255,255,0.06); cursor: pointer; transition: all .2s;
}
.style-card:hover { border-color: rgba(99,102,241,0.5); transform: translateY(-2px); }
.style-card.selected { border-color: #818cf8; box-shadow: 0 0 0 1px #818cf8, 0 8px 20px -6px rgba(99,102,241,0.5); }
.style-card .sc-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.style-card .sc-overlay {
  position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.9), transparent 65%);
}
.style-card .sc-label {
  position: absolute; bottom: 5px; left: 7px; right: 7px; font-size: 10px; font-weight: 600; color: #fff;
  display: flex; align-items: center; justify-content: space-between;
}
.style-card .sc-check {
  position: absolute; top: 5px; right: 5px; width: 16px; height: 16px; border-radius: 50%;
  background: #6366f1; display: none; align-items: center; justify-content: center;
}
.style-card.selected .sc-check { display: flex; }

/* ===== Reference thumbnails ===== */
.ref-thumb {
  aspect-ratio: 1; border-radius: 6px; background-size: cover; background-position: center;
  border: 1px solid rgba(255,255,255,0.08); cursor: pointer; transition: all .15s;
}
.ref-thumb:hover { border-color: rgba(99,102,241,0.5); transform: scale(1.05); }
.ref-add { aspect-ratio: 1; }

/* ===== Model options ===== */
.model-opt {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 10px;
  border-radius: 7px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05);
  cursor: pointer; transition: all .15s;
}
.model-opt:hover { background: rgba(255,255,255,0.05); }
.model-opt.active { background: rgba(99,102,241,0.1); border-color: rgba(99,102,241,0.4); }

/* ===== Ratio / segmented options ===== */
.ratio-opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 44px; border-radius: 6px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05);
  cursor: pointer; transition: all .15s;
}
.ratio-opt:hover { background: rgba(255,255,255,0.06); }
.ratio-opt.active { background: rgba(99,102,241,0.15); border-color: rgba(99,102,241,0.4); }
.ratio-opt span { font-size: 9px; color: #a1a1aa; font-weight: 600; }
.ratio-opt.active span { color: #a5b4fc; }
.ar-bar { background: #71717a; border-radius: 2px; }
.ratio-opt.active .ar-bar { background: #a5b4fc; }

.seg-opt {
  height: 30px; border-radius: 6px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.05);
  font-size: 11px; font-weight: 500; color: #a1a1aa; cursor: pointer; transition: all .15s;
}
.seg-opt:hover { background: rgba(255,255,255,0.06); color: #e4e4e7; }
.seg-opt.active { background: rgba(99,102,241,0.15); border-color: rgba(99,102,241,0.4); color: #a5b4fc; }

/* ===== History strip ===== */
.history-item {
  position: relative; flex-shrink: 0; width: 168px; aspect-ratio: 16/9; border-radius: 8px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06); cursor: pointer; transition: all .2s;
}
.history-item:hover { border-color: rgba(99,102,241,0.5); transform: translateY(-2px); box-shadow: 0 8px 20px -6px rgba(99,102,241,0.4); }
.history-item img { width: 100%; height: 100%; object-fit: cover; }
.history-item .hi-overlay {
  position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.9), transparent 60%);
  display: flex; flex-direction: column; justify-content: flex-end; padding: 6px;
}
.history-item .hi-prompt { font-size: 9px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item .hi-time { font-size: 8px; color: #a1a1aa; font-family: monospace; }
.history-item .hi-badge {
  position: absolute; top: 5px; left: 5px; font-size: 8px; font-weight: 600; padding: 1px 5px;
  border-radius: 3px; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); color: #fff;
}

/* ===== Generation stage dots ===== */
.stage-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.2); transition: all .3s; }
.stage-dot.active { background: #818cf8; box-shadow: 0 0 8px rgba(129,140,248,0.6); }
.stage-dot.done { background: #34d399; }

/* ===== Toast ===== */
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; min-width: 240px;
  background: #16161a; border: 1px solid rgba(255,255,255,0.1); border-radius: 10px;
  box-shadow: 0 12px 30px -8px rgba(0,0,0,0.6); animation: toastIn .25s ease;
}
.toast.success { border-color: rgba(52,211,153,0.3); }
.toast.success .toast-icon { color: #34d399; }
.toast.info .toast-icon { color: #818cf8; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* ===== Ruler ticks ===== */
.ruler-tick {
  position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,0.1);
}
.ruler-tick.major { background: rgba(255,255,255,0.2); }
.ruler-label {
  position: absolute; top: 4px; left: 3px; font-size: 8.5px; color: #71717a;
  font-family: 'JetBrains Mono', monospace; white-space: nowrap;
}

/* ===== Utilities ===== */
.fade-in { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Responsive guard */
@media (max-width: 1100px) {
  aside.w-\[300px\] { width: 260px !important; }
}