:root {
  color-scheme: dark;
  --bg: #071013;
  --panel: rgba(12, 27, 30, 0.94);
  --panel-soft: rgba(18, 39, 42, 0.7);
  --line: rgba(183, 225, 216, 0.14);
  --line-strong: rgba(183, 225, 216, 0.25);
  --text: #edf8f5;
  --muted: #93aaa6;
  --mint: #56e1bf;
  --mint-soft: rgba(86, 225, 191, 0.16);
  --gold: #f3ce78;
  --gold-soft: rgba(243, 206, 120, 0.16);
  --danger: #ff7d89;
  --radius-large: 28px;
  --radius-medium: 18px;
  --radius-small: 12px;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  --zone-1: #f6ba63;
  --zone-2: #68e2a3;
  --zone-3: #4ed8e7;
  --zone-4: #61aef6;
  --zone-5: #b58af6;
  --zone-6: #ee77ad;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 5%, rgba(61, 143, 128, 0.18), transparent 28rem),
    radial-gradient(circle at 92% 20%, rgba(82, 91, 163, 0.16), transparent 32rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  color: #071013;
  background: var(--gold);
  border-radius: 8px;
  transform: translateY(-150%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header,
.app-footer {
  width: min(1880px, calc(100% - 48px));
  margin-inline: auto;
}

.app-header {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-block: 18px;
}

.brand-lockup,
.header-actions,
.stage-toolbar,
.panel-heading,
.section-heading,
.energy-row,
.energy-meta {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 14px;
}

.brand-mark {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(86, 225, 191, 0.45);
  border-radius: 50%;
  color: var(--mint);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  box-shadow: inset 0 0 24px rgba(86, 225, 191, 0.08);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 620;
  letter-spacing: -0.03em;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 0;
}

.header-actions {
  gap: 12px;
}

.system-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 14px;
  color: #bbddd4;
  background: rgba(9, 24, 26, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 12px var(--mint);
}

.system-pill[data-status="fallback"] .status-dot {
  background: var(--danger);
  box-shadow: 0 0 12px var(--danger);
}

.system-pill[data-status="paused"] .status-dot {
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}

.button,
.icon-button,
.scenario-button,
.topology-option,
.zone-toggle {
  border: 1px solid var(--line);
  background: rgba(25, 48, 50, 0.5);
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease,
    color 150ms ease;
}

.button:hover,
.icon-button:hover,
.scenario-button:hover,
.topology-option:hover,
.zone-toggle:hover {
  border-color: var(--line-strong);
  background: rgba(38, 67, 67, 0.62);
}

.button:active,
.scenario-button:active,
.topology-option:active,
.zone-toggle:active {
  transform: translateY(1px);
}

.button {
  min-height: 42px;
  padding: 9px 13px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 680;
}

.button-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
}

.button-primary {
  color: #071512;
  background: var(--mint);
  border-color: transparent;
}

.button-primary:hover {
  color: #071512;
  background: #7deacb;
}

.button-celebration {
  margin-top: 10px;
  color: #201700;
  background: linear-gradient(135deg, #ffe6a0, #eab75f);
  border-color: transparent;
}

.button-danger {
  color: #ffb0b7;
}

.full-width {
  width: 100%;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: none;
  place-items: center;
  border-radius: 50%;
}

.app-shell {
  width: min(1880px, calc(100% - 48px));
  margin: 0 auto 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.stage-panel,
.control-panel {
  border: 1px solid var(--line);
  background: rgba(8, 20, 23, 0.75);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.stage-panel {
  min-width: 0;
  padding: 18px;
  border-radius: var(--radius-large);
}

.stage-toolbar {
  justify-content: space-between;
  gap: 16px;
  padding: 4px 4px 16px;
}

.event-clock {
  display: grid;
  justify-items: end;
  gap: 1px;
}

.event-clock span {
  color: var(--muted);
  font-size: 11px;
}

.event-clock strong {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
}

.scene-frame {
  position: relative;
  overflow: hidden;
  min-height: 620px;
  aspect-ratio: 16 / 10;
  border: 1px solid rgba(201, 240, 231, 0.1);
  border-radius: 22px;
  background: #071216;
  isolation: isolate;
}

.tree-scene {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
}

.technical-scale {
  color: rgba(224, 244, 239, 0.8);
  pointer-events: none;
}

.technical-scale path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.technical-scale .scale-guide {
  opacity: 0.35;
  stroke-dasharray: 4 6;
}

.technical-scale .scale-parts {
  opacity: 0.72;
}

.technical-scale text {
  fill: currentColor;
  stroke: rgba(5, 17, 19, 0.9);
  stroke-width: 5;
  paint-order: stroke fill;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.03em;
}

.zone-hit {
  cursor: pointer;
  outline: none;
}

.zone-hit:focus-visible .zone-ring {
  stroke: #fff;
  stroke-width: 5;
}

.zone-ring,
.zone-core,
.zone-person,
.root-path,
.tree-wash,
.tree-light,
.memory-ornament,
#tree-star {
  transition:
    opacity 160ms linear,
    fill 160ms linear,
    stroke 160ms linear,
    r 160ms linear,
    transform 160ms linear;
}

.scene-hud {
  position: absolute;
  inset: 20px 20px auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  pointer-events: none;
}

.state-copy {
  width: min(500px, 55%);
  padding: 16px 18px;
  border: 1px solid rgba(211, 238, 231, 0.1);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(5, 17, 19, 0.82), rgba(8, 26, 28, 0.42));
  backdrop-filter: blur(12px);
}

.state-code {
  color: var(--mint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.state-copy h3 {
  margin: 5px 0 4px;
  font-size: clamp(20px, 2.4vw, 34px);
  font-weight: 560;
  letter-spacing: -0.04em;
}

.state-copy p {
  margin-bottom: 0;
  color: #aac0bc;
  font-size: 13px;
}

.energy-card {
  width: min(290px, 36%);
  padding: 14px 16px;
  border: 1px solid rgba(211, 238, 231, 0.1);
  border-radius: 16px;
  background: rgba(5, 17, 19, 0.78);
  backdrop-filter: blur(12px);
}

.energy-row,
.energy-meta {
  justify-content: space-between;
  gap: 12px;
}

.energy-row {
  font-size: 12px;
}

.energy-row strong {
  color: var(--gold);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.energy-track {
  height: 7px;
  margin: 9px 0 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 99px;
}

.energy-track span {
  width: 0;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint), var(--gold));
  box-shadow: 0 0 16px rgba(86, 225, 191, 0.5);
  transition: width 100ms linear;
}

.energy-meta {
  color: var(--muted);
  font-size: 10px;
}

.presentation-help {
  position: absolute;
  left: 50%;
  bottom: 14px;
  padding: 8px 12px;
  color: rgba(224, 244, 239, 0.72);
  background: rgba(3, 12, 14, 0.58);
  border-radius: 99px;
  font-size: 10px;
  transform: translateX(-50%);
  pointer-events: none;
}

.scenario-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.scenario-button {
  min-height: 62px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  border-radius: 13px;
  color: #a8bbb7;
  font-size: 10px;
  font-weight: 650;
}

.scenario-button.is-active {
  color: var(--text);
  background: var(--mint-soft);
  border-color: rgba(86, 225, 191, 0.42);
}

.scenario-icon {
  color: var(--mint);
  font-size: 12px;
  letter-spacing: -0.1em;
}

.control-panel {
  max-height: calc(100vh - 118px);
  position: sticky;
  top: 12px;
  overflow: auto;
  border-radius: var(--radius-large);
  scrollbar-color: rgba(111, 158, 149, 0.35) transparent;
}

.panel-heading {
  position: sticky;
  top: 0;
  z-index: 4;
  justify-content: space-between;
  padding: 22px 22px 16px;
  background: linear-gradient(180deg, rgba(12, 27, 30, 0.99) 75%, transparent);
}

.control-section {
  padding: 18px 22px;
  border-top: 1px solid var(--line);
}

.section-heading {
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.section-heading h3 {
  font-size: 13px;
  font-weight: 730;
}

.section-tag {
  padding: 4px 7px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-description {
  margin: -3px 0 14px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.scale-metrics,
.topology-metrics {
  display: grid;
  margin: 0;
}

.scale-metrics {
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.scale-metrics div {
  min-width: 0;
  padding: 8px 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.018);
}

.scale-metrics dt,
.topology-metrics dt {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.scale-metrics dd,
.topology-metrics dd {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.topology-label {
  margin: 15px 0 8px;
  color: #b7c8c4;
  font-size: 11px;
}

.topology-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.topology-option {
  min-width: 0;
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 7px 6px;
  border-radius: 10px;
  text-align: left;
}

.topology-option strong {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topology-option span {
  color: var(--muted);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

.topology-option[aria-pressed="true"] {
  color: var(--text);
  background: var(--mint-soft);
  border-color: rgba(86, 225, 191, 0.42);
}

.topology-option[aria-pressed="true"] span {
  color: #bce9dd;
}

.topology-detail {
  margin-top: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.018);
}

.topology-detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topology-detail-heading strong {
  font-size: 11px;
}

.assumption-badge {
  padding: 3px 6px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.assumption-badge[data-status="benchmark"] {
  color: #bce9dd;
  background: var(--mint-soft);
  border-color: rgba(86, 225, 191, 0.35);
}

.assumption-badge[data-status="working"] {
  color: #f4dc9e;
  background: var(--gold-soft);
  border-color: rgba(243, 206, 120, 0.32);
}

.topology-metrics {
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 12px;
  margin-top: 12px;
}

.topology-metrics div {
  min-width: 0;
}

.topology-metrics dd {
  color: var(--mint);
}

.topology-power-metric,
.topology-rfq-metric {
  grid-column: 1 / -1;
}

.topology-power-metric small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.4;
}

.topology-detail > p {
  margin: 11px 0 0;
  color: #a8bbb7;
  font-size: 9px;
  line-height: 1.55;
}

.technical-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.button-grid {
  display: grid;
  gap: 8px;
}

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

.two-columns {
  grid-template-columns: repeat(2, 1fr);
}

.zone-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.zone-control {
  --zone-color: var(--mint);
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.018);
}

.zone-toggle {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  border-radius: 8px;
  color: #a9bbb8;
  font-size: 10px;
  font-weight: 700;
}

.zone-toggle::before {
  width: 7px;
  height: 7px;
  content: "";
  border-radius: 50%;
  background: var(--zone-color);
  box-shadow: 0 0 10px var(--zone-color);
}

.zone-control.is-active {
  border-color: color-mix(in srgb, var(--zone-color) 42%, transparent);
  background: color-mix(in srgb, var(--zone-color) 9%, transparent);
}

.zone-control.is-active .zone-toggle {
  color: var(--text);
}

.zone-motion-label {
  display: grid;
  gap: 4px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
}

.range-control {
  display: grid;
  gap: 8px;
  margin-top: 15px;
}

.range-control > span {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #b7c8c4;
  font-size: 11px;
}

output {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 2px 0;
  appearance: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  appearance: none;
  border: 3px solid #10282a;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 1px rgba(86, 225, 191, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 3px solid #10282a;
  border-radius: 50%;
  background: var(--mint);
}

.switch-control {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.018);
}

.switch-control span {
  display: grid;
  gap: 2px;
}

.switch-control strong {
  color: #c9d9d5;
  font-size: 11px;
}

.switch-control small {
  color: var(--muted);
  font-size: 9px;
}

input[type="checkbox"] {
  width: 34px;
  height: 20px;
  position: relative;
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background 150ms ease;
}

input[type="checkbox"]::after {
  width: 14px;
  height: 14px;
  position: absolute;
  top: 2px;
  left: 2px;
  content: "";
  border-radius: 50%;
  background: #8ba09c;
  transition:
    left 150ms ease,
    background 150ms ease;
}

input[type="checkbox"]:checked {
  background: var(--mint-soft);
  border-color: rgba(86, 225, 191, 0.55);
}

input[type="checkbox"]:checked::after {
  left: 16px;
  background: var(--mint);
}

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

.metrics-grid div {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.018);
}

.metrics-grid dt {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metrics-grid dd {
  margin: 3px 0 0;
  color: var(--mint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.frame-preview {
  max-height: 150px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 10px;
  color: #9dc8bd;
  background: #061013;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: 9px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

.event-log {
  display: grid;
  gap: 5px;
  max-height: 120px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.event-log li {
  padding: 6px 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 7px;
  font: 9px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.event-log time {
  color: var(--gold);
  margin-right: 6px;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 4px 28px;
  color: #738986;
  font-size: 10px;
}

.app-footer p {
  margin: 0;
}

body.presentation-mode {
  overflow: hidden;
}

body.presentation-mode .app-header,
body.presentation-mode .control-panel,
body.presentation-mode .scenario-strip,
body.presentation-mode .app-footer,
body.presentation-mode .stage-toolbar {
  display: none;
}

body.presentation-mode .app-shell {
  width: 100%;
  height: 100vh;
  display: block;
  margin: 0;
}

body.presentation-mode .stage-panel {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
}

body.presentation-mode .scene-frame {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    max-height: none;
    position: static;
  }

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

@media (max-width: 720px) {
  .app-header,
  .app-footer,
  .app-shell {
    width: min(100% - 24px, 1000px);
  }

  .app-header {
    min-height: 78px;
  }

  .brand-mark,
  .system-pill {
    display: none;
  }

  .button-ghost {
    width: 42px;
    min-width: 42px;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    font-size: 0;
    white-space: nowrap;
  }

  .button-ghost span {
    font-size: 18px;
  }

  .stage-panel {
    padding: 10px;
    border-radius: 18px;
  }

  .scene-frame {
    width: 100%;
    height: clamp(480px, 135vw, 570px);
    min-height: 0;
    aspect-ratio: auto;
    border-radius: 15px;
  }

  .scene-hud {
    inset: 10px 10px auto;
    display: grid;
  }

  .state-copy,
  .energy-card {
    width: min(100%, 330px);
  }

  .state-copy {
    padding: 12px 14px;
  }

  .state-copy p {
    display: none;
  }

  .energy-card {
    padding: 10px 12px;
  }

  .scenario-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .control-panel {
    border-radius: 18px;
  }

  .zone-controls {
    grid-template-columns: 1fr;
  }

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

  .app-footer {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}
