:root {
  color-scheme: dark;
  --ink: #f1f8f7;
  --muted: #9eb8b9;
  --surface: #061315;
  --surface-2: #0a2021;
  --line: #24494b;
  --cyan: #61e6df;
  --cyan-soft: #2aa9a5;
  --amber: #ffb84a;
  --red: #ff7167;
  --shadow: rgba(0, 0, 0, 0.36);
  font-family: "Segoe UI", Arial, sans-serif;
  background: #030c0e;
  color: var(--ink);
}

* { box-sizing: border-box; }
html { background: #030c0e; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 60% 18%, #0b2627 0, #030c0e 38rem); }
button, a { font: inherit; }
a { color: inherit; }

.topbar {
  min-height: 68px;
  padding: 0 4vw;
  display: flex;
  align-items: center;
  gap: 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 12, 14, 0.9);
}
.brand { font-size: 1.3rem; font-weight: 850; letter-spacing: 0.12em; text-decoration: none; }
.mode, .connection, .eyebrow, .run-meta { font: 700 0.72rem/1.2 ui-monospace, "Cascadia Mono", monospace; letter-spacing: 0.12em; text-transform: uppercase; }
.mode { display: flex; align-items: center; gap: 9px; color: var(--cyan); }
.mode span { width: 8px; height: 8px; background: var(--cyan); transform: rotate(45deg); }
.connection { margin-left: auto; color: var(--muted); }
.connection.ready { color: var(--cyan); }
.connection.stale { color: var(--amber); }

main { width: min(1600px, 94vw); margin: 0 auto; }
.intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, 31rem); gap: 5vw; align-items: end; padding: clamp(54px, 8vw, 120px) 0 42px; }
.eyebrow { margin: 0 0 12px; color: var(--cyan); }
h1, h2, p { margin-top: 0; }
h1 { max-width: 850px; margin-bottom: 0; font-size: clamp(3.1rem, 7vw, 7.4rem); line-height: 0.87; letter-spacing: -0.065em; }
.intro > p { margin-bottom: 4px; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.3rem); line-height: 1.55; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, 390px); border: 1px solid var(--line); box-shadow: 0 28px 90px var(--shadow); }
.map-panel { min-width: 0; padding: clamp(18px, 2.4vw, 36px); background: rgba(6, 19, 21, 0.88); }
.panel-heading, .rail-heading, .run-meta { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.panel-heading h2 { margin-bottom: 0; font-size: clamp(1.5rem, 2.5vw, 2.35rem); }
.run-meta { color: var(--muted); text-align: right; flex-direction: column; gap: 6px; }

.map { display: none; width: 100%; height: auto; margin-top: 20px; color: var(--cyan-soft); border: 1px solid var(--line); background: #041012; }
.viewer-ready .map { display: block; }
.viewer-ready .static-fallback { display: none; }
.map-base { fill: #041012; }
.map-grid { color: #235052; }
.terrain path { fill: none; stroke: #1d484a; stroke-width: 2; }
.zones path { fill: rgba(255, 184, 74, 0.035); stroke: #6a5a37; stroke-width: 1.5; stroke-dasharray: 8 9; }
.zones text { fill: #7e765d; font: 600 14px ui-monospace, monospace; letter-spacing: 0.16em; }
.uncertainty { fill: rgba(255, 184, 74, 0.08); stroke: var(--amber); stroke-width: 2; stroke-dasharray: 6 6; }
.network-link { fill: none; stroke: var(--cyan); stroke-width: 4; opacity: 0.76; filter: url(#glow); }
.network-link.degraded { stroke: var(--amber); stroke-dasharray: 12 10; opacity: 0.9; }
.node { cursor: pointer; outline: none; }
.node .hit { fill: transparent; }
.node .mark { fill: #071719; stroke: var(--ink); stroke-width: 4; }
.node.direct .mark { stroke: var(--cyan); }
.node.estimated .mark { stroke: var(--amber); }
.node.degraded .mark { fill: #302315; }
.node:focus .focus-ring, .node:hover .focus-ring { opacity: 1; }
.focus-ring { fill: none; stroke: var(--ink); stroke-width: 2; opacity: 0; }
.node-label { fill: var(--ink); font: 700 14px ui-monospace, monospace; letter-spacing: 0.04em; paint-order: stroke; stroke: #041012; stroke-width: 5px; }

.static-fallback, .noscript { margin-top: 20px; padding: clamp(24px, 4vw, 54px); border: 1px solid var(--line); color: var(--muted); min-height: 380px; background: radial-gradient(circle at 72% 42%, #124143 0, #071719 32%, #041012 66%); }
.static-fallback strong { color: var(--ink); font-size: 1.35rem; }
.static-fallback p { max-width: 42rem; margin-top: 14px; line-height: 1.6; }
.map-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 16px; color: var(--muted); font: 650 0.75rem ui-monospace, monospace; }
.map-legend span { display: inline-flex; align-items: center; gap: 7px; }
.map-legend i { width: 18px; height: 10px; display: inline-block; border: 2px solid var(--cyan); }
.map-legend .legend-estimated { border-color: var(--amber); border-radius: 50%; border-style: dashed; }
.map-legend .legend-link { height: 0; border: 0; border-top: 2px solid var(--cyan); }
.map-legend .legend-degraded { height: 0; border: 0; border-top: 2px dashed var(--amber); }

.state-rail { border-left: 1px solid var(--line); background: rgba(4, 16, 18, 0.96); }
.state-rail section { padding: 25px; border-bottom: 1px solid var(--line); }
.rail-heading span { color: var(--muted); font: 650 0.75rem ui-monospace, monospace; }
.node-list, .service-list { display: grid; gap: 8px; }
.node-button, .service-card { width: 100%; padding: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; }
.node-button { display: grid; grid-template-columns: 9px 1fr auto; gap: 10px; align-items: center; cursor: pointer; }
.node-button:hover, .node-button:focus-visible, .node-button[aria-pressed="true"] { border-color: var(--cyan); background: var(--surface-2); outline: none; }
.node-button .state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); }
.node-button .state-dot.degraded { background: var(--amber); }
.node-button .state-dot.unknown { background: var(--muted); }
.node-button small { color: var(--muted); }
.selection h2 { font-size: 1.45rem; margin-bottom: 8px; }
.selection p:last-child { color: var(--muted); line-height: 1.5; margin-bottom: 0; }
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 15px 0 0; font-size: 0.85rem; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; text-align: right; }
.service-card { display: flex; justify-content: space-between; gap: 12px; }
.service-card strong { font-size: 0.9rem; }
.service-card span { color: var(--cyan); font: 700 0.7rem ui-monospace, monospace; text-transform: uppercase; }
.service-card .reduced { color: var(--amber); }
.change-list { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: 0.84rem; line-height: 1.5; }
.change-list li + li { margin-top: 8px; }

.explanation { padding: clamp(60px, 9vw, 130px) 0; }
.explanation h2 { max-width: 850px; font-size: clamp(2.4rem, 5.5vw, 5.4rem); line-height: 0.95; letter-spacing: -0.055em; }
.explanation-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.explanation-grid p { margin: 0; padding: 25px; color: var(--muted); background: #030c0e; line-height: 1.55; }
.explanation-grid strong { display: block; color: var(--ink); margin-bottom: 8px; }

@media (max-width: 940px) {
  .intro { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: 1fr; }
  .state-rail { border-left: 0; border-top: 1px solid var(--line); }
  .explanation-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 18px; gap: 12px; }
  .mode { display: none; }
  main { width: calc(100vw - 28px); }
  .intro { padding-top: 46px; }
  h1 { font-size: clamp(3rem, 16vw, 4.6rem); }
  .map-panel { padding: 13px; }
  .panel-heading { display: block; }
  .run-meta { margin-top: 14px; text-align: left; align-items: flex-start; }
  .map-legend { gap: 12px; }
  .state-rail section { padding: 20px; }
}

@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; }
}
