:root {
  --bg: #050607;
  --panel: #13151a;
  --panel-strong: #1b1e24;
  --panel-soft: #20232b;
  --line: #343943;
  --text: #f5f7fb;
  --muted: #aeb8c7;
  --dim: #778292;
  --cyan: #62d7f2;
  --amber: #f6bd52;
  --green: #7ee081;
  --magenta: #d36bf2;
  --danger: #ff6b6b;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 480px);
  min-height: 100vh;
  background: #050607;
}

.onboarding-overlay[hidden] {
  display: none;
}

.onboarding-media {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #050607;
}

.onboarding-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 6, 7, 0.05) 0%, rgba(5, 6, 7, 0.32) 58%, #050607 100%),
    linear-gradient(0deg, rgba(5, 6, 7, 0.22), transparent 36%);
  pointer-events: none;
}

.onboarding-media img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  object-fit: cover;
}

.onboarding-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 42px 40px;
  border-left: 1px solid rgba(98, 215, 242, 0.24);
  background: rgba(5, 6, 7, 0.94);
  box-shadow: -22px 0 60px rgba(0, 0, 0, 0.34);
}

.onboarding-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.onboarding-progress span {
  height: 3px;
  background: #2c323c;
}

.onboarding-progress span.active,
.onboarding-progress span.complete {
  background: var(--cyan);
}

.onboarding-count {
  color: var(--amber);
  font-size: 12px;
  font-weight: 780;
  line-height: 1.2;
}

.onboarding-copy h2 {
  max-width: 11ch;
  font-size: 48px;
  line-height: 0.96;
  letter-spacing: 0;
}

.onboarding-copy > p:not(.onboarding-count) {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.58;
}

.onboarding-copy ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.onboarding-copy li {
  position: relative;
  padding-left: 20px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

.onboarding-copy li::before {
  content: "";
  position: absolute;
  top: 0.62em;
  left: 0;
  width: 8px;
  height: 8px;
  background: var(--amber);
}

.onboarding-actions {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}

.primary-button,
.secondary-button,
.tour-button {
  min-height: 42px;
  border: 1px solid var(--line);
  background: rgba(20, 23, 29, 0.92);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 780;
}

.primary-button {
  justify-self: end;
  min-width: 132px;
  border-color: rgba(246, 189, 82, 0.68);
  background: #c98724;
  color: #090806;
}

.secondary-button {
  min-width: 84px;
  color: var(--muted);
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.tour-button {
  width: 100%;
  color: var(--cyan);
  border-color: rgba(98, 215, 242, 0.34);
  background: #0a1014;
}

.quest-panel {
  display: grid;
  gap: 11px;
  padding: 12px;
  border: 1px solid rgba(246, 189, 82, 0.32);
  background: #0b0d11;
}

.quest-heading {
  display: grid;
  gap: 5px;
}

#quest-count {
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

#quest-title {
  color: var(--text);
  font-size: 14px;
  line-height: 1.15;
}

#quest-prompt,
.quest-feedback {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.quest-options {
  display: grid;
  gap: 7px;
}

.quest-option {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  background: #11141a;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.32;
}

.quest-option:hover,
.quest-option:focus-visible {
  border-color: rgba(126, 224, 129, 0.68);
  outline: none;
  background: #132018;
}

.quest-choice {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(98, 215, 242, 0.32);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
}

.quest-feedback {
  min-height: 34px;
  color: var(--amber);
}

.unlock-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.unlock-chip {
  padding: 5px 7px;
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 10px;
  font-weight: 780;
  line-height: 1.1;
}

.unlock-chip.unlocked {
  border-color: rgba(126, 224, 129, 0.42);
  color: var(--green);
}

.quest-panel.complete {
  border-color: rgba(126, 224, 129, 0.42);
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 360px;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 42% 44%, rgba(98, 215, 242, 0.11), transparent 31%),
    linear-gradient(135deg, #050607 0%, #101116 42%, #070709 100%);
}

.app-shell.is-onboarding {
  pointer-events: none;
  user-select: none;
  filter: blur(8px) brightness(0.52);
}

.rail,
.inspector {
  position: relative;
  z-index: 2;
  background: rgba(19, 21, 26, 0.92);
  border-color: var(--line);
  backdrop-filter: blur(18px);
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  overflow: auto;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
  border-left: 1px solid var(--line);
  overflow: auto;
}

.brand-block {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-block > div {
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(98, 215, 242, 0.42);
  background: #0b1114;
  color: var(--cyan);
  font-size: 14px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 17px;
  line-height: 1.14;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.brand-block p,
.stage-copy p,
.summary-label,
.metric-label,
.metric-help,
.parameter-role,
.source-meta,
.term-meaning,
.term-source {
  color: var(--muted);
}

.brand-block p {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.3;
}

.stage-rail {
  display: grid;
  gap: 9px;
}

.stage-button {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 10px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.stage-button:hover,
.stage-button.active {
  border-color: rgba(98, 215, 242, 0.42);
  background: #172029;
}

.stage-button.locked,
.segmented button.locked,
.icon-button.locked,
.time-control.locked {
  border-color: rgba(52, 57, 67, 0.8);
  color: var(--dim);
  cursor: not-allowed;
  opacity: 0.54;
}

.stage-button.locked:hover,
.segmented button.locked:hover {
  background: transparent;
}

.stage-index {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid var(--line);
  background: #0a0c10;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stage-button.active .stage-index {
  border-color: var(--cyan);
  color: var(--cyan);
}

.stage-label {
  display: block;
  font-size: 14px;
  font-weight: 760;
  line-height: 1.1;
}

.stage-layer {
  display: block;
  margin-top: 5px;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.2;
}

.summary-strip {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.summary-strip div {
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: #0c0e13;
}

.summary-label {
  display: block;
  font-size: 11px;
  line-height: 1.3;
}

.summary-strip strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.15;
}

.scene-region {
  position: relative;
  min-width: 0;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

#scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#scene-canvas:active {
  cursor: grabbing;
}

.topbar {
  position: absolute;
  top: 18px;
  left: 20px;
  right: 20px;
  z-index: 3;
  display: grid;
  grid-template-columns: 42px minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.icon-button,
.segmented button,
.tab-button {
  border: 1px solid var(--line);
  background: rgba(20, 23, 29, 0.92);
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  font-size: 18px;
}

.icon-button.primary {
  border-color: rgba(246, 189, 82, 0.58);
  color: var(--amber);
  box-shadow: 0 0 0 1px rgba(246, 189, 82, 0.08), var(--shadow);
}

.time-control {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: rgba(13, 16, 21, 0.84);
  box-shadow: var(--shadow);
}

#time-label {
  color: var(--text);
  font-size: 12px;
  line-height: 1.1;
}

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

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 0;
  border: 1px solid var(--line);
  background: rgba(13, 16, 21, 0.84);
  box-shadow: var(--shadow);
}

.segmented button {
  min-width: 76px;
  height: 42px;
  border-width: 0 1px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: rgba(98, 215, 242, 0.14);
  color: var(--cyan);
}

.legend {
  position: absolute;
  left: 20px;
  bottom: 18px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: rgba(13, 16, 21, 0.84);
  color: var(--muted);
  font-size: 12px;
  box-shadow: var(--shadow);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.scene-guide {
  position: absolute;
  right: 20px;
  bottom: 18px;
  z-index: 4;
  display: grid;
  width: min(360px, calc(100% - 40px));
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(98, 215, 242, 0.34);
  background: rgba(8, 11, 15, 0.88);
  box-shadow: var(--shadow);
}

.guide-copy {
  display: grid;
  gap: 5px;
}

.guide-kicker {
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

#ring-title {
  color: var(--text);
  font-size: 14px;
  line-height: 1.18;
}

#ring-info,
.story-caption {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.ring-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ring-chip {
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  background: #11141a;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 780;
}

.ring-chip.active,
.ring-chip:hover,
.ring-chip:focus-visible {
  border-color: rgba(246, 189, 82, 0.72);
  color: var(--amber);
  outline: none;
}

.story-button {
  min-height: 34px;
  border: 1px solid rgba(126, 224, 129, 0.42);
  background: #0d1710;
  color: var(--green);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.story-button.active {
  border-color: rgba(246, 189, 82, 0.72);
  color: var(--amber);
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
}

.swatch-cyan {
  background: var(--cyan);
}

.swatch-amber {
  background: var(--amber);
}

.swatch-green {
  background: var(--green);
}

.swatch-flow {
  background: var(--green);
  box-shadow: 5px 0 0 var(--magenta);
}

.stage-copy {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

#stage-kicker {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 780;
}

.stage-copy h2 {
  margin-top: 7px;
  font-size: 24px;
  line-height: 1.08;
  letter-spacing: 0;
}

.stage-copy p {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.55;
}

.learning-summary {
  border: 1px solid rgba(98, 215, 242, 0.36);
  background: #0a1014;
}

.learning-card {
  display: grid;
  gap: 8px;
  padding: 13px;
}

.learning-kicker {
  color: var(--amber);
  font-size: 11px;
  font-weight: 780;
  line-height: 1.2;
}

.learning-headline {
  color: var(--text);
  font-size: 18px;
  line-height: 1.16;
  letter-spacing: 0;
}

.learning-body {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  min-height: 82px;
  padding: 11px;
  border: 1px solid var(--line);
  background: #0c0e13;
}

.metric-card.wide {
  grid-column: 1 / -1;
}

.metric-label {
  display: block;
  font-size: 11px;
  line-height: 1.25;
}

.metric-value {
  display: block;
  margin-top: 7px;
  color: var(--text);
  font-size: 18px;
  font-weight: 780;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.metric-unit {
  display: block;
  margin-top: 4px;
  color: var(--dim);
  font-size: 11px;
}

.metric-help {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.35;
}

.status-good .metric-value {
  color: var(--green);
}

.details-panel {
  border: 1px solid var(--line);
  background: #0c0e13;
}

.details-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.tab-button {
  height: 38px;
  border-width: 0 1px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.tab-button:last-child {
  border-right: 0;
}

.tab-button.active {
  background: #182026;
  color: var(--cyan);
}

.details-content {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.details-content.hidden {
  display: none;
}

.parameter-row,
.source-row,
.learn-row {
  display: grid;
  gap: 5px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(52, 57, 67, 0.7);
}

.parameter-row:last-child,
.source-row:last-child,
.learn-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.parameter-name,
.source-title,
.term-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 760;
}

.parameter-role,
.source-meta,
.source-row a,
.term-meaning,
.term-source {
  font-size: 12px;
  line-height: 1.4;
}

.term-source {
  color: var(--dim);
  font-size: 11px;
}

.source-row a {
  color: var(--cyan);
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .onboarding-overlay {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .onboarding-media {
    min-height: 44vh;
  }

  .onboarding-media img {
    min-height: 44vh;
  }

  .onboarding-media::after {
    background:
      linear-gradient(0deg, #050607 0%, rgba(5, 6, 7, 0.38) 45%, rgba(5, 6, 7, 0.06) 100%);
  }

  .onboarding-copy {
    justify-content: start;
    min-height: 56vh;
    padding: 30px 24px 34px;
    border-top: 1px solid rgba(98, 215, 242, 0.24);
    border-left: 0;
  }

  .onboarding-copy h2 {
    max-width: 14ch;
    font-size: 40px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .rail,
  .inspector {
    border: 0;
    overflow: visible;
  }

  .rail {
    gap: 14px;
  }

  .stage-rail {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stage-button {
    grid-template-columns: 1fr;
    min-height: 72px;
  }

  .summary-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .scene-region {
    height: 62vh;
    min-height: 62vh;
  }

  .topbar {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .segmented {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .onboarding-copy {
    padding: 24px 18px 28px;
  }

  .onboarding-copy h2 {
    font-size: 34px;
  }

  .onboarding-copy > p:not(.onboarding-count) {
    font-size: 15px;
  }

  .onboarding-actions {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .primary-button {
    justify-self: stretch;
  }

  .stage-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-button {
    grid-template-columns: 26px 1fr;
    min-height: 58px;
  }

  .summary-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .summary-strip div {
    min-width: 0;
    padding: 9px;
  }

  .summary-strip strong {
    font-size: 17px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    left: 12px;
    right: 12px;
  }

  .legend {
    left: 12px;
    right: 12px;
    bottom: 14px;
  }

  .scene-guide {
    left: 12px;
    right: 12px;
    bottom: 58px;
    width: auto;
  }
}
