@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2');
}

:root {
  --bg: #0b0f17;
  --panel: #131a26;
  --panel-2: #182131;
  --border: #263349;
  --border-soft: #202b3d;
  --text: #e8eef8;
  --muted: #94a3b8;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --green: #34d399;
  --red: #f87171;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  overflow-x: hidden;
}

.glow {
  position: fixed;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}
.glow-a { top: -180px; left: -120px; background: var(--accent); }
.glow-b { top: 260px; right: -200px; background: var(--accent-2); }

.app {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), #4f46e5 60%, var(--accent-2));
  box-shadow: 0 8px 24px rgba(124, 92, 255, 0.35);
}
.brand-mark svg { width: 24px; height: 24px; color: white; }
.brand h1 { margin: 0; font-size: 21px; letter-spacing: -0.4px; font-weight: 800; }
.brand p { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); }
.topbar-badge {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
}
.topbar-badge[data-state="loading"] { color: #a5f3fc; border-color: rgba(34,211,238,0.45); background: rgba(34,211,238,0.08); }
.topbar-badge[data-state="ready"] { color: #a7f3d0; border-color: rgba(52,211,153,0.45); background: rgba(52,211,153,0.08); }
.topbar-badge[data-state="error"] { color: #fecaca; border-color: rgba(248,113,113,0.45); background: rgba(248,113,113,0.08); }

main { display: grid; gap: 18px; }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0)) , var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.18);
}
.card-head { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 18px; }
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.card-head p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.step {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800;
  color: #d9d0ff;
  background: rgba(124, 92, 255, 0.16);
  border: 1px solid rgba(124, 92, 255, 0.35);
}

/* Upload */
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.privacy-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(52,211,153,0.22);
  background: rgba(52,211,153,0.06);
  border-radius: 10px;
  color: #b6c2d6;
  font-size: 11.5px;
  line-height: 1.6;
}
.dropzone {
  position: relative;
  min-height: 178px;
  border: 1.5px dashed #34435c;
  border-radius: 14px;
  background: rgba(255,255,255,0.015);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: rgba(124,92,255,0.06); outline: none; }
.dropzone.dragover { border-color: var(--accent-2); background: rgba(34,211,238,0.08); transform: translateY(-2px); }
.dropzone.has-file { border-style: solid; border-color: rgba(52,211,153,0.5); background: rgba(52,211,153,0.05); }
.drop-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(124,92,255,0.12);
  color: #b9a8ff;
  margin-bottom: 4px;
}
.drop-icon svg { width: 23px; height: 23px; }
.drop-title { font-weight: 700; font-size: 14px; }
.drop-hint { font-size: 11.5px; color: var(--muted); }
.file-chip {
  margin-top: 10px;
  max-width: 100%;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(52,211,153,0.12);
  border: 1px solid rgba(52,211,153,0.3);
  border-radius: 9px;
  padding: 7px 13px;
}
.chip-name { font-size: 12.5px; font-weight: 600; color: #a7f3d0; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-meta { font-size: 11px; color: var(--muted); }

/* Preview */
.preview-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; }
.preview-box, .audio-box {
  background: #0d131e;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  padding: 12px;
  min-width: 0;
}
.preview-label { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 9px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-video { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.dot-audio { background: var(--accent-2); box-shadow: 0 0 10px var(--accent-2); }
video, audio { width: 100%; display: block; }
video { max-height: 340px; background: #05080d; border-radius: 9px; }
audio { height: 38px; margin-bottom: 12px; }
.preview-empty {
  text-align: center; color: #64748b; font-size: 12px;
  padding: 62px 0;
}
.preview-empty.small { padding: 0 0 14px; }
.quick-info { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quick-info > div {
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 8px 10px;
  display: flex; flex-direction: column;
}
.quick-info span { font-size: 10.5px; color: var(--muted); }
.quick-info strong { font-size: 13px; font-variant-numeric: tabular-nums; }
.quick-info .highlight { border-color: rgba(124,92,255,0.45); background: rgba(124,92,255,0.1); }
.quick-info .highlight strong { color: #c4b5fd; }

/* Timeline */
.timeline {
  margin-top: 16px;
  position: relative;
  background: #0d131e;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  padding: 14px 14px 10px;
}
.timeline-ruler { position: relative; height: 20px; margin-left: 54px; border-bottom: 1px solid var(--border-soft); }
.tick { position: absolute; top: 0; bottom: 0; font-size: 9.5px; color: #64748b; transform: translateX(-50%); }
.tick::after { content: ''; position: absolute; bottom: 0; left: 50%; width: 1px; height: 5px; background: #475569; }
.timeline-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.timeline-label { width: 44px; flex: 0 0 44px; font-size: 10.5px; color: var(--muted); text-align: right; }
.track-wrap { flex: 1; min-width: 0; height: 26px; background: rgba(255,255,255,0.02); border-radius: 6px; overflow: hidden; }
.track {
  height: 100%;
  display: flex; align-items: center;
  padding: 0 8px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  border-radius: 6px;
  transition: width .25s ease;
}
.track-video { background: linear-gradient(90deg, #6d4aff, #8b6cff); }
.track-audio { background: linear-gradient(90deg, #0891b2, #22d3ee); }
.track-target { background: linear-gradient(90deg, #059669, #34d399); }
.track.repeat {
  background-image: repeating-linear-gradient(115deg, rgba(255,255,255,0.16) 0 8px, rgba(255,255,255,0) 8px 16px),
    linear-gradient(90deg, #6d4aff, #8b6cff);
}
.track-audio.repeat {
  background-image: repeating-linear-gradient(115deg, rgba(255,255,255,0.16) 0 8px, rgba(255,255,255,0) 8px 16px),
    linear-gradient(90deg, #0891b2, #22d3ee);
}
.playhead {
  position: absolute;
  top: 34px; bottom: 28px;
  width: 2px;
  left: 54px;
  background: #f8fafc;
  box-shadow: 0 0 8px rgba(255,255,255,0.7);
  pointer-events: none;
  transition: left .08s linear;
}
.playhead::before {
  content: ''; position: absolute; top: -3px; left: -4px;
  width: 10px; height: 10px; border-radius: 50%; background: #f8fafc;
}
.timeline-note { margin: 9px 0 0 54px; font-size: 10.5px; color: #64748b; }

/* Tabs & panels */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border-soft); margin-bottom: 18px; overflow-x: auto; }
.tab {
  appearance: none; border: 0; background: transparent;
  color: var(--muted);
  padding: 9px 15px;
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: #c4b5fd; border-bottom-color: var(--accent); }
.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label:first-child, .field .check-label { font-size: 12px; font-weight: 600; color: #cbd5e1; }
.field .value { color: #c4b5fd; font-variant-numeric: tabular-nums; }
.field .help { margin: 0; font-size: 10.5px; color: #64748b; }
select, input[type="text"], input[type="number"] {
  width: 100%;
  background: #0d131e;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,92,255,0.14);
}
input[type="range"] {
  width: 100%; height: 5px;
  appearance: none;
  border-radius: 999px;
  background: #2b3750;
  outline: none;
  margin: 9px 0 3px;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 2px solid #0d131e; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(124,92,255,0.6);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0d131e; cursor: pointer;
}
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.check-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.callout {
  margin-top: 16px;
  background: rgba(34,211,238,0.07);
  border: 1px solid rgba(34,211,238,0.24);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 12px;
  color: #a5f3fc;
}
.subhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 12px; }
.subhead.first { margin-top: 0; }
.section-title { font-size: 12.5px; font-weight: 700; color: #c4b5fd; }
.divider { height: 1px; background: var(--border-soft); margin: 20px 0; }
.switch-label { display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.switch-label input { position: absolute; opacity: 0; }
.switch {
  width: 34px; height: 19px; border-radius: 999px;
  background: #334155; position: relative; transition: background .2s;
}
.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #cbd5e1; transition: transform .2s;
}
.switch-label input:checked + .switch { background: var(--accent); }
.switch-label input:checked + .switch::after { transform: translateX(15px); background: white; }
.help-inline { font-size: 10.5px; color: #64748b; }
.preset-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.mini-btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: #cbd5e1;
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 11px; font-weight: 600;
  cursor: pointer;
}
.mini-btn:hover { border-color: var(--accent); color: white; }
.mini-btn.ghost { margin-left: auto; }

/* Actions */
.action-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 10px;
  padding: 10px 17px;
  font-size: 12.5px; font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .15s, filter .15s, background .15s;
}
.btn svg { width: 14px; height: 14px; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #5b45e0); color: white; box-shadow: 0 8px 22px rgba(124,92,255,0.28); }
.btn.ghost { background: rgba(255,255,255,0.04); border-color: var(--border); color: #cbd5e1; }
.btn.subtle { background: transparent; color: var(--muted); border-color: var(--border); margin-top: 12px; }
.action-note { font-size: 11.5px; color: var(--muted); }

.progress-card {
  margin-top: 18px;
  background: #0d131e;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 15px;
}
.progress-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 9px; }
.progress-top strong { color: #c4b5fd; font-variant-numeric: tabular-nums; }
.progress-track { height: 8px; background: #1e293b; border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .25s ease;
}
.progress-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 10.5px; color: var(--muted); }
.log-details { margin-top: 10px; font-size: 11px; color: var(--muted); }
.log-details summary { cursor: pointer; }
.log-details pre {
  max-height: 160px; overflow: auto;
  background: #070b11; border-radius: 8px; padding: 10px;
  font-size: 10px; line-height: 1.5; color: #94a3b8; white-space: pre-wrap; word-break: break-word;
}
.warning-box {
  margin-top: 10px;
  background: rgba(251,191,36,0.08);
  border: 1px solid rgba(251,191,36,0.3);
  color: #fde68a;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 11.5px;
}
.error-box {
  margin-top: 16px;
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.35);
  color: #fecaca;
  border-radius: 10px; padding: 12px 14px; font-size: 12px;
  white-space: pre-wrap; max-height: 220px; overflow: auto;
}
.result {
  margin-top: 18px;
  border: 1px solid rgba(52,211,153,0.32);
  background: rgba(52,211,153,0.045);
  border-radius: 12px; padding: 16px;
}
.result-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.result-head h3 { margin: 0; font-size: 14px; color: #a7f3d0; }
.result-head p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result video { max-height: 360px; border-radius: 9px; background: #05080d; }

footer { text-align: center; color: #526077; font-size: 11px; margin-top: 26px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
  background: #1e293b; border: 1px solid var(--border);
  color: var(--text); padding: 10px 16px; border-radius: 10px;
  font-size: 12px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 50;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }

@media (max-width: 780px) {
  .app { padding: 18px 12px 36px; }
  .card { padding: 16px; }
  .upload-grid, .preview-grid, .field-grid { grid-template-columns: 1fr; }
  .topbar-badge { display: none; }
  .quick-info { grid-template-columns: 1fr 1fr; }
  .btn { padding: 9px 13px; }
}
