@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --bg:         #07070c;
  --surface:    #0f0f18;
  --surface2:   #16161f;
  --surface3:   #1e1e2c;
  --border:     #26263a;
  --border-hi:  #38385a;
  --accent:     #6366f1;
  --accent-h:   #818cf8;
  --accent-dim: rgba(99,102,241,.13);
  --accent2:    #e879a0;
  --text:       #ededf8;
  --text-2:     #b8b8d4;
  --text-muted: #5f5f82;
  --success:    #34d399;
  --radius:     12px;
  --radius-sm:  8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Header ─────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 54px;
  background: rgba(7,7,12,.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.header h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  white-space: nowrap;
}

.header h1::before {
  content: '';
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  flex-shrink: 0;
  display: block;
}

/* ── Nav links ───────────────────────────────── */
.nav-links { display: flex; gap: 3px; }

.nav-link {
  padding: 5px 13px;
  border-radius: 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.16s;
  border: 1px solid transparent;
}

.nav-link:hover { color: var(--text-2); background: var(--surface3); border-color: var(--border); }

.nav-link.active {
  background: var(--accent-dim);
  border-color: rgba(99,102,241,.3);
  color: var(--accent-h);
  font-weight: 600;
}

/* ── Tool tabs ───────────────────────────────── */
.tool-tabs {
  display: flex;
  gap: 1px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

.tab {
  padding: 4px 16px;
  border-radius: 7px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.14s;
  white-space: nowrap;
}

.tab:hover { color: var(--text-2); background: var(--surface3); }

.tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}

/* ── Main ────────────────────────────────────── */
.main { flex: 1; padding: 24px 28px; }

/* ── Upload ──────────────────────────────────── */
.upload-area {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 80px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-area:hover, .upload-area.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.upload-content svg { color: var(--text-muted); margin-bottom: 18px; opacity: 0.6; }
.upload-content p { color: var(--text-2); margin-bottom: 6px; }

.browse-link {
  color: var(--accent-h);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Editor layout ───────────────────────────── */
.editor-area {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  align-items: start;
}

/* ── Preview ─────────────────────────────────── */
.preview-container {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
}

.video-wrapper {
  position: relative;
  background: #000;
  width: 100%;
  line-height: 0;
}

.video-wrapper video {
  width: 100%;
  display: block;
  max-height: 460px;
  object-fit: contain;
}

#cropCanvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  display: none;
}

.playback-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
}

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.14s, background 0.14s;
}

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

.time-display {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.2px;
}

/* ── Tool panel ──────────────────────────────── */
.tool-panel { display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

.panel-title {
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

/* ── Timeline ────────────────────────────────── */
.timeline-container { margin-bottom: 14px; }

.timeline {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 10px 10px 8px;
  border: 1px solid var(--border);
}

.timeline-track {
  position: relative;
  height: 44px;
  background: var(--surface3);
  border-radius: 5px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
}

.thumb-strip {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  border-radius: 5px;
}

.thumb-strip img {
  flex: 1;
  min-width: 0;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
}

.thumb-strip-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: rgba(255,255,255,.28);
  letter-spacing: 0.5px;
  pointer-events: none;
}

.trim-region {
  position: absolute;
  top: 0; bottom: 0;
  background: rgba(99,102,241,.2);
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
}

.trim-handle {
  position: absolute;
  top: 0; bottom: 0;
  width: 10px;
  background: var(--accent);
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s;
}

.trim-handle:hover { background: var(--accent-h); }

.trim-handle::after {
  content: '';
  display: block;
  width: 2px;
  height: 16px;
  background: rgba(255,255,255,.55);
  border-radius: 1px;
}

.trim-handle.left  { left: 0; border-radius: 4px 0 0 4px; }
.trim-handle.right { right: 0; border-radius: 0 4px 4px 0; }

.playhead {
  position: absolute;
  top: -2px; bottom: -2px;
  width: 2px;
  background: var(--accent2);
  pointer-events: none;
  left: 0;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Time inputs ─────────────────────────────── */
.time-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.time-field label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 5px;
  font-weight: 600;
}

.time-field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 9px;
  font-size: 12px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.time-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.time-field input[readonly] { opacity: 0.4; cursor: default; }

/* ── Crop presets ────────────────────────────── */
.crop-presets {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.preset-label { font-size: 11px; color: var(--text-muted); margin-right: 2px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

.preset-btn {
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  transition: all 0.14s;
}

.preset-btn:hover { border-color: var(--border-hi); color: var(--text-2); background: var(--surface2); }

.preset-btn--special { border-color: rgba(232,121,160,.35); color: var(--accent2); }
.preset-btn--special:hover { border-color: var(--accent2) !important; background: rgba(232,121,160,.08); color: var(--accent2) !important; }
.preset-btn--special.active { background: var(--accent2) !important; border-color: var(--accent2) !important; color: #fff !important; }
.preset-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Crop dimensions ─────────────────────────── */
.crop-dimensions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 7px;
  margin-bottom: 12px;
}

.dim-field label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 5px;
  font-weight: 600;
}

.dim-field input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 7px 7px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.dim-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.crop-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ── Filename ────────────────────────────────── */
.filename-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.filename-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
  font-weight: 600;
}

.filename-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.filename-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.filename-input-wrap input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}

.filename-ext {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 10px 0 0;
  white-space: nowrap;
  user-select: none;
}

/* ── Buttons ─────────────────────────────────── */
.actions { display: flex; gap: 8px; }

.btn {
  flex: 1;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 2px 14px rgba(99,102,241,.28);
}

.btn.primary:hover {
  box-shadow: 0 4px 22px rgba(99,102,241,.44);
  transform: translateY(-1px);
}

.btn.secondary {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-2);
}

.btn.secondary:hover { border-color: var(--border-hi); color: var(--text); background: var(--surface3); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* ── Speed control ───────────────────────────── */
.speed-presets {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.speed-btn {
  flex: 1;
  min-width: 0;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.14s;
  text-align: center;
}

.speed-btn:hover { border-color: var(--border-hi); color: var(--text-2); background: var(--surface3); }
.speed-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.speed-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.speed-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; font-weight: 500; }

#speedSlider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--surface3);
  outline: none;
  cursor: pointer;
}

#speedSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(99,102,241,.4), 0 0 0 3px var(--surface2);
  transition: box-shadow 0.15s;
}

#speedSlider::-webkit-slider-thumb:hover {
  box-shadow: 0 2px 14px rgba(99,102,241,.55), 0 0 0 3px var(--surface2);
}

.speed-display-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.speed-display-label { font-size: 12px; color: var(--text-muted); }

.speed-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.speed-info {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
  padding: 9px 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.speed-info svg { flex-shrink: 0; margin-top: 2px; color: var(--accent); opacity: 0.7; }

/* ── Status / Progress ───────────────────────── */
.status-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.progress-bar-wrap {
  background: var(--surface3);
  border-radius: 4px;
  height: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8b5cf6, var(--accent2));
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease;
}

#statusText { font-size: 12px; color: var(--text-muted); text-align: center; }

/* ── Utilities ───────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 900px) {
  .editor-area { grid-template-columns: 1fr; }
  .header { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .main { padding: 16px; }
}
