:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #141a2b;
  --muted: #5d667d;
  --line: #e3e6ef;
  --grid: #eceef4;
  --c1: #3b5bdb;   /* CPU */
  --c2: #0ca678;   /* memory */
  --c3: #f08c00;   /* requests */
  --c4: #ae3ec9;   /* round trip */
  --c5: #1098ad;   /* tcp rtt */
  --warn: #e8590c;
  --hero-a: #0b1430;
  --hero-b: #13235a;
  --ok: #2fb344;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1020;
    --surface: #141a2e;
    --ink: #e8ebf5;
    --muted: #98a1ba;
    --line: #232b45;
    --grid: #1c2339;
    --c1: #7b93ff;
    --c2: #3fd6a2;
    --c3: #ffb347;
    --c4: #da77f2;
    --c5: #3bc9db;
    --warn: #ff922b;
    --hero-a: #070b18;
    --hero-b: #0f1a40;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
h1, h2 { margin: 0; }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 20px; }

/* Hero */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(160deg, var(--hero-a), var(--hero-b));
  padding: calc(72px + env(safe-area-inset-top, 0px)) 20px 96px;
}
#waves { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-inner { position: relative; max-width: 1120px; margin: 0 auto; }
.hero h1 {
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.lede { max-width: 34rem; margin: 14px 0 0; color: #c7cfee; font-size: 1.08rem; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 0 16px; padding: 5px 12px; border-radius: 999px;
  background: rgba(255,255,255,.1); font-size: .82rem; color: #dfe5ff;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #8891aa; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 0 rgba(47,179,68,.6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(47,179,68,0); } 100% { box-shadow: 0 0 0 0 rgba(47,179,68,0); } }

/* Tiles */
.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px;
  margin-top: -48px; position: relative;
}
.tile, .card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px -12px rgba(16,24,40,.12);
}
.tile { padding: 16px 18px; }
.tile h2, .card h2 { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.big { margin: 6px 0 2px; font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.big small { font-size: 1rem; color: var(--muted); margin-left: 2px; font-weight: 600; }
.sub { margin: 0; color: var(--muted); font-size: .88rem; }

/* Cards */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 14px 0 0; }
.card { padding: 18px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.legend { display: flex; gap: 14px; margin: 0; padding: 0; list-style: none; font-size: .85rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.sw-1 { background: var(--c1); } .sw-2 { background: var(--c2); }
.sw-4 { background: var(--c4); } .sw-5 { background: var(--c5); }
.pill { font-size: .78rem; padding: 3px 10px; border-radius: 999px; background: var(--grid); color: var(--muted); font-weight: 600; }
.pill.good { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.fair { background: color-mix(in srgb, var(--c3) 18%, transparent); color: var(--c3); }
.pill.poor { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* You <-> Server */
.link { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 8px 4px; }
.node { display: grid; justify-items: center; text-align: center; gap: 2px; min-width: 96px; max-width: 220px; }
.node svg { width: 40px; height: 40px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 4px; }
.node span { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.wire { position: relative; height: 40px; }
.wire::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px dashed var(--line); }
.packet {
  position: absolute; top: 50%; left: 0; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%;
  background: var(--c4); box-shadow: 0 0 12px var(--c4);
  animation: travel var(--trip, 2s) ease-in-out infinite alternate;
}
@keyframes travel { from { left: 0; } to { left: 100%; } }
.wire-label {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -150%);
  font-size: .95rem; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface); padding: 0 8px;
}

/* Facts */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* Latency list */
.lat { list-style: none; margin: 0; padding: 0; display: grid; }
.lat li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lat li:first-child { padding-top: 0; }
.lat div { display: grid; }
.lat div span { font-size: .8rem; color: var(--muted); }
.lat strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lat small { font-size: .8rem; color: var(--muted); margin-left: 3px; font-weight: 600; }
.lat-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.lat-foot button {
  font: inherit; font-size: .85rem; font-weight: 600; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.lat-foot button:hover:not(:disabled) { border-color: var(--c4); }
.lat-foot button:disabled { opacity: .55; cursor: default; }
.chart { position: relative; height: 240px; }
.chart.short { height: 160px; }
.chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.note { margin: 10px 0 0; font-size: .8rem; color: var(--muted); }

/* Ring */
.ring-wrap { position: relative; width: 180px; max-width: 100%; aspect-ratio: 1; margin: 6px auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--grid); stroke-width: 12; }
.ring-fill {
  fill: none; stroke: var(--c2); stroke-width: 12; stroke-linecap: round;
  stroke-dasharray: 314.16; stroke-dashoffset: 314.16; transition: stroke-dashoffset .8s ease;
}
.ring-text { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-text strong { font-size: 1.9rem; font-variant-numeric: tabular-nums; }
.ring-text span { font-size: .85rem; color: var(--muted); }

/* Load */
.load { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 16px; }
.load li { display: grid; grid-template-columns: 56px 52px 1fr; align-items: center; gap: 10px; }
.load span { color: var(--muted); font-size: .88rem; }
.load b { font-variant-numeric: tabular-nums; text-align: right; }
.load i { display: block; height: 10px; border-radius: 6px; background: var(--grid); overflow: hidden; }
.load em { display: block; height: 100%; width: 0; background: var(--c1); border-radius: 6px; transition: width .8s ease; }

/* Cores heatmap */
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.core {
  position: relative; aspect-ratio: 1; border-radius: 8px; background: var(--grid); overflow: hidden;
  font-size: .7rem; font-variant-numeric: tabular-nums; color: var(--muted);
}
.core em { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--c1); opacity: .85; transition: height .8s ease; }
.core span { position: absolute; inset: 0; display: grid; place-items: center; mix-blend-mode: normal; }

.foot { padding-block: 32px 48px; color: var(--muted); font-size: .85rem; text-align: center; }
.foot p { margin: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .hero { padding-bottom: 80px; }
  .link { gap: 8px; }
  .node { min-width: 72px; }
}
@media (prefers-reduced-motion: reduce) {
  .dot.on, .packet { animation: none; }
  .packet { left: 50%; }
  .ring-fill, .load em, .core em { transition: none; }
}
