:root {
  --bg: #0b0f17;
  --bg-elev: #121826;
  --bg-elev-2: #1a2233;
  --border: #253148;
  --text: #e8ecf4;
  --text-dim: #9aa7bd;
  --text-faint: #6b7690;
  --accent: #5b8cff;
  --accent-2: #22d3c7;
  --accent-grad: linear-gradient(135deg, #5b8cff, #22d3c7);
  --warn-bg: #3a2c10;
  --warn-border: #6b4e12;
  --warn-text: #ffd98a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  margin-bottom: 34px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-grad);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

.tagline {
  margin: 0;
  color: var(--text-dim);
  font-size: 14.5px;
  max-width: 560px;
}

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

/* ---------- banners ---------- */

.banner {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
}

.banner-warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
}

/* A smaller, tighter banner variant for a transient notice inside a
   settings panel (e.g. the real-photo AI model-switch note) rather than
   a page-level warning. */
.banner-inline {
  padding: 10px 12px;
  margin: 8px 0 0;
  font-size: 12.5px;
}

/* ---------- dropzone ---------- */

.dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  padding: 70px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--accent);
  background: var(--bg-elev-2);
  outline: none;
}

.dropzone.dragover {
  border-color: var(--accent-2);
  background: var(--bg-elev-2);
  transform: scale(1.005);
}

.dropzone-icon {
  color: var(--accent);
  margin-bottom: 10px;
}

.dropzone-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 6px;
}

.dropzone-sub {
  margin: 0;
  color: var(--text-faint);
  font-size: 13.5px;
}

/* ---------- workspace layout ---------- */

.workspace-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 22px;
  align-items: start;
}

@media (max-width: 880px) {
  .workspace-grid { grid-template-columns: 1fr; }
}

.preview-pane {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 320px;
}

.preview-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  background:
    linear-gradient(45deg, #0e1420 25%, transparent 25%),
    linear-gradient(-45deg, #0e1420 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #0e1420 75%),
    linear-gradient(-45deg, transparent 75%, #0e1420 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #090c12;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.preview-holder { max-width: 100%; }

.preview-media, .preview-canvas {
  max-width: 100%;
  max-height: 70vh;
  display: block;
  border-radius: 4px;
}

.media-toolbar {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.audio-player-tag {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  width: 70px;
  flex-shrink: 0;
}

.audio-player audio { width: 100%; }

/* ---------- settings pane ---------- */

.settings-pane {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.file-name {
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12.5px;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
}

.link-btn:hover { text-decoration: underline; }

.settings-block h2 {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 18px 0 8px;
}

.settings-block h2:first-child { margin-top: 4px; }

.hint {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.5;
}

.hint-restore-note {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.segmented {
  display: flex;
  gap: 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.segmented-wide { flex-wrap: wrap; }

.segmented label {
  flex: 1;
  text-align: center;
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.segmented span {
  display: block;
  padding: 8px 6px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.segmented input:checked + span {
  background: var(--accent-grad);
  color: #0a0e16;
  font-weight: 600;
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
}

.segmented input:disabled {
  cursor: not-allowed;
}

.segmented input:disabled + span {
  opacity: 0.4;
  cursor: not-allowed;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text);
  margin: 10px 0;
  cursor: pointer;
}

.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); }

.slider-row {
  display: grid;
  grid-template-columns: 50px 1fr 52px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
  margin: 10px 0;
}

.slider-row input[type="range"] {
  accent-color: var(--accent);
}

.slider-row output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.sub-panel {
  padding: 4px 0 4px 4px;
  border-left: 2px solid var(--border);
  margin-left: 2px;
}

/* ---------- buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  flex: 1;
  min-width: 120px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.12s ease, opacity 0.12s ease;
}

.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* `.btn` alone is fine on a <button> (a naturally-sized replaced-ish
   element that still respects `flex: 1`/padding in the `.actions` row),
   but an <a> defaults to `display: inline`, which ignores flex sizing
   and centers nothing -- needed for #download-ready-link to actually
   look and lay out like the buttons beside it.
   `:not([hidden])` matters here, not just style: a bare `a.btn` selector
   (specificity 0,1,1) outranks the browser's built-in
   `[hidden] { display: none }` rule (specificity 0,1,0), so setting
   `downloadReadyLink.hidden = true` in JS would set the *attribute*
   correctly but this rule's `display: inline-flex` would still win the
   cascade -- the link would stay visually shown (and clickable)
   regardless of what any JS state logic decided. Scoping this rule to
   only apply while `hidden` is absent means the element falls back to
   the browser's default hidden behavior whenever it *is* hidden,
   instead of this rule having to out-specificity it. */
a.btn:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-grad);
  color: #0a0e16;
  border: none;
}

.btn-accent {
  background: transparent;
  border: 1px solid var(--accent-2);
  color: var(--accent-2);
}

.btn-stop {
  background: transparent;
  border: 1px solid #d9605f;
  color: #ff9797;
}

/* ---------- status / progress ---------- */

.status {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-dim);
  min-height: 18px;
  line-height: 1.5;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-eta {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.progress {
  flex: 1;
  width: 100%;
  margin-top: 8px;
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
  appearance: none;
  border: none;
}

.progress::-webkit-progress-bar { background: var(--bg-elev-2); border-radius: 4px; }
.progress::-webkit-progress-value { background: var(--accent-grad); border-radius: 4px; }
.progress::-moz-progress-bar { background: var(--accent-grad); border-radius: 4px; }

/* ---------- video trim slider ---------- */

.trim-block {
  margin-top: 12px;
}

.trim-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 600;
}

.trim-times { font-variant-numeric: tabular-nums; font-weight: 500; }
.trim-duration-note { color: var(--text-faint); font-weight: 400; }

.trim-slider {
  position: relative;
  height: 28px;
  margin: 6px 0 2px;
}

.trim-track {
  position: absolute;
  top: 12px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--bg-elev-2);
  border-radius: 2px;
}

.trim-fill {
  position: absolute;
  top: 12px;
  height: 4px;
  background: var(--accent-grad);
  border-radius: 2px;
}

.trim-range {
  position: absolute;
  top: 6px;
  left: 0;
  width: 100%;
  height: 16px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.trim-range::-webkit-slider-runnable-track { background: transparent; }
.trim-range::-moz-range-track { background: transparent; border: none; }

.trim-range::-webkit-slider-thumb {
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-grad);
  border: 2px solid #0a0e16;
  cursor: ew-resize;
}

.trim-range::-moz-range-thumb {
  pointer-events: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-2);
  border: 2px solid #0a0e16;
  cursor: ew-resize;
}

/* ---------- before/after compare (image) ---------- */

.compare-wrap {
  position: relative;
  width: 100%;
  max-height: 70vh;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 4px;
  background: #000;
  touch-action: pan-y;
}

.compare-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  user-select: none;
}

.compare-before {
  clip-path: inset(0 50% 0 0);
}

.compare-label {
  position: absolute;
  top: 10px;
  z-index: 2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.65);
  color: var(--text);
  backdrop-filter: blur(2px);
  transition: opacity 0.15s ease;
}

.compare-label-after { right: 10px; }
.compare-label-before { left: 10px; }

.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  border-left: 2px solid rgba(255, 255, 255, 0.85);
  transform: translateX(-1px);
  pointer-events: none;
  z-index: 3;
}

.compare-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #0a0e16;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  box-shadow: var(--shadow);
}

.compare-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  z-index: 4;
  -webkit-appearance: none;
  appearance: none;
}

/* ---------- video before/after toggle ---------- */

.video-compare-toggle {
  display: flex;
  gap: 8px;
}

.chip-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.chip-btn.active {
  background: var(--accent-grad);
  border-color: transparent;
  color: #0a0e16;
}

/* ---------- audio placeholder ---------- */

.audio-icon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 20px;
  color: var(--text-faint);
}

.audio-icon-badge {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--accent-2);
}

.audio-icon-caption {
  margin: 0;
  font-size: 13px;
  text-align: center;
  max-width: 280px;
}

/* ---------- footer ---------- */

.footer {
  margin-top: 44px;
  text-align: center;
}

.footer p {
  max-width: 700px;
  margin: 0 auto;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.7;
}

.footer a { color: var(--text-dim); }
