*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }
/* Layout: NOC console. HUD bar on top, network map left, CLI output panel right; stacks on phones. Single dark theme by choice. */
:root {
  --bg: #0D141C;
  --panel: #121C27;
  --raise: #182533;
  --line: #2A3B4D;
  --fg: #DCE6F0;
  --muted: #8A9BAE;
  --amber: #F2A541;
  --cyan: #5CC8D6;
  --amber-dim: rgba(242,165,65,.14);
  --cyan-dim: rgba(92,200,214,.12);
  --font-display: "Chakra Petch", "Trebuchet MS", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  color-scheme: dark;
}
html, body { background: var(--bg); color: var(--fg); }
body { font-family: var(--font-body); font-size: 15px; line-height: 1.55; }
.wrap {
  max-width: 1180px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 28px;
  display: grid; gap: 18px;
}

/* HUD */
.hud { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px 24px; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.id h1 { font-family: var(--font-display); font-weight: 700; font-size: clamp(28px, 5vw, 40px); letter-spacing: .04em; line-height: 1; margin: 0; text-wrap: balance; }
.id p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.id p b { color: var(--fg); font-weight: 500; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.chip strong { color: var(--fg); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim); }
.bar { width: 56px; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .4s ease; }
.chip.done { border-color: var(--amber); }
.chip.done strong { color: var(--amber); }

/* Main grid */
.main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.main .map { border-radius: 6px 6px 0 0; }
.main .panel { border-top: 0; border-radius: 0 0 6px 6px; }
.main .prompt { border-radius: 0; }
.out { padding: 20px 22px 24px; }
@media (min-width: 860px) {
  .out.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
  .out.cols .entry { border-top: 0; padding-top: 0; }
  .out.cols > h2, .out.cols > .now { grid-column: 1 / -1; }
}

.map {
  position: relative; border: 1px solid var(--line); border-radius: 6px;
  background-color: var(--panel);
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 22px 22px;
}
.map svg { display: block; width: 100%; height: auto; }
.map-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; padding: 8px 12px; border-top: 1px solid var(--line); font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; color: var(--fg); }

/* SVG parts */
.link { stroke: var(--line); stroke-width: 2; }
.link.lit { stroke: var(--amber); stroke-opacity: .7; }
.port { font-family: var(--font-mono); font-size: 11px; fill: var(--muted); }
.node { cursor: pointer; outline: none; }
.node .ring { fill: var(--bg); stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 5; transition: stroke .2s, fill .2s; }
.node .num { font-family: var(--font-display); font-weight: 600; font-size: 18px; fill: var(--muted); text-anchor: middle; dominant-baseline: central; }
.node .lbl { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: .08em; fill: var(--muted); text-anchor: middle; }
.node .halo { fill: none; stroke: var(--amber); stroke-width: 2; opacity: 0; transform-box: fill-box; transform-origin: center; }
.node.found .ring { stroke: var(--cyan); stroke-dasharray: none; }
.node.found .num, .node.found .lbl { fill: var(--fg); }
.node.active .ring { stroke: var(--amber); fill: var(--amber-dim); stroke-dasharray: none; }
.node.active .num { fill: var(--amber); }
.node.active .lbl { fill: var(--amber); }
.node.active .halo { animation: pulse 1.8s ease-out infinite; }
.node:hover .ring, .node:focus-visible .ring { stroke: var(--amber); }
.node:focus-visible .ring { stroke-width: 3; }
.node.core .num { font-size: 15px; letter-spacing: .06em; }
.node .lbl { paint-order: stroke; stroke: var(--panel); stroke-width: 5px; stroke-linejoin: round; }
.node.sub .num { font-size: 12px; }
.node.sub .lbl { font-size: 13px; letter-spacing: .06em; }
.link.sub { stroke-dasharray: 4 4; }
.node.sub, .link.sub { transition: opacity .3s ease, visibility .3s; }
.collapsed { opacity: 0; visibility: hidden; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .node.sub, .link.sub { transition: none; } }
@keyframes pulse { 0% { opacity: .8; transform: scale(1); } 100% { opacity: 0; transform: scale(1.6); } }
.packet { fill: var(--amber); }
.packet.idle { fill: var(--cyan); opacity: .55; }

/* CLI panel */
.panel { border: 1px solid var(--line); border-radius: 6px; background: var(--panel); min-width: 0; display: grid; }
.prompt { font-family: var(--font-mono); font-size: 13px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--raise); border-radius: 6px 6px 0 0; color: var(--muted); overflow-x: auto; white-space: nowrap; }
.prompt .host { color: var(--cyan); }
.prompt .cmd { color: var(--fg); }
.cursor { display: inline-block; width: 8px; height: 15px; background: var(--amber); vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.out { padding: 18px 18px 20px; display: grid; gap: 14px; min-width: 0; transition: opacity .2s; }
.out.fading { opacity: 0; }
.out h2 { font-family: var(--font-display); font-weight: 600; font-size: 22px; letter-spacing: .03em; margin: 0; line-height: 1.2; text-wrap: balance; }
.out h3 { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin: 0; line-height: 1.25; }
.out p { margin: 0; max-width: 62ch; }
.meta { font-family: var(--font-mono); font-size: 12px; color: var(--muted); letter-spacing: .03em; }
.out ul { margin: 0; padding-left: 18px; display: grid; gap: 5px; }
.out li::marker { color: var(--amber); }
.entry { display: grid; gap: 6px; padding-top: 14px; border-top: 1px dashed var(--line); }
.entry:first-of-type { border-top: 0; padding-top: 0; }
.now { font-size: 14px; color: var(--muted); }
.now b { color: var(--amber); font-weight: 500; }

.table { overflow-x: auto; }
.table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { font-family: var(--font-mono); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-align: left; padding: 0 10px 6px 0; border-bottom: 1px solid var(--line); }
.table td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table td:first-child { font-family: var(--font-mono); font-size: 13px; color: var(--cyan); white-space: nowrap; }
.st { font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.st.up { color: var(--cyan); }
.st.prog { color: var(--amber); }

.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 12px; }
.flow span { border: 1px solid var(--line); background: var(--raise); border-radius: 3px; padding: 3px 7px; }
.flow em { font-style: normal; color: var(--amber); }

.ph { color: var(--amber); border: 1px dashed var(--amber); border-radius: 3px; padding: 0 4px; font-family: var(--font-mono); font-size: .9em; }
.copy { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: transparent; color: var(--fg); border: 1px solid var(--line); border-radius: 3px; padding: 3px 8px; cursor: pointer; }
.copy:hover, .copy:focus-visible { border-color: var(--amber); color: var(--amber); outline: none; }
a { color: var(--cyan); text-underline-offset: 3px; }
a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

footer { font-family: var(--font-mono); font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  .node.active .halo, .cursor { animation: none; }
  .out, .bar i { transition: none; }
}
