:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: #11140f;
  color: #f1f4eb;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(rgba(8, 11, 7, 0.24), rgba(8, 11, 7, 0.74)),
    var(--scene-bg-image, url("https://images.unsplash.com/photo-1448375240586-882707db888b?auto=format&fit=crop&w=1800&q=80"))
      center / cover fixed;
}

body[data-scene="sea"] {
  background:
    radial-gradient(circle at 50% 12%, rgba(117, 176, 190, 0.2), transparent 38%),
    linear-gradient(rgba(6, 22, 29, 0.22), rgba(6, 16, 22, 0.76)),
    var(--scene-bg-image) center / cover fixed,
    linear-gradient(180deg, #173746 0%, #102731 46%, #081419 100%);
}

body[data-scene="train"] {
  background:
    linear-gradient(90deg, rgba(210, 181, 130, 0.08) 0 1px, transparent 1px 80px),
    radial-gradient(circle at 62% 22%, rgba(185, 145, 93, 0.18), transparent 36%),
    linear-gradient(rgba(18, 14, 10, 0.2), rgba(8, 7, 6, 0.8)),
    var(--scene-bg-image) center / cover fixed,
    linear-gradient(180deg, #26231f 0%, #171411 58%, #090807 100%);
}

body[data-scene="city"] {
  background:
    linear-gradient(90deg, rgba(210, 225, 230, 0.05) 0 1px, transparent 1px 64px),
    radial-gradient(circle at 22% 18%, rgba(140, 156, 165, 0.18), transparent 32%),
    linear-gradient(rgba(11, 14, 18, 0.2), rgba(7, 9, 12, 0.78)),
    var(--scene-bg-image) center / cover fixed,
    linear-gradient(180deg, #242b30 0%, #151a1f 52%, #080a0d 100%);
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 16px;
  align-content: start;
  align-items: start;
}

.stage,
.controls,
.library,
.log {
  border: 1px solid rgba(241, 244, 235, 0.14);
  background: rgba(13, 18, 12, 0.76);
  backdrop-filter: blur(20px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.stage {
  position: relative;
  overflow: hidden;
  height: calc(100vh - 64px);
  min-height: 520px;
  max-height: 820px;
  padding: 32px;
  grid-row: span 3;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.scene-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.88;
  pointer-events: none;
}

.scene-head,
.meters {
  position: relative;
  z-index: 1;
}

.stage-topline,
.scene-tabs,
.transport {
  position: relative;
  z-index: 1;
}

.stage-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.kicker {
  margin: 0;
  color: #a9d6a0;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(3.2rem, 9vw, 7rem);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.status,
.library p {
  color: #c8d3bf;
  line-height: 1.5;
}

.status {
  margin-bottom: 16px;
}

.transport {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.scene-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin: -3px 0 0;
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 18px;
  cursor: pointer;
}

.primary {
  background: #dcefcf;
  color: #172112;
}

.secondary {
  border-color: rgba(241, 244, 235, 0.2);
  background: rgba(241, 244, 235, 0.08);
  color: #f1f4eb;
}

.scene-tab {
  min-height: 34px;
  border-color: rgba(241, 244, 235, 0.18);
  background: rgba(241, 244, 235, 0.06);
  color: #dce8d4;
  padding: 0 12px;
}

.scene-tab.active {
  border-color: rgba(169, 214, 160, 0.7);
  background: rgba(169, 214, 160, 0.16);
  color: #f1f4eb;
}

.locale {
  min-height: 44px;
  border: 1px solid rgba(241, 244, 235, 0.2);
  border-radius: 6px;
  padding: 0 10px;
  background: rgba(241, 244, 235, 0.08);
  color: #f1f4eb;
}

.controls select {
  min-height: 38px;
  width: 100%;
  border: 1px solid rgba(241, 244, 235, 0.2);
  border-radius: 6px;
  padding: 0 10px;
  background: rgba(241, 244, 235, 0.08);
  color: #f1f4eb;
}

.controls,
.library,
.log {
  padding: 18px;
}

.controls {
  display: grid;
  gap: 16px;
}

.library {
  display: grid;
  gap: 18px;
}

.library-block {
  display: grid;
  gap: 12px;
}

.library-block + .library-block {
  padding-top: 16px;
  border-top: 1px solid rgba(241, 244, 235, 0.12);
}

label {
  display: grid;
  gap: 8px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #edf3e6;
  font-size: 0.95rem;
}

.help {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  border-radius: 999px;
  padding: 0;
  border-color: rgba(241, 244, 235, 0.26);
  background: rgba(241, 244, 235, 0.08);
  color: #dcefcf;
  font-size: 0.82rem;
  line-height: 1;
}

.help[aria-expanded="true"] {
  border-color: #a9d6a0;
  background: rgba(169, 214, 160, 0.18);
}

.tooltip-popover {
  position: fixed;
  z-index: 20;
  width: min(280px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(241, 244, 235, 0.18);
  border-radius: 6px;
  background: rgba(18, 24, 16, 0.96);
  color: #edf3e6;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  font-size: 0.9rem;
  line-height: 1.45;
}

input[type="range"] {
  width: 100%;
  accent-color: #a9d6a0;
}

.meters {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(241, 244, 235, 0.11);
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #a9d6a0;
  transition: width 0.2s ease;
}

.drop {
  min-height: 78px;
  place-items: center;
  border: 1px dashed rgba(241, 244, 235, 0.3);
  border-radius: 6px;
  background: rgba(241, 244, 235, 0.05);
  cursor: pointer;
}

.drop.over {
  border-color: #a9d6a0;
  background: rgba(169, 214, 160, 0.12);
}

.drop input {
  display: none;
}

.log {
  min-height: 0;
  max-height: 260px;
  display: flex;
  flex-direction: column;
}

.log ol {
  margin: 0;
  padding-left: 20px;
  overflow: auto;
  flex: 1;
  min-height: 0;
  color: #c8d3bf;
  font-size: 0.9rem;
  line-height: 1.55;
}

.running .primary {
  background: #f2c7a1;
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .stage {
    height: min(620px, calc(100vh - 48px));
    min-height: 420px;
    grid-row: auto;
  }

  .stage-topline {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .scene-tabs {
    justify-content: flex-start;
  }
}
