:root {
  --bg0: #0c1210;
  --bg1: #152019;
  --fg: #e6efe8;
  --muted: #8fa396;
  --accent: #3dce8a;
  --accent-dim: #2a8f5f;
  --line: rgba(230, 239, 232, 0.12);
  --danger: #e07070;
  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Figtree", "Avenir Next", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--fg);
  background:
    radial-gradient(900px 480px at 12% -8%, #1f3a2c 0%, transparent 55%),
    radial-gradient(700px 400px at 90% 10%, #243528 0%, transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 55%, #0a100e);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { width: min(1080px, 92vw); margin: 0 auto; padding: 1.25rem 0 4rem; }

.topnav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.5rem 0 1.5rem;
}
.topnav .mark {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em;
  color: var(--fg); text-decoration: none;
}
.topnav nav { display: flex; gap: 1.1rem; font-size: 0.95rem; }
.topnav nav a { color: var(--muted); text-decoration: none; }
.topnav nav a:hover, .topnav nav a.active { color: var(--fg); }

.hero {
  min-height: min(78vh, 640px);
  display: grid;
  align-content: end;
  padding: 2rem 0 3rem;
  border-bottom: 1px solid var(--line);
}
.hero .brand {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 12vw, 6.5rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
  margin: 0 0 1rem;
  font-weight: 700;
}
.hero .lede {
  max-width: 28rem;
  color: var(--muted);
  font-size: 1.1rem;
  margin: 0 0 1.75rem;
}
.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.7rem 1.15rem;
  border-radius: 4px;
  border: 1px solid transparent;
  font: inherit; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #062016; }
.btn-primary:hover { background: #54e09a; text-decoration: none; }
.btn-ghost {
  background: transparent; color: var(--fg);
  border-color: var(--line);
}
.btn-ghost:hover { border-color: var(--muted); text-decoration: none; }

.page-head { padding: 0.5rem 0 1.5rem; }
.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.8rem);
  margin: 0 0 0.35rem;
  letter-spacing: -0.03em;
}
.page-head p { margin: 0; color: var(--muted); max-width: 36rem; }

.panel {
  border-top: 1px solid var(--line);
  padding: 1.25rem 0;
}
.panel h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.75rem;
  font-weight: 600;
}

.label { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.25rem; }
.mono { font-family: var(--font-mono); font-size: 0.85rem; word-break: break-all; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 0.9rem; }
.ok { color: var(--accent); }

.form-grid {
  display: grid;
  gap: 0.85rem;
  max-width: 28rem;
}
.form-grid label { display: grid; gap: 0.3rem; font-size: 0.9rem; }
input, textarea, select {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 4px;
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}
input:focus, textarea:focus { outline: 1px solid var(--accent-dim); }

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}
.stat strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 500;
}
.stat span { color: var(--muted); font-size: 0.8rem; }

.blocks { display: grid; gap: 0.5rem; }
.block-row {
  display: grid;
  grid-template-columns: 5rem 1fr auto;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.block-row .hash { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: var(--muted);
}
.dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: var(--muted);
}
.dot.on { background: var(--accent); }
.dot.off { background: var(--danger); }

.foot {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}

.legal {
  max-width: 42rem;
  padding: 0.5rem 0 2rem;
}
.legal h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.5rem;
}
.legal-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}
.legal h2 {
  font-size: 1.05rem;
  margin: 1.75rem 0 0.55rem;
  letter-spacing: -0.01em;
}
.legal p, .legal li {
  color: rgba(230, 239, 232, 0.92);
  font-size: 0.98rem;
}
.legal ul { padding-left: 1.2rem; }
.legal li { margin: 0.35rem 0; }
.legal code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: rgba(230, 239, 232, 0.06);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

@media (max-width: 640px) {
  .block-row { grid-template-columns: 1fr; }
}

/* ---------- network map ---------- */
[hidden] { display: none !important; }
:root {
  --warn: #e3b341;
  --crit: var(--danger);
  --offline: #5b6a61;
  --unknown: #8fa396;
}
.shell-wide { width: min(1440px, 95vw); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
.net-age { font-size: 0.8rem; margin: 0.25rem 0 0; }
.net-note {
  margin: 0.75rem 0 0; padding: 0.5rem 0.75rem; font-size: 0.85rem;
  border: 1px solid rgba(227, 179, 65, 0.4); border-radius: 4px; color: var(--warn);
}
.net-summary { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.net-summary .stat.bad strong { color: var(--crit); }
.epoch-bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 0.35rem; overflow: hidden; }
.epoch-bar > div { height: 100%; background: var(--accent-dim); width: 0; transition: width 0.4s; }
.sev-critical, .stat .sev-critical { color: var(--crit); }
.sev-warn, .stat .sev-warn { color: var(--warn); }
.sev-info, .stat .sev-info { color: var(--muted); }

.net-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.net-toolbar input[type="search"] { width: 15rem; max-width: 100%; }
.net-toolbar select { width: auto; font-family: var(--font-body); }
.net-toolbar input, .net-toolbar select { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.net-toolbar .spacer { flex: 1; }
.net-toolbar .check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); }
.net-toolbar .check input { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg button {
  background: transparent; color: var(--muted); border: 0; padding: 0.4rem 0.8rem;
  font: inherit; font-size: 0.85rem; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: rgba(61, 206, 138, 0.14); color: var(--fg); }

.net-layout { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 1rem; }
.net-main { min-width: 0; }
.net-stage {
  position: relative; height: min(72vh, 720px); min-height: 420px;
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, rgba(61, 206, 138, 0.05), transparent 65%), rgba(0, 0, 0, 0.18);
}
#net-svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; user-select: none; }
#net-svg:active { cursor: grabbing; }
.net-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; }

.net-edge-line { stroke: rgba(230, 239, 232, 0.28); fill: none; stroke-linecap: round; }
.net-edge-hit { stroke: transparent; stroke-width: 12; vector-effect: non-scaling-stroke; cursor: pointer; }
.net-edge.k-relay .net-edge-line { stroke: rgba(61, 206, 138, 0.38); }
.net-edge.h-warn .net-edge-line { stroke: var(--warn); }
.net-edge.h-critical .net-edge-line { stroke: var(--crit); }
.net-edge.one-sided .net-edge-line { stroke-dasharray: 5 5; }
.net-edge.pulse .net-edge-line { animation: net-pulse 1.6s ease-in-out infinite; }
.net-edge:hover .net-edge-line, .net-edge.selected .net-edge-line { stroke: var(--fg); }
@keyframes net-pulse { 50% { opacity: 0.35; } }

.net-node { cursor: pointer; outline: none; }
.net-node .net-shape { fill: var(--accent); stroke: #0c1210; stroke-width: 1.5; transition: fill 0.3s; }
.net-node.h-warn .net-shape { fill: var(--warn); }
.net-node.h-critical .net-shape { fill: var(--crit); }
.net-node.h-offline .net-shape { fill: var(--offline); }
.net-node.h-unknown .net-shape { fill: var(--unknown); }
.net-node.r-relay .net-shape { stroke: var(--fg); stroke-width: 2; }
.net-node.ghost .net-shape { fill: transparent; stroke: var(--offline); stroke-dasharray: 3 3; stroke-width: 1.5; }
.net-node.ghost.h-offline .net-shape { stroke: var(--crit); }
.net-node .net-ring { fill: none; stroke: transparent; stroke-width: 2; }
.net-node.leader-soon .net-ring { stroke: rgba(230, 239, 232, 0.55); stroke-dasharray: 2 3; }
.net-node.leader-now .net-ring { stroke: var(--fg); stroke-dasharray: none; }
.net-node.selected .net-ring, .net-node:focus-visible .net-ring { stroke: var(--accent); stroke-width: 3; stroke-dasharray: none; }
.net-node .net-badge { display: none; }
.net-node.flagged .net-badge { display: inline; }
.net-node .net-badge circle { fill: var(--crit); stroke: #0c1210; stroke-width: 1.5; }
.net-node.pinned .net-shape { stroke: var(--fg); stroke-dasharray: none; }
.net-label {
  fill: var(--muted); font-family: var(--font-mono); font-size: 10px;
  pointer-events: none; display: none;
}
.net-node.r-relay .net-label, #net-svg.zoomed .net-label,
.net-node:hover .net-label, .net-node.selected .net-label, .net-node.h-critical .net-label { display: inline; }
.net-node.r-relay .net-label { fill: var(--fg); }

.net-node.hidden, .net-edge.hidden { display: none; }
#net-svg.focusing .net-node:not(.focus) { opacity: 0.18; }
#net-svg.focusing .net-edge:not(.focus) { opacity: 0.08; }

.net-zoom {
  position: absolute; left: 0.6rem; top: 0.6rem; display: grid; gap: 0.25rem;
}
.net-zoom button {
  width: 2rem; height: 2rem; border-radius: 4px; border: 1px solid var(--line);
  background: rgba(12, 18, 16, 0.85); color: var(--fg); font: inherit; cursor: pointer;
}
.net-zoom button:hover { border-color: var(--muted); }

.net-tooltip {
  position: absolute; z-index: 3; pointer-events: none; max-width: 220px;
  background: rgba(12, 18, 16, 0.96); border: 1px solid var(--line); border-radius: 4px;
  padding: 0.45rem 0.6rem; font-size: 0.78rem; line-height: 1.45;
}
.hb {
  display: inline-block; padding: 0 0.4rem; border-radius: 3px; font-size: 0.72rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: rgba(61, 206, 138, 0.16); color: var(--accent);
}
.hb.h-warn { background: rgba(227, 179, 65, 0.16); color: var(--warn); }
.hb.h-critical { background: rgba(224, 112, 112, 0.18); color: var(--crit); }
.hb.h-offline { background: rgba(91, 106, 97, 0.3); color: #b5c2b9; }
.hb.h-unknown { background: rgba(143, 163, 150, 0.16); color: var(--muted); }

.net-drawer {
  position: absolute; z-index: 2; top: 0; right: 0; bottom: 0; width: min(380px, 100%);
  overflow-y: auto; padding: 0.9rem 1rem 1.25rem;
  background: rgba(12, 18, 16, 0.97); border-left: 1px solid var(--line);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.drawer-close { background: none; border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.drawer-close:hover { color: var(--fg); }
.drawer-id { margin: 0.5rem 0 0.25rem; font-size: 0.8rem; }
.net-drawer h3 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 1.1rem 0 0.4rem; font-weight: 600;
}
.role-badge { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.kv {
  display: flex; justify-content: space-between; gap: 1rem; font-size: 0.85rem;
  padding: 0.2rem 0; border-bottom: 1px dashed rgba(230, 239, 232, 0.06);
}
.kv > span:first-child { color: var(--muted); }
.kv > span:last-child { text-align: right; }
.kv.bad > span:last-child { color: var(--crit); }
.copy, .link {
  background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer;
}
.copy { font-family: var(--font-body); font-size: 0.75rem; margin-left: 0.35rem; }
.link:hover, .copy:hover { text-decoration: underline; }
.spark { margin: 0.6rem 0 0; }
.spark svg { width: 100%; height: 44px; display: block; background: rgba(0, 0, 0, 0.2); border-radius: 3px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark figcaption { font-size: 0.72rem; color: var(--muted); margin-top: 0.2rem; }

.net-side h2 { display: flex; justify-content: space-between; align-items: baseline; }
.net-issues { display: grid; gap: 0.35rem; max-height: min(72vh, 720px); overflow-y: auto; padding-right: 0.25rem; }
.net-issue {
  display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.5rem; align-items: baseline;
  text-align: left; width: 100%; padding: 0.5rem 0.6rem; font: inherit; font-size: 0.82rem;
  color: var(--fg); background: rgba(0, 0, 0, 0.18); border: 1px solid var(--line);
  border-left: 3px solid var(--muted); border-radius: 4px;
}
button.net-issue { cursor: pointer; }
button.net-issue:hover, .net-issue.active { border-color: var(--muted); background: rgba(230, 239, 232, 0.05); }
.net-issue.sev-critical { border-left-color: var(--crit); }
.net-issue.sev-warn { border-left-color: var(--warn); }
.net-issue .sev { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.net-issue.sev-critical .sev { color: var(--crit); }
.net-issue.sev-warn .sev { color: var(--warn); }
.net-issue .code { font-weight: 600; }
.net-issue .msg { grid-column: 1 / -1; color: var(--muted); word-break: break-word; }
.net-issue.static { margin-bottom: 0.3rem; }
.net-more { width: 100%; font-size: 0.8rem; padding: 0.45rem; }

.net-legend {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin-top: 0.6rem;
  font-size: 0.75rem; color: var(--muted); align-items: center;
}
.net-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.net-legend svg { width: 14px; height: 14px; }
.net-legend .lg-shape { fill: var(--accent); stroke: var(--fg); stroke-width: 1; }
.net-legend .lg-ghost { fill: none; stroke: var(--offline); stroke-dasharray: 3 2; }
.net-legend .lg-ring { fill: none; stroke: var(--fg); stroke-width: 1.5; }
.net-legend .lg-dash { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 4 3; }
.net-legend svg[viewBox="0 0 24 10"] { width: 24px; height: 10px; }
.sw { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--accent); }
.sw.h-warn { background: var(--warn); }
.sw.h-critical { background: var(--crit); }
.sw.h-offline { background: var(--offline); }

.net-table-wrap, .table-wrap { overflow-x: auto; }
.net-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.net-table th, .net-table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.net-table th button {
  background: none; border: 0; padding: 0; font: inherit; font-size: 0.75rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer;
}
.net-table tbody tr { cursor: pointer; }
.net-table tbody tr:hover, .net-table tbody tr:focus { background: rgba(230, 239, 232, 0.04); outline: none; }
.net-table td:last-child { white-space: normal; min-width: 16rem; }
.net-table.compact { font-size: 0.78rem; margin-top: 0.5rem; }
.net-table.compact th, .net-table.compact td { padding: 0.3rem 0.35rem; }
.net-table tr.h-warn td:first-child { box-shadow: inset 2px 0 var(--warn); }
.net-table tr.h-critical td:first-child { box-shadow: inset 2px 0 var(--crit); }
.chip {
  display: inline-block; font-size: 0.7rem; padding: 0 0.35rem; margin: 0.1rem 0;
  border: 1px solid var(--line); border-radius: 3px; color: var(--muted);
}
.net-source-box summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 1000px) {
  .net-layout { grid-template-columns: 1fr; }
  .net-issues { max-height: 50vh; }
}
@media (max-width: 640px) {
  .net-stage { height: 62vh; min-height: 360px; }
  .net-toolbar input[type="search"] { width: 100%; }
  .net-drawer { width: 100%; }
}
