:root {
  --bg: #0b0d10;
  --bg-2: #14181d;
  --bg-3: #1c2229;
  --line: #262d36;
  --text: #e7ecf2;
  --text-dim: #8a96a6;
  --accent: #4f8cff;
  --accent-2: #6aa3ff;
  --ok: #3ddc97;
  --warn: #f0b429;
  --err: #ff6b6b;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent-2); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }

header.app {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,13,16,.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
header.app .logo {
  font-weight: 700;
  letter-spacing: .5px;
  font-size: 17px;
}
header.app .logo span { color: var(--accent); }

.steps {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.steps .step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.steps .step.active {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(79,140,255,.08);
}
.steps .step .num {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--bg-3);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.steps .step.active .num { background: var(--accent); color: #fff; }

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 28px 80px;
}

h1 { font-size: 26px; margin: 0 0 6px; font-weight: 700; }
h2 { font-size: 18px; margin: 0 0 16px; font-weight: 600; }
.lead { color: var(--text-dim); margin: 0 0 28px; }

.tabs {
  display: inline-flex;
  background: var(--bg-2);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin-bottom: 24px;
}
.tabs button {
  background: transparent;
  border: 0;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-dim);
}
.tabs button.active {
  background: var(--bg-3);
  color: var(--text);
}

.grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dropzone {
  position: relative;
  aspect-ratio: 16 / 9;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
  overflow: hidden;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: rgba(79,140,255,.08); }
.dropzone.filled { border-style: solid; border-color: var(--ok); color: var(--text); }
.dropzone .label {
  position: absolute; top: 10px; left: 12px;
  font-size: 12px; color: var(--text-dim);
  background: rgba(0,0,0,.4); padding: 3px 8px; border-radius: 6px;
}
.dropzone .icon { font-size: 30px; opacity: .6; }
.dropzone .name { font-size: 13px; padding: 0 16px; text-align: center; word-break: break-all; }
.dropzone input[type=file] { display: none; }

.source-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
}
.source-input:focus { outline: none; border-color: var(--accent); }

.tile {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tile .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; }

.actions {
  margin-top: 28px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--accent-2); }
.btn:active { transform: scale(.98); }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.progress-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.progress-bar {
  height: 8px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width .3s ease;
}

/* ----- Step 2 ----- */
.preview-wrap {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) { .preview-wrap { grid-template-columns: 1fr; } }

.quad-preview {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
}
.quad-preview .stage {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}
.quad-preview video {
  width: 100%;
  height: 100%;
  display: block;
}
.quad-preview .name-badge {
  position: absolute;
  bottom: 14px; left: 14px;
  background: rgba(0,0,0,.55);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.thumb-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.thumb {
  aspect-ratio: 16 / 9;
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  cursor: pointer;
  display: flex;
  align-items: end;
  justify-content: start;
  padding: 8px;
  font-size: 12px;
  color: var(--text-dim);
  transition: border-color .15s;
}
.thumb.active { border-color: var(--accent); color: var(--text); }

.name-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}
.name-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
}
.name-row .num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.name-row input {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.name-row input:focus { outline: none; border-color: var(--accent); }
.name-row .reorder { display: flex; gap: 4px; }
.name-row .reorder button {
  background: var(--bg-3);
  border: 1px solid var(--line);
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
}
.name-row .reorder button:hover { color: var(--text); }

/* ----- Step 3 ----- */
.player-shell {
  max-width: 1100px;
  margin: 0 auto;
}
.player-frame {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  border: 1px solid var(--line);
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}
.player-frame .stage {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  transition: transform .25s ease;
}
.player-frame video {
  width: 100%;
  height: 100%;
  display: block;
}
.player-frame .view-name {
  position: absolute;
  bottom: 16px; left: 16px;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(6px);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  pointer-events: none;
}
.player-frame .swipe-hint {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 60px;
  color: rgba(255,255,255,.85);
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
.player-frame .swipe-hint.show { opacity: 1; }

.controls {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.controls .row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.ctrl-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: background .15s, border-color .15s;
}
.ctrl-btn:hover { background: var(--bg-3); border-color: var(--accent); }
.ctrl-btn.primary {
  width: 56px; height: 56px;
  background: var(--accent);
  border-color: var(--accent);
  font-size: 22px;
}
.ctrl-btn.primary:hover { background: var(--accent-2); }

.view-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.view-buttons button {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 8px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all .15s;
}
.view-buttons button .key {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
}
.view-buttons button.active {
  background: var(--accent);
  border-color: var(--accent);
}
.view-buttons button.active .key { color: rgba(255,255,255,.7); }

.scrub {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
}
.scrub input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--bg-3);
  border-radius: 999px;
  outline: none;
}
.scrub input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 60px 20px;
}

.panel-status {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
}
.panel-status strong { color: var(--text); }

/* Logo link */
header.app a.logo {
  font-weight: 700;
  letter-spacing: .5px;
  font-size: 17px;
  color: var(--text);
  text-decoration: none;
}
header.app a.logo span { color: var(--accent); }

/* Volume controls */
.volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
}
.volume-slider {
  -webkit-appearance: none;
  width: 90px;
  height: 4px;
  background: var(--bg-3);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}
.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 0;
  cursor: pointer;
}
