:root {
  color-scheme: dark;
  /* Palette taken directly from deltaclips (deltaclips.html) */
  --fg: #fff;
  --bg: #1a1a1a;
  --panel: #222;
  --panel-2: #2a2a2a;
  --border: #444;
  --border-soft: #333;
  --accent: #5865F2;
  --accent-hover: #4752C4;
  --success: #3ba55c;
  --success-hover: #2d7d46;
  --danger: #d83c3e;
  --muted: #888;
  --muted-2: #666;
  --muted-3: #555;
  --warn: #ffb454;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 960px;
  width: 100%;
  padding-top: 20px;
  padding-bottom: 64px;
}

/* Compact top bar: logo on the left, slim file picker filling the rest */
.app-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding-right: 16px;
  border-right: 1px solid var(--border-soft);
  white-space: nowrap;
}
/* "ΔE" monogram — plain white wordmark */
.logo-mark {
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.5px;
  color: var(--fg);
}
.muted { color: var(--muted); font-size: 13px; }
.warn { color: var(--warn); white-space: pre-wrap; margin-top: 16px; }

section { margin: 16px 0; }

/* Section headers — mirror deltaclips' .history-header h2 */
.section-title {
  font-size: 0.85em;
  color: #aaa;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ---- File picker: slim header-height bar ---- */
#pick { flex: 1; min-width: 0; }
.upload-area {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--panel);
  cursor: pointer;
  transition: all 0.2s;
}
.upload-area:hover { border-color: var(--muted-2); background: #282828; }
.upload-area input[type="file"] { display: none; }
.upload-icon { font-size: 20px; line-height: 1; }
.upload-title { font-size: 14px; font-weight: 600; white-space: nowrap; }
.upload-sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
#filename {
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* ---- Two-column editor layout ---- */
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
  margin-top: 24px;
}
.col-main { min-width: 0; }
.col-side { display: flex; flex-direction: column; }

video {
  width: 100%;
  max-height: 60vh;
  background: #000;
  border-radius: 8px;
  display: block;
}

/* Audio panel sits directly under the video */
.panel { margin-top: 20px; }
#audioPanel .section-title { margin-bottom: 10px; }

/* ---- Sidebar ---- */
.col-side {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 16px;
}
.side-block {
  margin: 0 0 13px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--border-soft);
}
.side-block:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }

/* Big live timecode readout, set as an inset display */
.timecode {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 9px 12px;
  font-variant-numeric: tabular-nums;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
}
.timecode-total { font-size: 13px; font-weight: 500; color: var(--muted); }
#rangeInfo, #outputInfo, #bitrateInfo { margin-top: 6px; }

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

/* ---- Buttons ---- */
/* Secondary buttons — mirror .history-item-copy */
button, select {
  font: inherit;
  background: var(--panel-2);
  color: #aaa;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
button:hover:not(:disabled) { background: var(--border-soft); color: #fff; }
button:disabled { background: var(--border); color: var(--muted-2); cursor: not-allowed; }

/* Primary action — mirror .upload-btn */
#render {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(88, 101, 242, 0.25);
  transition: background 0.2s, box-shadow 0.2s;
}
#render:hover:not(:disabled) {
  background: var(--accent-hover);
  color: #fff;
  box-shadow: 0 3px 14px rgba(88, 101, 242, 0.38);
}
#render:disabled { background: var(--border); color: var(--muted-2); box-shadow: none; }

#cancel { flex-shrink: 0; }

/* ---- Trim controls ---- */
.row { display: flex; gap: 6px; margin-bottom: 10px; }
.row button { flex: 1 1 0; min-width: 0; font-size: 13px; padding: 8px 6px; text-align: center; }

.slider-field { margin: 9px 0; }
.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
}
.slider-head span { font-size: 13px; color: #ccc; }
.slider-head output {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: #8aa6ff;
}

/* Custom range slider — full width, accent thumb on a track */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 4px 0;
  background: var(--border);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb:hover { background: var(--accent-hover); }
input[type="range"]::-moz-range-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

/* ---- Inputs ---- */
.inline { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.inline input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 4px;
  padding: 6px 8px;
  font: inherit;
  width: 72px;
  margin-left: auto;
  text-align: right;
}

/* ---- Audio tracks: each track as a card (file-row style) ---- */
.track {
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.track:hover { background: #2e333d; border-color: var(--border-soft); }
.track:last-child { margin-bottom: 0; }

.trackrow {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}
.trackrow input[type="checkbox"] { accent-color: var(--accent); }
.trackrow code { color: var(--muted); font-size: 12px; }

canvas.wave {
  display: block;
  width: 100%;
  height: 56px;
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none; /* let pointer drag scrub instead of scrolling */
}
.wavestatus { font-size: 12px; color: var(--muted); }

/* ---- Progress: mirror .file-row-progress ---- */
.progress { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
progress {
  width: 100%;
  height: 8px;
  border: none;
  border-radius: 4px;
  overflow: hidden;
  background: var(--border);
  appearance: none;
  -webkit-appearance: none;
}
progress::-webkit-progress-bar { background: var(--border); border-radius: 4px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 4px; }
#progText { font-variant-numeric: tabular-nums; min-width: 40px; color: var(--muted); }

/* ---- Result card ---- */
#result {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 12px;
}
.result-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}
.result-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 11px;
  flex-shrink: 0;
}
.result-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 6px 0 10px;
  font-size: 13px;
  min-width: 0;
}
.result-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #c3c9d4;
}
.result-size {
  flex-shrink: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.filebtn {
  display: block;
  width: 100%;
  text-align: center;
  background: var(--success);
  color: #fff;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}
.filebtn:hover { background: var(--success-hover); }
.filebtn[hidden] { display: none; } /* author display:block would otherwise override [hidden] */

/* ---- Narrow screens: stack the two columns ---- */
@media (max-width: 760px) {
  .editor-grid { grid-template-columns: 1fr; gap: 20px; }
  .app-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .logo { border-right: none; padding-right: 0; } /* divider only makes sense side-by-side */
  .upload-sub { display: none; } /* keep the slim bar on one line */
}
