:root {
  --bg: #081018;
  --bg-2: #0c1622;
  --panel: #101a27;
  --line: rgba(176, 206, 224, 0.14);
  --text: #e7eef6;
  --muted: #8ea0b3;
  --faint: rgba(231, 238, 246, 0.42);
  --cyan: #3ddec8;
  --cyan-ink: #07332d;
  --amber: #e2b15a;
  --coral: #e07a68;
  --blue: #7eb0cc;
  --violet: #c2b0f2;
  --ok: #8dcea8;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --sans: Outfit, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(900px 420px at 18% -10%, rgba(61, 222, 200, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

.app {
  height: 100vh;
  min-height: 640px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.top {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.brand { min-width: 180px; }

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}

.scenarios {
  display: flex;
  gap: 6px;
  flex: 1;
}

.scenarios button,
.transport button,
.seg button,
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
}

.scenarios button.is-on,
.seg button.is-on {
  color: var(--cyan-ink);
  background: var(--cyan);
  border-color: var(--cyan);
}

.transport { display: flex; gap: 6px; align-items: center; }

.transport button.primary {
  background: var(--cyan);
  color: var(--cyan-ink);
  border-color: var(--cyan);
  font-weight: 600;
  min-width: 78px;
}

.transport button:hover,
.scenarios button:hover,
.seg button:hover,
.ghost:hover { border-color: rgba(61, 222, 200, 0.45); }

.scenarios button.is-on:hover,
.seg button.is-on:hover,
.transport button.primary:hover { border-color: var(--cyan); }

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 332px;
  min-height: 0;
}

.map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 80px),
    var(--bg-2);
}

#world {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.legend, .hint, .readout {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

.legend {
  top: 14px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-width: calc(100% - 150px);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8, 16, 24, 0.72);
  backdrop-filter: blur(8px);
  font-size: 12px;
  color: var(--muted);
}

.legend span { display: flex; align-items: center; gap: 6px; }

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.swatch.est { background: var(--cyan); }
.swatch.part { background: var(--violet); }
.swatch.truth { background: transparent; border: 1.5px solid #bac6d6; }
.swatch.odom { background: var(--coral); }
.swatch.lm { background: var(--amber); }

.readout {
  top: 14px;
  right: 14px;
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.readout b { font-weight: 500; color: var(--cyan); }
.readout .dim { color: var(--muted); }

.hint {
  left: 14px;
  bottom: 16px;
  color: var(--faint);
  font-size: 12px;
  max-width: 70%;
}

aside {
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
  padding: 14px 14px 18px;
}

.blurb {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.narrative {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 2px solid var(--cyan);
  background: rgba(61, 222, 200, 0.06);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  min-height: 3.8em;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.stat {
  padding: 8px 10px 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat.wide { grid-column: 1 / -1; }

.stat strong {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.health {
  min-height: 1.2em;
  margin: 4px 2px 12px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

.health.ok { color: var(--ok); }
.health.bad { color: var(--coral); }
.health.warn { color: var(--amber); }

.block { margin: 14px 0; }

.block.first { margin-top: 0; }

.is-hidden { display: none !important; }

.block h2, .foot h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: baseline;
  margin-top: 9px;
}

.row label { font-size: 13px; }

.row output {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--cyan);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  margin: 6px 0 0;
  background: rgba(176, 206, 224, 0.28);
  border-radius: 99px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--cyan);
  border: none;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: none;
  border-radius: 50%;
  background: var(--cyan);
  cursor: pointer;
}

.help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.seg { display: flex; gap: 6px; }

.seg button { flex: 1; border-radius: 9px; padding-left: 8px; padding-right: 8px; }

#filter-seg button { font-size: 13px; }

.toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
}

.toggles label {
  display: flex;
  gap: 7px;
  align-items: center;
  font-size: 13px;
  color: var(--text);
}

input[type="checkbox"] { accent-color: var(--cyan); }

.mode-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.mode-line strong { font-weight: 600; font-size: 13.5px; }

.ghost { border-radius: 999px; padding: 5px 10px; font-size: 12px; }

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

.log li.close { color: var(--cyan); }
.log li.init { color: var(--amber); }
.log li.warn { color: var(--coral); }

.foot {
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(240px, 1fr) 210px;
  gap: 14px;
  align-items: stretch;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  background: rgba(8, 16, 24, 0.92);
  min-height: 168px;
}

.eq { display: flex; flex-direction: column; justify-content: center; gap: 7px; }

.eq p {
  margin: 0;
  padding: 7px 9px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.eq p b {
  display: inline-block;
  min-width: 64px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.eq p.is-on {
  color: var(--text);
  background: rgba(61, 222, 200, 0.08);
}

.eq p.is-on b { color: var(--cyan); }

.plot h2 { display: flex; justify-content: space-between; }

.plot h2 span { letter-spacing: 0; text-transform: none; font-weight: 400; }

.swatch-line {
  display: inline-block;
  width: 14px;
  height: 2px;
  margin: 0 4px 3px 8px;
  vertical-align: middle;
}

.swatch-line.err { background: var(--coral); }
.swatch-line.sig { background: var(--cyan); }

#spark, #cov {
  width: 100%;
  height: 124px;
  display: block;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 8px;
  border: 1px solid var(--line);
}

.cov-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.copyright {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--faint);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-align: right;
}

.copyright a {
  color: inherit;
  text-decoration: none;
}

.copyright a:hover { color: var(--cyan); }

@media (max-width: 1100px) {
  .top { flex-wrap: wrap; gap: 10px; }
  .stage { grid-template-columns: 1fr; }
  aside {
    border-left: none;
    border-top: 1px solid var(--line);
    max-height: 46vh;
  }
  .foot { grid-template-columns: 1fr; }
  .app { height: auto; min-height: 100vh; }
  .map-wrap { height: 68vh; min-height: 420px; }
}
