@font-face {
  font-family: "Archivo";
  src: url("fonts/archivo-latin-900.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --color-ink: #141414;
  --color-surface: #f5f1e7;
  --color-surface-muted: #ffe7a3;
  --color-card: #fffdf7;
  --color-panel: #1f1e1b;
  --color-text: #141414;
  --color-muted: #615d55;
  --color-line: #141414;
  --color-line-soft: rgba(20, 20, 20, 0.2);
  --color-accent: #ffaf00;
  --color-accent-soft: #ffe7a3;
  --color-violet: #7952ff;
  --color-danger: #b42318;
  --color-success: #0f7b47;
  --color-success-soft: #d9f7e8;
  --map-ocean: #dfdbd0;
  --map-land: #fffdf7;
  --map-border: #8c867a;
  --marker-stroke: #141414;
  --marker-fill: #ffaf00;
  --shadow-card: 7px 7px 0 #141414;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Archivo", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --container: 1440px;
  font-family: var(--font-sans);
  font-synthesis: none;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-surface: #141414;
  --color-surface-muted: #302d25;
  --color-card: #1f1e1b;
  --color-text: #ffffff;
  --color-muted: #d8d2c4;
  --color-line: #f5f1e7;
  --color-line-soft: rgba(245, 241, 231, 0.22);
  --color-danger: #ff786d;
  --color-success: #5de0a0;
  --color-success-soft: rgba(93, 224, 160, 0.14);
  --map-ocean: #181814;
  --map-land: #2b2924;
  --map-border: #5e594f;
  --marker-stroke: #141414;
  --shadow-card: 7px 7px 0 #7952ff;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  scroll-behavior: smooth;
  background: var(--color-surface);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--color-text);
  background: radial-gradient(circle at 92% 9%, rgba(255, 175, 0, 0.18), transparent 24rem), var(--color-surface);
}

button, a { color: inherit; }
button { font: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.7rem 0.9rem;
  border: 2px solid #141414;
  color: #141414;
  background: var(--color-accent);
  box-shadow: 4px 4px 0 #141414;
  font-family: var(--font-display);
  font-size: 0.84rem;
  font-weight: 900;
  text-transform: uppercase;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus-visible { transform: translateY(0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 2px solid var(--color-line);
  background: var(--color-surface);
  background: color-mix(in srgb, var(--color-surface) 94%, transparent);
  backdrop-filter: blur(16px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  max-width: var(--container);
  min-height: 82px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2.5rem);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.72rem;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.5vw, 1.45rem);
  font-weight: 900;
  text-decoration: none;
  text-transform: uppercase;
}

.brand-lockup {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  line-height: 1;
}

.brand-lockup strong {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.5vw, 1.45rem);
  font-weight: 900;
  letter-spacing: 0;
}

.brand-lockup span {
  color: var(--color-muted);
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.brand img {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.nav-links a,
.theme-toggle,
.nav-wallet {
  min-height: 42px;
  border: 2px solid transparent;
  text-decoration: none;
}

.nav-links > a:not(.nav-wallet) {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.62rem;
}

.nav-links a:hover,
.nav-links a:focus-visible,
.theme-toggle:hover,
.theme-toggle:focus-visible,
.nav-links a[aria-current="page"] {
  color: #000;
  background: var(--color-accent-soft);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.45rem 0.62rem;
  color: var(--color-text);
  background: transparent;
  font: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.theme-toggle strong {
  padding: 0.05rem 0.28rem;
  border: 2px solid currentColor;
  color: #141414;
  background: var(--color-accent-soft);
}

.nav-wallet {
  display: inline-flex;
  align-items: center;
  margin-left: 0.45rem;
  padding: 0.55rem 0.9rem;
  border-color: #141414;
  color: #141414;
  background: var(--color-accent);
  box-shadow: 4px 4px 0 #141414;
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: 2px solid #141414;
  border-radius: 0;
  color: #141414;
  background: var(--color-accent);
  box-shadow: 4px 4px 0 #141414;
  cursor: pointer;
}

.nav-toggle-bar {
  display: block;
  height: 2px;
  margin: 4px 0;
  background: currentColor;
}

.node-map-shell {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(3.5rem, 7vw, 6.5rem) clamp(1rem, 3vw, 2.5rem) 5rem;
}

.node-map-shell:focus { outline: none; }

.hero {
  max-width: 1050px;
  margin-bottom: clamp(2rem, 4vw, 3.5rem);
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--color-muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.eyebrow::before {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.55rem;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 0.32rem rgba(255, 175, 0, 0.18);
  content: "";
}

.hero h1 {
  max-width: 980px;
  margin: 0;
  font: 900 clamp(3.4rem, 7vw, 7.2rem) / 0.94 var(--font-display);
  letter-spacing: -0.045em;
  text-transform: uppercase;
}

.lede {
  max-width: 820px;
  margin: 1.6rem 0 0;
  color: var(--color-muted);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 600;
  line-height: 1.55;
}

.history-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
  padding: 0.45rem;
  border: 2px solid var(--color-line);
  border-radius: 8px;
  background: var(--color-card);
  box-shadow: var(--shadow-card);
}

.history-tabs button {
  min-height: 44px;
  padding: 0.65rem 1rem;
  border: 2px solid transparent;
  border-radius: 4px;
  color: var(--color-muted);
  background: transparent;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
}

.history-tabs button:hover,
.history-tabs button:focus-visible {
  border-color: var(--color-line);
  color: var(--color-text);
}

.history-tabs button[aria-selected="true"] {
  border-color: #141414;
  color: #141414;
  background: var(--color-accent);
  box-shadow: 3px 3px 0 #141414;
}

#history-panel[aria-busy="true"] .map-card,
#history-panel[aria-busy="true"] .table-card {
  opacity: 0.72;
}

.status-panel,
.metric-card,
.map-card,
.table-card,
.method-card {
  border: 2px solid var(--color-line);
  border-radius: 8px;
  background: var(--color-card);
}

.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.25rem;
  padding: 1.2rem 1.35rem;
  box-shadow: var(--shadow-card);
}

.status-copy {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.status-copy p {
  margin: 0.25rem 0 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.status-dot {
  width: 0.75rem;
  height: 0.75rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 0.3rem rgba(255, 175, 0, 0.18);
}

.status-dot.ok {
  background: var(--color-success);
  box-shadow: 0 0 0 0.3rem var(--color-success-soft);
}

.status-dot.error {
  background: var(--color-danger);
  box-shadow: 0 0 0 0.3rem rgba(239, 68, 68, 0.13);
}

.freshness {
  display: flex;
  gap: 2rem;
  margin: 0;
}

.freshness div {
  display: grid;
  gap: 0.25rem;
}

.freshness dt,
.metric-label,
th {
  color: var(--color-muted);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.freshness dd {
  margin: 0;
  font-weight: 600;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin: 1.25rem 0;
}

.metric-card {
  display: flex;
  min-height: 175px;
  flex-direction: column;
  padding: 1.45rem;
}

.metric-value {
  margin: auto 0 0.45rem;
  font: 900 3.6rem / 1 var(--font-display);
}

.metric-note,
.legend,
.table-total {
  color: var(--color-muted);
  font-size: 0.82rem;
}

.map-card,
.table-card,
.method-card {
  margin-top: 1.25rem;
  padding: clamp(1rem, 2.5vw, 2rem);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.section-heading h2,
.method-card h2 {
  margin: 0;
  font: 900 clamp(1.8rem, 3.2vw, 3rem) / 0.98 var(--font-display);
  text-transform: uppercase;
}

.legend {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.legend span {
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid #141414;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 3px 3px 0 rgba(20, 20, 20, 0.25);
}

.world-map {
  height: clamp(390px, 58vw, 650px);
  overflow: hidden;
  border: 2px solid var(--color-line);
  border-radius: 6px;
  background: var(--map-ocean);
}

.leaflet-container { font-family: var(--font-sans); }

.leaflet-control-zoom a {
  border-color: var(--color-line-soft) !important;
  color: var(--color-text) !important;
  background: var(--color-card) !important;
}

.leaflet-control-attribution {
  color: var(--color-muted) !important;
  background: var(--color-card) !important;
  background: color-mix(in srgb, var(--color-card) 90%, transparent) !important;
}

.leaflet-control-attribution a { color: var(--color-text) !important; }

.peer-tooltip {
  border: 2px solid #141414;
  border-radius: 4px;
  color: #141414;
  background: #fffdf7;
  box-shadow: 4px 4px 0 #141414;
  font-weight: 600;
}

.peer-tooltip::before { border-top-color: #141414 !important; }

.empty-state {
  padding: 2rem;
  color: var(--color-muted);
  text-align: center;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  min-width: 500px;
  border-collapse: collapse;
}

th,
td {
  padding: 1rem 0.75rem;
  border-bottom: 1px solid var(--color-line-soft);
  text-align: left;
}

th:nth-child(n + 2),
td:nth-child(n + 2) { text-align: right; }

tbody tr:last-child td { border-bottom: 0; }

.country-name {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
}

.country-code {
  display: inline-grid;
  min-width: 2.3rem;
  place-items: center;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--color-line-soft);
  border-radius: 3px;
  color: #141414;
  background: var(--color-accent-soft);
  font-size: 0.72rem;
}

.method-card {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) 1fr 1fr;
  gap: 2rem;
  align-items: start;
  background: var(--color-surface-muted);
}

.method-card p {
  margin: 0;
  color: var(--color-muted);
  line-height: 1.65;
}

footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 2rem;
  justify-content: center;
  padding: 2.2rem clamp(1rem, 3vw, 2.5rem);
  border-top: 2px solid #141414;
  color: #d8d2c4;
  background: #141414;
  font-size: 0.82rem;
}

footer a { color: #ffffff; }

@media (max-width: 1200px) {
  .nav { min-height: 72px; }
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute;
    top: calc(100% + 2px);
    right: clamp(1rem, 3vw, 2.5rem);
    left: clamp(1rem, 3vw, 2.5rem);
    display: none;
    align-items: stretch;
    padding: 1rem;
    border: 2px solid var(--color-line);
    color: var(--color-text);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
  }
  .nav-links.is-open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .nav-links > a,
  .theme-toggle { width: 100%; }
  .nav-links > a:not(.nav-wallet),
  .theme-toggle { justify-content: flex-start; }
  .nav-wallet {
    margin-left: 0;
    justify-content: center;
  }
}

@media (max-width: 760px) {
  .brand-lockup strong { font-size: 0.94rem; }
  .node-map-shell {
    padding-top: 3.5rem;
    padding-bottom: 3rem;
  }
  .hero h1 { font-size: clamp(2.75rem, 14vw, 4.4rem); }
  .history-tabs {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .history-tabs button { width: 100%; }
  .history-tabs button:last-child { grid-column: 1 / -1; }
  .metrics { grid-template-columns: 1fr; }
  .metric-card { min-height: 135px; }
  .status-panel,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .freshness {
    width: 100%;
    gap: 1rem;
    justify-content: space-between;
  }
  .method-card {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .world-map { height: 430px; }
  .table-wrap { overflow-x: visible; }
  table {
    min-width: 0;
    table-layout: fixed;
  }
  th,
  td {
    padding: 0.85rem 0.35rem;
    font-size: 0.76rem;
    white-space: normal;
  }
  th:first-child { width: 54%; }
  th:nth-child(2) { width: 25%; }
  th:nth-child(3) { width: 21%; }
  .country-name { gap: 0.4rem; }
  .country-code {
    min-width: 2rem;
    padding: 0.2rem 0.3rem;
    font-size: 0.65rem;
  }
}

@media (max-width: 540px) {
  .nav-links.is-open { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
