:root {
  color-scheme: dark;
  --paper: #f7f4ea;
  --ink: #eef3f8;
  --muted: #9ba9b7;
  --panel: rgba(11, 15, 20, 0.74);
  --panel-strong: rgba(12, 16, 22, 0.9);
  --line: rgba(255, 255, 255, 0.16);
  --accent: #ff6f61;
  --accent-2: #5ec4ff;
  --green: #83d483;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
.stage {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 111, 97, 0.12), transparent 28%),
    radial-gradient(circle at 82% 16%, rgba(94, 196, 255, 0.12), transparent 30%),
    linear-gradient(135deg, #080b0f 0%, #11161b 54%, #191818 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.28);
}

button.primary {
  color: #17110f;
  border-color: rgba(255, 255, 255, 0.44);
  background: linear-gradient(135deg, #fff4d1, #ff9d8e 54%, #ff6f61);
}

.stage {
  position: relative;
  isolation: isolate;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud,
.scenario-switch,
.drop-zone,
.timeline-panel,
.legend,
.status-toast {
  position: absolute;
  z-index: 3;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(120%);
}

.top-left {
  top: 18px;
  left: 18px;
  width: min(620px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 16px 18px;
}

.playground-title-button {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  white-space: nowrap;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
}

.playground-title-button:hover {
  transform: none;
  background: transparent;
}

.playground-caret {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #fff8df, #ff6f61 64%, #5ec4ff);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transform-origin: center;
  transition: filter 180ms ease;
  filter: drop-shadow(0 0 12px rgba(255, 111, 97, 0.36));
}

.playground-title-main,
.playground-title-suffix {
  font-size: clamp(24px, 2.45vw, 34px);
  line-height: 0.94;
  font-weight: 800;
  letter-spacing: 0;
}

.playground-title-main {
  color: #ffb5a8;
}

.playground-title-suffix {
  color: var(--ink);
}

.brand {
  margin-top: 8px;
  font-size: clamp(18px, 2.1vw, 30px);
  line-height: 1.05;
  max-width: 720px;
  font-weight: 760;
  letter-spacing: 0;
  text-wrap: balance;
  color: rgba(238, 243, 248, 0.92);
}

.mode-tabs {
  display: grid;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.mode-tabs {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.mode-tabs button {
  min-height: 32px;
  padding: 0 10px;
  border-color: transparent;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}

.mode-tabs button:hover {
  transform: none;
}

.mode-tabs button.active {
  color: #120f0d;
  background: linear-gradient(135deg, #fff8df, #ffbd95 58%, #ff6f61);
}

.scenario-switch {
  top: 18px;
  right: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(540px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 8px;
}

.scenario-switch button {
  min-height: 34px;
  min-width: 94px;
  padding: 0 16px;
  border-color: transparent;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.scenario-switch button:hover {
  transform: none;
}

.scenario-switch button.active {
  color: #120f0d;
  background: linear-gradient(135deg, #fff8df, #ffbd95 58%, #ff6f61);
}

.file-line {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.top-right {
  top: 76px;
  right: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
}

.metric {
  min-width: 84px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.045);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  line-height: 1;
}

.drop-zone {
  left: 18px;
  bottom: 144px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 36px);
  border-radius: 8px;
  padding: 10px;
}

.stage[data-mode="denoising"] .drop-zone {
  bottom: 164px;
}

.stage[data-mode="denoising"] .legend {
  bottom: 164px;
}

.drop-zone input {
  display: none;
}

#dropLabel {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.timeline-panel {
  left: 18px;
  right: 18px;
  bottom: 18px;
  border-radius: 8px;
  padding: 12px 14px 14px;
}

.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-height: 40px;
}

.transport label {
  display: grid;
  grid-template-columns: auto minmax(110px, 180px);
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.transport label.toggle {
  display: inline-flex;
  gap: 8px;
  color: var(--ink);
}

.transport .readout {
  min-width: 78px;
  color: var(--muted);
  font-size: 12px;
}

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

#frameSlider,
#denoiseStepSlider {
  display: block;
  width: 100%;
  margin-top: 10px;
}

.denoise-scrubber {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.denoise-scrubber #denoiseStepSlider {
  margin-top: 0;
}

.stage[data-mode="final"] .denoise-only,
.stage[data-mode="denoising"] .final-only {
  display: none;
}

.stage[data-mode="denoising"] #frameSlider.final-only {
  display: none;
}

.legend {
  right: 18px;
  bottom: 144px;
  display: grid;
  gap: 8px;
  width: min(260px, calc(100vw - 36px));
  max-height: min(45vh, 420px);
  overflow: auto;
  border-radius: 8px;
  padding: 12px;
}

.legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.46);
}

.legend-row strong {
  color: var(--ink);
  font-weight: 600;
}

.status-toast {
  left: 50%;
  top: 22px;
  max-width: min(520px, calc(100vw - 36px));
  transform: translate(-50%, -16px);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.status-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.stage.dragging::after {
  content: "";
  position: absolute;
  inset: 18px;
  z-index: 2;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  background: rgba(94, 196, 255, 0.08);
  pointer-events: none;
}

.stage.recording .hud,
.stage.recording .scenario-switch,
.stage.recording .drop-zone,
.stage.recording .timeline-panel,
.stage.recording .legend {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.hud,
.scenario-switch,
.drop-zone,
.timeline-panel,
.legend {
  transition:
    opacity 220ms ease,
    transform 220ms ease;
}

@media (max-width: 840px) {
  .top-right {
    top: auto;
    left: 18px;
    right: 18px;
    bottom: 206px;
  }

  .drop-zone {
    bottom: 154px;
  }

  .legend {
    display: none;
  }

  .timeline-panel {
    padding: 10px;
  }

  .transport {
    flex-wrap: wrap;
    gap: 8px;
  }

  .transport label {
    grid-template-columns: auto minmax(120px, 1fr);
  }

  #dropLabel {
    display: none;
  }
}

@media (max-width: 560px) {
  .top-left {
    padding: 13px 14px;
  }

  .brand {
    font-size: 30px;
  }

  .top-right {
    grid-template-columns: repeat(3, 1fr);
  }

  .metric {
    min-width: 0;
    padding: 10px;
  }

  .metric strong {
    font-size: 18px;
  }

  .transport label {
    width: 100%;
  }
}
