:root {
  --bg: #0b0c0f;
  --bg-lift: #12141a;
  --panel: #151820;
  --panel-edge: rgba(236, 240, 247, 0.08);
  --ink: #eef1f6;
  --muted: #8b93a7;
  --line: rgba(236, 240, 247, 0.1);
  --accent: #c8f135;
  --accent-ink: #101208;
  --danger: #ff8d7a;
  --field: #0f1116;
  --field-edge: rgba(236, 240, 247, 0.14);
  --radius: 10px;
  --radius-lg: 16px;
  color-scheme: dark;
  font-family: "Instrument Sans", "Avenir Next", sans-serif;
  font-feature-settings: "ss01" on;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1200px 520px at 12% -8%, rgba(200, 241, 53, 0.08), transparent 58%),
    radial-gradient(900px 480px at 100% 0%, rgba(88, 120, 255, 0.07), transparent 50%),
    linear-gradient(180deg, #10131a 0%, var(--bg) 42%, #090a0d 100%);
}

button, .button, input, select, summary {
  font: inherit;
}

button, .button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:hover:not(:disabled), .button:hover {
  border-color: rgba(236, 240, 247, 0.28);
  background: rgba(236, 240, 247, 0.04);
}

button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.primary, .primary-link {
  width: min(100%, 18rem);
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 0.9rem 1.1rem;
}

button.primary:hover:not(:disabled), .primary-link:hover {
  background: #d6ff4f;
  border-color: transparent;
}

button.ghost {
  border-color: transparent;
  color: var(--muted);
  padding-inline: 0.7rem;
}

button.ghost:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(236, 240, 247, 0.05);
  border-color: transparent;
}

button[aria-pressed="true"] {
  background: var(--ink);
  color: #10131a;
  border-color: var(--ink);
}

.page {
  width: min(1040px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.6rem 0 4.5rem;
}

.mast-top,
.mast-actions,
.look-actions,
.row-between,
.panel-head,
.video-main,
.video-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
}

.mast-top { margin-bottom: 1.4rem; }

.mast-brand {
  padding: 0.2rem 0 0.4rem;
}

.brand {
  margin: 0;
  font-family: Syne, "Avenir Next", sans-serif;
  font-weight: 800;
  font-size: clamp(3rem, 8vw, 5.2rem);
  letter-spacing: -0.06em;
  line-height: 0.9;
  color: var(--ink);
}

.lan {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.lan a {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  border-bottom: 1px solid rgba(236, 240, 247, 0.2);
}

#stop-server { color: var(--danger); }

h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h2 {
  font-family: Syne, "Avenir Next", sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
}
h3 { font-size: 0.98rem; }

.meta, .note, .empty, .music-name, .hint {
  color: var(--muted);
}

.note { color: var(--danger); margin: 0.7rem 0 0; }

.tabs {
  display: flex;
  gap: 0.35rem;
  margin-top: 1.75rem;
  padding: 0.28rem;
  width: fit-content;
  max-width: 100%;
  background: rgba(236, 240, 247, 0.04);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.tabs button {
  min-width: 5.8rem;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  color: var(--muted);
  font-weight: 600;
}

.tabs button:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(236, 240, 247, 0.05);
  border-color: transparent;
}

.tabs button[aria-selected="true"] {
  background: var(--ink);
  color: #10131a;
  border-color: transparent;
}

.tab-panels { margin-top: 0.9rem; }

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 28%),
    var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem 1.15rem;
}

.panel-head { margin-bottom: 0.15rem; }

.section-label {
  margin: 0.85rem 0 0.05rem;
  font-family: Syne, "Avenir Next", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.settings > .section-label:first-child { margin-top: 0.45rem; }

.option {
  display: grid;
  grid-template-columns: minmax(7.5rem, 11rem) minmax(0, 1fr);
  gap: 0.25rem 1rem;
  align-items: center;
  padding: 0.42rem 0;
  border-top: 1px solid var(--line);
}

.section-label + .option,
.build-row { border-top: 0; }

.build-row { padding-top: 0.75rem; }

.option-stack {
  display: block;
  align-items: stretch;
  padding: 0.55rem 0;
}

.option-copy h3,
.option-copy > span,
.option-copy > label {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
}

.option-copy > label { margin-top: 0; width: 100%; margin-bottom: 0; }

.option-copy .music-name {
  margin: 0.1rem 0 0;
  color: var(--ink);
  font-size: 0.82rem;
  line-height: 1.25;
}

.option-copy > button { margin-top: 0.25rem; padding: 0.2rem 0.45rem; }

.option-control { min-width: 0; }

.option-control > button,
.option-control > .primary { width: min(100%, 16rem); }

.look-actions .primary,
.look-actions > button { width: min(100%, 16rem); }

.option .presets {
  width: min(100%, 22rem);
  margin-top: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.28rem;
}

.option .presets button { width: 100%; padding: 0.32rem 0.4rem; font-size: 0.9rem; }

.option .presets.ratios { width: min(100%, 28rem); }

.option .presets.ratios button {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  padding-inline: 0.15rem;
  font-size: 0.84rem;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.stepper input[type="number"] {
  width: 3.8rem;
  text-align: center;
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 0.32rem 0.3rem;
  border: 1px solid var(--field-edge);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  -moz-appearance: textfield;
}

.stepper input[type="number"]::-webkit-outer-spin-button,
.stepper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-unit {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 0.9rem;
}

.stepper > button {
  width: 2rem;
  min-width: 2rem;
  padding: 0.25rem 0;
  font-size: 1rem;
  line-height: 1.2;
}

.cut-shift {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.cut-shift > button {
  width: auto;
  min-width: 4.6rem;
}

#sync-nudges {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: row;
  width: min(100%, 28rem);
  margin-top: 0.4rem;
  gap: 0.28rem;
}

#sync-nudges button { padding: 0.3rem 0.35rem; font-size: 0.85rem; }

.option-stack > label { margin-bottom: 0.25rem; }
.option-stack > h3 { margin-bottom: 0.35rem; font-size: 0.92rem; }

.drop {
  margin-top: 1rem;
  padding: 1.35rem 1.2rem;
  border: 1px dashed rgba(236, 240, 247, 0.18);
  border-radius: var(--radius-lg);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  background: rgba(236, 240, 247, 0.02);
}

.drop.hot {
  border-color: rgba(200, 241, 53, 0.55);
  background: rgba(200, 241, 53, 0.05);
}

.drop p { margin: 0; color: var(--muted); font-weight: 500; }

.saved { margin-top: 1.35rem; }
.saved h3 { margin: 0; font-size: 1rem; }

.videos, .cuts { list-style: none; margin: 0.85rem 0 0; padding: 0; }

.videos li, .cuts li {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 0.8rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}

.videos img, .thumb-fallback {
  width: 96px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  background: #222632;
}

.video-copy { min-width: 0; }

.video-copy strong, .cuts li strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-actions { margin-top: 0.45rem; justify-content: flex-start; }
.video-actions button, .presets button { padding: 0.35rem 0.7rem; }

.music-name, #summary, #silent-note, #progress, #error, .empty {
  margin: 0.35rem 0 0;
}

label {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
  align-items: baseline;
}

output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.15rem;
  align-items: center;
}

#reroll, #cancel, #apply-look, #apply-look-settings {
  width: auto;
  min-width: 8rem;
}

#scenes { margin-top: 0.15rem; }

.progress-wrap { margin-top: 1rem; }
.upload-progress { margin-top: 0.35rem; }

.track {
  height: 5px;
  border-radius: 99px;
  background: #242833;
  overflow: hidden;
}

#progress-bar,
#upload-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
}

.build-log {
  margin: 0.65rem 0 0;
  max-height: 11rem;
  overflow: auto;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: #15181f;
  color: #c6ccd8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.error { color: var(--danger); }

details { margin-top: 0.45rem; color: var(--muted); }

pre {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
}

#result { margin-top: 1.1rem; }

.stage {
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 9 / 16;
  margin-top: 0.85rem;
}

.stage.wide {
  width: min(100%, 640px);
  aspect-ratio: 16 / 9;
}

#player, #ride-player {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  border-radius: 12px;
  object-fit: contain;
}

.shot-badge, .context-badge {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 2;
  margin: 0;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(11, 12, 15, 0.82);
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  border: 1px solid rgba(236, 240, 247, 0.14);
}

.context-badge {
  width: auto;
  height: auto;
  min-height: 2rem;
  padding: 0.35rem 0.65rem;
  font-variant-numeric: normal;
}

.ride-map { margin-top: 1.35rem; }
.ride-map h3 { margin: 0; font-size: 1rem; }

.ride-picker {
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.ride-picker select {
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--field-edge);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
}

.ride-timeline {
  position: relative;
  height: 28px;
  margin-top: 1.5rem;
  border-radius: 8px;
  background: #242833;
  touch-action: none;
  cursor: crosshair;
}

.ride-seg, .ride-mark, .ride-select, .ride-head {
  position: absolute;
  top: 0;
  bottom: 0;
}

.ride-seg { border-radius: 2px; }
.ride-seg[data-scene="road"] { background: #d4a017; }
.ride-seg[data-scene="traffic"] { background: #ff6a2b; }
.ride-seg[data-scene="lights"] { background: #ff5c8a; }
.ride-seg[data-scene="scenery"] { background: #2fad6f; }
.ride-seg[data-scene="town"] { background: #6b8cff; }
.ride-seg[data-scene="waiting"] { background: #8a8175; }
.ride-seg[data-reason="speed"] { background: #e23b4a; }
.ride-seg[data-scene=""] { background: #3a342c; }

.ride-mark {
  border: 2px solid #eef1f6;
  border-radius: 5px;
  pointer-events: none;
  z-index: 2;
}

.ride-mark span {
  position: absolute;
  top: -1.15rem;
  left: 0;
  font-size: 0.72rem;
  font-weight: 700;
}

.ride-select {
  background: rgba(238, 241, 246, 0.24);
  outline: 2px solid var(--ink);
  pointer-events: none;
  z-index: 3;
}

.ride-head {
  width: 2px;
  margin-left: -1px;
  background: white;
  pointer-events: none;
  z-index: 4;
}

.ride-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.ride-legend li { display: flex; align-items: center; gap: 0.35rem; }

.ride-legend li::before {
  content: "";
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 2px;
  background: #3a342c;
}

.ride-legend li[data-scene="road"]::before { background: #d4a017; }
.ride-legend li[data-scene="traffic"]::before { background: #ff6a2b; }
.ride-legend li[data-scene="lights"]::before { background: #ff5c8a; }
.ride-legend li[data-scene="scenery"]::before { background: #2fad6f; }
.ride-legend li[data-scene="town"]::before { background: #6b8cff; }
.ride-legend li[data-scene="waiting"]::before { background: #8a8175; }
.ride-legend li[data-scene="speed"]::before { background: #e23b4a; }

.replace-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.5rem;
  max-width: 42rem;
}

.replace-row span { color: var(--muted); font-size: 0.85rem; }
.replace-row button { padding: 0.35rem 0.65rem; }

.sync-list {
  list-style: none;
  margin: 0.45rem 0 0;
  padding: 0;
  max-height: 160px;
  overflow: auto;
  display: grid;
  gap: 0.28rem;
}

.sync-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.sync-list .off { color: var(--muted); }

.color-preview { margin-top: 0.45rem; }
.option-control .empty { margin-top: 0.25rem; font-size: 0.82rem; }

.color-captions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  color: var(--muted);
  font-size: 0.85rem;
}

.color-preview img {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 0.3rem;
  border-radius: 10px;
  background: black;
}

.scene-row {
  display: grid;
  grid-template-columns: minmax(7.5rem, 11rem) minmax(0, 1fr);
  align-items: center;
  gap: 0.25rem 1rem;
  margin-top: 0;
  padding: 0.28rem 0;
  border-top: 1px solid var(--line);
}

#scenes .scene-row:first-child { border-top: 0; padding-top: 0.15rem; }

.scene-row > span {
  font-size: 0.92rem;
  font-weight: 600;
}

.scene-row .presets {
  margin: 0;
  width: min(100%, 18rem);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.28rem;
}

.scene-row .presets button { width: 100%; padding: 0.3rem 0.35rem; font-size: 0.88rem; }

.cuts { margin-bottom: 1rem; }
.cuts li {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  cursor: pointer;
  border-radius: 8px;
  padding-inline: 0.35rem;
}
.cuts li.on { background: rgba(200, 241, 53, 0.08); }

.cut-actions {
  display: block;
  max-width: 42rem;
  min-width: 0;
  margin-top: 0.5rem;
}

.cut-actions button { padding: 0.4rem 0.55rem; }

#download {
  margin-top: 0.35rem;
  display: inline-flex;
}

.notice:empty { display: none; }
.notice {
  margin: 0.75rem 0 0;
  min-height: 1.2rem;
  color: var(--danger);
}

@media (max-width: 860px) {
  .page { width: min(100% - 1.25rem, 1040px); padding-top: 1.1rem; }
  .brand { font-size: clamp(2.6rem, 14vw, 4rem); }
  .drop, .videos li { display: grid; }
  .drop { align-items: start; }
  .videos li { grid-template-columns: 96px 1fr; }
  .option, .scene-row {
    grid-template-columns: minmax(5.5rem, 7.5rem) minmax(0, 1fr);
    gap: 0.2rem 0.65rem;
    padding: 0.36rem 0;
  }
  .option-control > button,
  .option-control > .primary,
  .look-actions .primary,
  .look-actions > button,
  .option .presets,
  .option .presets.ratios,
  .scene-row .presets { width: 100%; }
  #sync-nudges { grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; min-width: 0; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions .primary, #reroll, #cancel, #apply-look { width: 100%; }
}
