:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5d636e;
  --faint: #8a909b;
  --line: #e3e3df;
  --line-strong: #cfcfca;
  --bar: #c9ccd2;
  --accent: #127a4a;         /* cheapest = the one thing that matters */
  --accent-soft: #e3f3ea;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --danger: #b42318;
  --focus: #1f6feb;
  --radius: 8px;
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 40px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #181b20;
    --text: #eceef1;
    --muted: #a3a9b3;
    --faint: #7b818b;
    --line: #2a2e35;
    --line-strong: #3a3f47;
    --bar: #4a505a;
    --accent: #3ccf85;
    --accent-soft: #15352a;
    --warn: #e7a64a;
    --warn-soft: #3a2b12;
    --danger: #ff7b72;
    --focus: #6ea8ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.45;
  font-feature-settings: "tnum" 1;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--s3); padding: var(--s5) var(--s4) var(--s2); max-width: 1600px; margin: 0 auto;
}
h1 {
  margin: 0; font-size: clamp(2.4rem, 5.2vw, 4.2rem); line-height: 1; font-weight: 800;
  letter-spacing: -0.035em;
}
h1 .by { font-weight: 400; color: var(--muted); letter-spacing: -0.01em; font-size: .42em; margin-left: .15em; white-space: nowrap; }
.sub { margin: var(--s2) 0 0; color: var(--muted); font-size: 15px; }
.top-controls { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.status {
  max-width: 1600px; margin: 0 auto; padding: 0 var(--s4) var(--s3); color: var(--faint); font-size: 12.5px;
}
.status.err { color: var(--danger); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s3); }
h2 { margin: 0; font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: var(--s2); }
h3 { margin: 0 0 var(--s2); font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.step {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text); color: var(--surface); font-size: 11.5px; font-weight: 700;
}
.count { color: var(--faint); font-weight: 500; }

/* ---------- buttons & fields ---------- */
.btn {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 6px;
  padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--text); }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--text); color: var(--surface); border-color: var(--text); }
.btn.small { padding: 3px 9px; font-size: 12.5px; }
.btn.icon { padding: 2px 8px; border-color: transparent; color: var(--faint); background: transparent; font-size: 16px; line-height: 1; }
.btn.icon:hover { color: var(--danger); border-color: transparent; }

.add-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s3); }
.add-row .btn::before { content: "+ "; color: var(--faint); }

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > span { font-size: 11.5px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: var(--s2); }
.field input, .field select, .search {
  width: 100%; min-width: 0; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface);
}
.field input[type=number] { text-align: right; }
.hint { font-size: 11.5px; color: var(--faint); margin-top: 2px; }

.empty-small { color: var(--faint); font-size: 13px; padding: var(--s2) 0; }

/* ---------- regions ---------- */
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s2); }
.search { margin-bottom: var(--s2); }
.region-list { max-height: 420px; overflow: auto; border-top: 1px solid var(--line); padding-top: var(--s2); }
.geo { margin-bottom: var(--s2); }
.geo-head { display: flex; justify-content: space-between; align-items: center; font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; padding: 4px 0; }
.geo-head button { font-size: 11.5px; border: 0; background: none; color: var(--faint); cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 500; }
.geo-head button:hover { color: var(--text); }
.regions { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s2); }
.region { display: flex; align-items: center; gap: 6px; padding: 3px 2px; cursor: pointer; border-radius: 4px; font-size: 13px; }
.region:hover { background: var(--bg); }
.region input { margin: 0; accent-color: var(--text); }
.region small { color: var(--faint); font-size: 11px; margin-left: auto; }

/* ---------- results ---------- */
.results { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4);
  display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--s4);
}
@media (max-width: 720px) { .hero { grid-template-columns: 1fr; gap: var(--s3); } }
.kicker { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.hero-main .region-name { font-size: clamp(1.6rem, 3vw, 2.3rem); font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; color: var(--accent); }
.hero-main .big { font-size: 20px; font-weight: 650; margin-top: 6px; }
.hero-main .big small { font-size: 13px; color: var(--muted); font-weight: 400; }
.stat .val { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.stat .ctx { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3) var(--s4) var(--s4); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); margin-bottom: var(--s3); flex-wrap: wrap; }
.card-head h2 { font-size: 15px; }
.card-head p { margin: 0; font-size: 12.5px; color: var(--faint); }

/* ranking bars */
.rank { display: grid; grid-template-columns: minmax(120px, 210px) 1fr auto auto; gap: 6px var(--s3); align-items: center; }
.rank .rn { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .rn small { color: var(--faint); margin-left: 6px; font-size: 11.5px; }
.rank .track { height: 18px; position: relative; }
.rank .fill { height: 100%; background: var(--bar); border-radius: 0 3px 3px 0; min-width: 2px; transition: width .35s ease; }
.rank .first .fill, .rank .fill.first { background: var(--accent); }
.rank .fill.partial { background: repeating-linear-gradient(135deg, var(--bar) 0 5px, transparent 5px 9px); }
.rank .rv { text-align: right; font-weight: 650; font-size: 13.5px; white-space: nowrap; }
.rank .rd { text-align: right; font-size: 12.5px; color: var(--muted); white-space: nowrap; min-width: 64px; }
.rank .rd.best { color: var(--accent); font-weight: 650; }
.rank .rn.best { font-weight: 650; }
.rank .note { grid-column: 2 / -1; font-size: 11.5px; color: var(--warn); margin-top: -4px; }

/* matrix */
.table-wrap { overflow-x: auto; margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); white-space: normal; min-width: 200px; }
thead th { font-size: 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line-strong); }
thead th .geo-s { display: block; font-weight: 400; color: var(--faint); font-size: 11px; }
td .u { display: block; font-size: 11px; color: var(--faint); margin-top: 1px; }
td .wn { font-weight: 600; }
td .wd { display: block; font-size: 11.5px; color: var(--faint); }
td.min { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
td.min .u { color: var(--accent); opacity: .8; }
td.na { color: var(--faint); }
td.loading { color: var(--faint); }
tfoot td { font-weight: 700; border-bottom: 0; border-top: 1px solid var(--line-strong); }
tfoot td.min { font-weight: 750; }
th.col-best { color: var(--accent); }

.empty {
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: var(--s5) var(--s4); text-align: center; color: var(--muted);
}
.empty h2 { justify-content: center; font-size: 18px; color: var(--text); margin-bottom: var(--s2); }
.empty p { margin: 0 0 var(--s3); }

.skeleton { color: transparent !important; background: linear-gradient(90deg, var(--line) 0, var(--bg) 50%, var(--line) 100%); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: 4px; }
@keyframes sk { to { background-position: -200% 0; } }

.foot { max-width: 1600px; margin: 0 auto; padding: var(--s2) var(--s4) var(--s5); color: var(--faint); font-size: 12px; }
.foot p { max-width: 900px; margin: 0; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface);
  padding: 8px 16px; border-radius: 6px; font-size: 13px; z-index: 10;
}
@media (prefers-reduced-motion: reduce) { .rank .fill { transition: none; } .skeleton { animation-duration: 3s; } }
@media (max-width: 560px) {
  .top { padding: var(--s4) var(--s3) var(--s2); }
  .flow { padding: 0 var(--s3) var(--s3); }
  .rank { grid-template-columns: 1fr auto; }
  .rank .track { grid-column: 1 / -1; order: 3; height: 10px; }
  .rank .rd { display: none; }
  .regions { grid-template-columns: 1fr; }
}

/* ---------- loading animations ---------- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 20; overflow: hidden; opacity: 0; transition: opacity .25s; pointer-events: none; }
.progress.on { opacity: 1; }
.progress-bar { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: var(--accent); transition: width .3s ease; }
.progress.on .progress-bar::after {
  content: ""; position: absolute; inset: 0; width: 120px; right: 0; left: auto;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.7)); animation: glint 1s infinite;
}
.progress.indeterminate .progress-bar { width: 35% !important; animation: indet 1.1s infinite cubic-bezier(.65,.05,.36,1); }
@keyframes indet { from { left: -35%; } to { left: 100%; } }
@keyframes glint { from { opacity: .2; } 50% { opacity: 1; } to { opacity: .2; } }

.status { display: flex; align-items: center; gap: 8px; }
.spinner { display: none; width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; flex: none; }
.status.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.fill.loading { background: linear-gradient(90deg, var(--bar) 0, var(--line) 50%, var(--bar) 100%) !important; background-size: 200% 100% !important; animation: sk 1.1s infinite linear; }
.card.is-loading .card-head h2::after {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 8px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; vertical-align: -1px;
}
.hero.is-loading { position: relative; overflow: hidden; }
.hero.is-loading::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--surface) 60%, transparent) 50%, transparent 80%);
  background-size: 200% 100%; animation: sk 1.3s infinite linear;
}
.fade-in { animation: fadein .35s ease both; }
@keyframes fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .spinner, .progress-bar, .fill.loading, .hero.is-loading::after, .fade-in { animation-duration: 3s !important; }
}

/* ---------- boot popup ---------- */
body.booting { overflow: hidden; }
.boot {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--s3);
  background: color-mix(in srgb, var(--bg) 45%, transparent);
  backdrop-filter: blur(10px) saturate(120%); -webkit-backdrop-filter: blur(10px) saturate(120%);
  transition: opacity .45s ease, visibility .45s;
}
.boot.done { opacity: 0; visibility: hidden; }
.boot-card {
  width: min(460px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: var(--s4) var(--s4) var(--s3); box-shadow: 0 24px 60px -20px rgba(0,0,0,.35);
  animation: pop .4s cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
.boot-brand { font-weight: 800; letter-spacing: -0.02em; font-size: 15px; }
.boot-brand span { font-weight: 400; color: var(--muted); }
.boot-card h2 { font-size: 20px; margin: 4px 0 var(--s3); letter-spacing: -0.01em; }
.boot-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; min-height: 238px; }
.boot-steps li { display: flex; align-items: center; gap: 12px; font-size: 14px; animation: stepin .3s ease both; }
.boot-steps li .detail { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.boot-steps li.pending { color: var(--muted); }
@keyframes stepin { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.ico { width: 20px; height: 20px; flex: none; display: grid; place-items: center; }
.ico .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
.ico svg { width: 20px; height: 20px; }
.ico .ok circle { fill: #1f9d55; }
.ico .ok path { stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 14; stroke-dashoffset: 14; animation: draw .35s .05s ease forwards; }
.ico .ok { animation: popok .3s cubic-bezier(.2,.9,.3,1.4) both; }
.ico .bad circle { fill: var(--danger); }
.ico .bad path { stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes popok { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.boot-foot { margin-top: var(--s3); min-height: 20px; font-size: 12.5px; color: var(--faint); display: flex; justify-content: space-between; align-items: center; gap: var(--s2); }
.boot-foot.err { color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .boot-card, .boot-steps li, .ico .ok, .ico .ok path { animation-duration: .01s; } }

/* ---------- three-step flow ---------- */
.steps-nav {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  max-width: 1600px; margin: 0 auto var(--s3); padding: 10px var(--s4);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.steps-nav a { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; padding: 4px 10px 4px 4px; border-radius: 999px; }
.steps-nav a:hover { background: var(--surface); }
.steps-nav .step { background: var(--line-strong); color: var(--text); }
.steps-nav a.done .step { background: var(--accent); color: #fff; }
.steps-nav a.done .step::before { content: "✓"; }
.steps-nav a.done .step { font-size: 0; }
.steps-nav a.done .step::before { font-size: 11.5px; }
.sn-label { font-weight: 650; font-size: 13.5px; }
.sn-sum { color: var(--muted); font-size: 12.5px; }
.sn-sep { color: var(--faint); }

.flow { max-width: 1600px; margin: 0 auto; padding: 0 var(--s4) var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: var(--s4); scroll-margin-top: 64px; }
.stage.plain { background: transparent; border: 0; padding: 0; }
.stage.plain > .stage-head { padding: 0 var(--s1); }
.stage-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.stage-title h2 { font-size: 20px; letter-spacing: -0.01em; }
.stage-sum { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.step.big { width: 32px; height: 32px; font-size: 15px; flex: none; }

/* regions */
.region-tools { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: center; margin-bottom: var(--s3); }
.region-tools .presets { margin: 0; }
.region-tools .search { flex: 1 1 260px; max-width: 420px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line-strong); font-size: 13px; cursor: default;
}
.chip small { color: var(--faint); font-size: 11px; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--faint); font-size: 15px; line-height: 1; padding: 0 4px; border-radius: 50%; }
.chip button:hover { color: var(--danger); }
.chips .none { color: var(--faint); font-size: 13px; }
.linkbtn { margin-top: var(--s3); border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:hover { color: var(--text); }
.region-list { max-height: none; overflow: visible; margin-top: var(--s3); padding-top: var(--s3); columns: 250px auto; column-gap: var(--s4); }
.region-list .geo { break-inside: avoid; margin-bottom: var(--s3); }
.region-list .regions { grid-template-columns: 1fr; }

@media (max-width: 720px) {
  .stage { padding: var(--s3); }
  .steps-nav { padding: 8px var(--s3); }
  .sn-sum { display: none; }
  .workloads { grid-template-columns: 1fr; }
}

/* ---------- boot disclaimer ---------- */
.disclaimer { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.disclaimer p { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.disclaimer strong { color: var(--text); }
.accept { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.accept input { margin-top: 2px; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
#boot-continue { align-self: flex-end; padding: 8px 18px; }
#boot-continue:disabled { opacity: .45; cursor: not-allowed; }
.boot-steps { min-height: 0; }
.boot-card { max-height: calc(100vh - 32px); overflow: auto; }

/* ---------- footer, legal pages, changelog ---------- */
.foot { padding-bottom: var(--s2); }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: 12.5px; color: var(--muted); }
.foot-links a { color: var(--muted); text-decoration: none; }
.foot-visits { font-variant-numeric: tabular-nums; }
.foot-links a:hover { color: var(--text); text-decoration: underline; }
.foot-btn { border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; }
.foot-btn:hover { color: var(--danger); }
.foot-note { max-width: 1600px; margin: 0 auto; padding: 0 var(--s4) var(--s5); color: var(--faint); font-size: 12px; }
.accept.optional { color: var(--muted); }
.accept small { color: var(--faint); }
.boot-legal { font-size: 12px !important; }
.boot-legal a { color: var(--muted); }

.docpage .foot { max-width: 820px; padding: var(--s4) var(--s4) var(--s5); }
.doc-top { max-width: 820px; margin: 0 auto; padding: var(--s4) var(--s4) 0; display: flex; justify-content: space-between; align-items: center; gap: var(--s3); }
.doc-brand { font-weight: 800; font-size: 20px; letter-spacing: -0.02em; text-decoration: none; }
.doc-brand .by { font-weight: 400; color: var(--muted); font-size: .7em; }
.doc { max-width: 820px; margin: 0 auto; padding: var(--s4); font-size: 14.5px; line-height: 1.6; }
.doc h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); letter-spacing: -0.02em; margin: var(--s3) 0 var(--s2); }
.doc h2 { font-size: 17px; margin: var(--s4) 0 var(--s2); display: block; }
.doc h3 { margin: var(--s3) 0 var(--s1); }
.doc .de { font-weight: 400; color: var(--muted); font-size: .8em; }
.doc .lead { color: var(--muted); margin-top: 0; }
.doc p, .doc li { color: var(--text); }
.doc ul { padding-left: 20px; }
.doc code { font-size: 12.5px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }
.release { border-top: 1px solid var(--line); margin-top: var(--s4); }
.release h2 { display: flex; align-items: center; gap: var(--s2); font-size: 20px; }
.rel-meta { color: var(--muted); margin: 0; }
.tag { font-size: 11px; font-weight: 650; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 8px; }
a.btn { text-decoration: none; display: inline-block; }

/* ---------- sharing ---------- */
.shared-bar {
  max-width: 1600px; margin: 0 auto var(--s3); padding: 10px var(--s4); display: flex; gap: var(--s3); align-items: center; justify-content: space-between;
  background: var(--accent-soft); border-top: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  font-size: 13px;
}
.shared-bar[hidden] { display: none; }
.shared-text b { color: var(--accent); }
.shared-text .diff { color: var(--warn); }
.fab {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--text); color: var(--surface); border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 650;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.45); cursor: pointer;
}
.fab[hidden] { display: none; }
@media (min-width: 821px) { .fab { display: none; } }
@media (max-width: 820px) { .foot-note { padding-bottom: 90px; } }
.sheet {
  position: fixed; inset: 0; z-index: 45; display: flex; align-items: flex-end; justify-content: center;
  background: color-mix(in srgb, var(--bg) 45%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: min(520px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 0 0;
  padding: var(--s4) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom)); animation: sheetin .3s cubic-bezier(.2,.9,.3,1) both;
}
@keyframes sheetin { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-card h2 { font-size: 20px; margin-bottom: var(--s2); }
.sheet-card p { margin: 0 0 var(--s3); color: var(--muted); font-size: 14px; line-height: 1.5; }
.sheet-actions { display: flex; flex-direction: column; gap: var(--s2); }
.sheet-actions .btn { padding: 11px 16px; font-size: 15px; text-align: center; }

/* ---------- MCP page ---------- */
.codebox { display: flex; align-items: center; gap: var(--s2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: var(--s2) 0; }
.codebox code { flex: 1; font-size: 13px; overflow-x: auto; white-space: nowrap; border: 0; background: none; padding: 0; }
.codeblock { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; }
.codeblock code { border: 0; background: none; padding: 0; }
.kv { border-collapse: collapse; width: 100%; margin: var(--s2) 0; font-size: 13.5px; }
.kv th, .kv td { text-align: left; vertical-align: top; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: normal; position: static; min-width: 0; background: none; }
.kv th { width: 170px; color: var(--muted); font-weight: 600; }
.doc h3 { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); }



/* ---------- live latency ---------- */
.live { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.status.live-on .live { display: inline-block; animation: livepulse 1.6s ease-in-out infinite; }
.status.live-paused .live { display: inline-block; background: var(--faint); }
@keyframes livepulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 50% { box-shadow: 0 0 0 5px transparent; } }
.btn.is-paused { border-color: var(--accent); color: var(--accent); }
.spark { display: block; width: 120px; height: 24px; margin-left: auto; }
.spark polyline { fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
tr.best .spark polyline { stroke: var(--accent); }
td.lost { color: var(--warn); }
.rank .rv small { color: var(--faint); font-weight: 400; margin-left: 4px; }
@media (prefers-reduced-motion: reduce) { .status.live-on .live { animation: none; } .rank .fill { transition: none; } }
/* ---------- glowing MCP button ---------- */
.mcp-btn {
  display: inline-flex; align-items: center; gap: 7px; font-weight: 700; letter-spacing: .02em;
  color: #0d2b1c; background: #3ccf85; border-color: #3ccf85;
  box-shadow: 0 0 0 0 rgba(60, 207, 133, .55), 0 0 18px rgba(60, 207, 133, .45);
  animation: mcpglow 2.4s ease-in-out infinite;
}
.mcp-btn:hover { background: #5ee09d; border-color: #5ee09d; color: #0d2b1c; }
.mcp-dot { width: 8px; height: 8px; border-radius: 50%; background: #0d2b1c; box-shadow: 0 0 0 2px rgba(13, 43, 28, .25); }
@keyframes mcpglow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(60, 207, 133, .55), 0 0 14px rgba(60, 207, 133, .35); }
  50% { box-shadow: 0 0 0 6px rgba(60, 207, 133, 0), 0 0 26px rgba(60, 207, 133, .7); }
}
@media (prefers-reduced-motion: reduce) { .mcp-btn { animation: none; } }
.mcp-dot { flex: none; display: inline-block; }

/* ---------- live latency map (map.js) ---------- */
/* sizes are given in screen pixels times --k (map units per pixel), so they stay the same at every zoom */
.azmap { display: block; width: 100%; height: 100%; --k: 1; user-select: none; }
.azmap .land path { fill: color-mix(in srgb, var(--text) 7%, var(--surface)); stroke: none; }
.azmap .ln { fill: none; stroke: var(--bar); stroke-width: calc(var(--k) * 1.4px); stroke-linecap: round; transition: stroke .4s, opacity .4s; }
.azmap .ln.best { stroke: var(--accent); stroke-width: calc(var(--k) * 2.2px); }
.azmap .ln.waiting { opacity: .45; }
.azmap .ln.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: azdraw 1.1s cubic-bezier(.3, .7, .2, 1) forwards; }
@keyframes azdraw { to { stroke-dashoffset: 0; } }
.azmap .pk { fill: var(--muted); }
.azmap .pk.best { fill: var(--accent); }
.azmap .dot { fill: var(--surface); stroke: var(--muted); stroke-width: calc(var(--k) * 1.5px); }
.azmap .dot.best { fill: var(--accent); stroke: var(--accent); }
.azmap .mtag rect { fill: var(--surface); stroke: var(--line-strong); stroke-width: calc(var(--k) * 1px); }
.azmap .mtag text { fill: var(--text); font-weight: 650; text-anchor: middle; dominant-baseline: central; font-feature-settings: "tnum" 1; }
.azmap .mtag.best rect { fill: var(--accent); stroke: var(--accent); }
.azmap .mtag.best text { fill: var(--surface); }
.azmap .leader { stroke: var(--faint); stroke-width: calc(var(--k) * 1px); stroke-dasharray: calc(var(--k) * 2px) calc(var(--k) * 2px); }
.azmap .rname { fill: var(--muted); }
.azmap .me .core { fill: var(--text); stroke: var(--surface); stroke-width: calc(var(--k) * 2px); }
.azmap .me .pulse { fill: color-mix(in srgb, var(--text) 25%, transparent); transform-box: fill-box; transform-origin: center; animation: azpulse 2s ease-out infinite; }
.azmap .me-label { fill: var(--text); font-weight: 700; paint-order: stroke; stroke: var(--surface); stroke-width: calc(var(--k) * 3px); stroke-linejoin: round; }
@keyframes azpulse { from { transform: scale(.6); opacity: .9; } to { transform: scale(3.2); opacity: 0; } }
.azmap .fade { animation: azfade .45s ease both; }
@keyframes azfade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .azmap .me .pulse, .azmap .fade { animation: none; } }
.azmap-note:empty { display: none; }
.azmap-note { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 2px 8px; border-radius: 6px; }
.map-host { position: relative; width: 100%; height: 100%; min-height: 0; }
.map-attr { margin: var(--s2) 0 0; font-size: 11.5px; color: var(--faint); }
.map-attr a { color: var(--faint); }

/* mini map at the bottom of the dashboard */
.map-card { padding-bottom: var(--s3); }
.map-mini {
  position: relative; display: block; width: 100%; height: clamp(240px, 30vw, 420px); padding: 0; cursor: zoom-in;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); overflow: hidden; transition: border-color .2s;
}
.map-mini:hover { border-color: var(--line-strong); }
.map-mini .map-hint {
  position: absolute; right: 10px; top: 10px; font-size: 12px; color: var(--muted); pointer-events: none;
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px;
}

/* enlarged map: blurred dashboard behind */
.map-overlay {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: var(--s4);
  background: color-mix(in srgb, var(--bg) 45%, transparent); backdrop-filter: blur(10px) saturate(120%); -webkit-backdrop-filter: blur(10px) saturate(120%);
  animation: azfade .25s ease both;
}
.map-overlay[hidden] { display: none; }
.map-panel {
  width: min(1500px, 100%); height: min(900px, 100%); display: flex; flex-direction: column; gap: var(--s2);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: var(--s3) var(--s4) var(--s3);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .45); animation: mapin .3s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes mapin { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.map-panel-head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.map-panel-head h2 { font-size: 18px; letter-spacing: -0.01em; }
.map-panel-head p { margin: 0; font-size: 12.5px; color: var(--muted); }
.map-panel-head .actions { margin-left: auto; display: flex; gap: var(--s2); }
.map-panel .map-host { flex: 1; border-radius: var(--radius); background: var(--bg); overflow: hidden; }
body.map-open { overflow: hidden; }
@media (max-width: 720px) { .map-overlay { padding: var(--s2); } .map-panel { padding: var(--s3); } }
@media (prefers-reduced-motion: reduce) { .map-overlay, .map-panel { animation: none; } }

/* map.html: the map in its own tab */
.mappage { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.mappage .top { padding-top: var(--s4); width: 100%; }
.mappage h1 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); }
.mappage .status { width: 100%; }
.map-main { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 1600px; margin: 0 auto; padding: 0 var(--s4) var(--s2); min-height: 420px; }
.map-main .map-host { flex: 1; min-height: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.map-start { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: var(--s3);
  background: color-mix(in srgb, var(--bg) 45%, transparent); backdrop-filter: blur(10px) saturate(120%); -webkit-backdrop-filter: blur(10px) saturate(120%); }
.map-start[hidden] { display: none; }
.map-start .boot-card p { color: var(--muted); font-size: 13.5px; line-height: 1.5; }

/* zoom: wheel / pinch / drag on the large map, buttons top left */
.azmap:not(.compact) { cursor: grab; touch-action: none; }
.azmap.dragging { cursor: grabbing; }
.azmap-ctl { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.azmap-ctl[hidden], .azmap-ctl button[hidden] { display: none; }
.azmap-ctl button {
  min-width: 32px; height: 32px; padding: 0 10px; font-size: 13px; font-weight: 600; line-height: 1; cursor: pointer;
  color: var(--text); background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line-strong); border-radius: 6px;
}
.azmap-ctl button[data-z="in"], .azmap-ctl button[data-z="out"] { font-size: 18px; padding: 0; }
.azmap-ctl button:hover { border-color: var(--text); }
/* country borders and names (under the latency lines) */
.azmap .borders path { fill: none; stroke: color-mix(in srgb, var(--text) 20%, var(--surface)); stroke-width: calc(var(--k) * .8px); stroke-linejoin: round; }
.azmap .cname { fill: color-mix(in srgb, var(--text) 38%, var(--surface)); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; pointer-events: none; }
