/* IP 检测 · css/style.css — design tokens (light/dark) + shared component vocabulary (docs/ARCHITECTURE.md §8, §9). */

/* ============================================================== tokens: light */
:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f5f8;
  --surface-3: #e7ecf1;
  --border: #e1e6ec;
  --border-strong: #c8d1db;
  --text: #16202b;
  --text-2: #4a5867;
  --text-3: #637282;
  --accent: #0f766e;
  --accent-2: #0d9488;
  --accent-bg: #e3f3f1;
  --on-accent: #ffffff;
  --ok: #157a3c;
  --ok-bg: #e5f4ea;
  --warn: #b25206;
  --warn-bg: #fcf0de;
  --bad: #c42b2b;
  --bad-bg: #fbe9e9;
  --info: #1f62d0;
  --info-bg: #e7effc;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 10px rgba(15, 23, 42, .045);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .16), 0 3px 8px rgba(15, 23, 42, .08);
  --font: -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --mono: 'Cascadia Mono', Consolas, 'SF Mono', Menlo, monospace;
  --header-h: 104px;
  --gutter: 24px;
  --maxw: 1360px;
  --header-bg: rgba(255, 255, 255, .86);
  --backdrop: rgba(10, 15, 22, .45);
  --zebra: rgba(242, 245, 248, .55);
}

/* ============================================================== tokens: dark (auto, unless forced light) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1117;
    --bg-elev: #131922;
    --surface: #151c25;
    --surface-2: #1b232e;
    --surface-3: #242e3a;
    --border: #253040;
    --border-strong: #354253;
    --text: #e4eaf1;
    --text-2: #a7b3c0;
    --text-3: #8593a3;
    --accent: #2dd4bf;
    --accent-2: #22b8a8;
    --accent-bg: rgba(45, 212, 191, .12);
    --on-accent: #042420;
    --ok: #4ade80;
    --ok-bg: rgba(74, 222, 128, .12);
    --warn: #fbbf24;
    --warn-bg: rgba(251, 191, 36, .12);
    --bad: #f87171;
    --bad-bg: rgba(248, 113, 113, .13);
    --info: #60a5fa;
    --info-bg: rgba(96, 165, 250, .13);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 10px rgba(0, 0, 0, .18);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55), 0 3px 8px rgba(0, 0, 0, .35);
    --header-bg: rgba(19, 25, 34, .86);
    --backdrop: rgba(0, 0, 0, .6);
    --zebra: rgba(27, 35, 46, .5);
  }
}

/* ============================================================== tokens: dark (forced) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-elev: #131922;
  --surface: #151c25;
  --surface-2: #1b232e;
  --surface-3: #242e3a;
  --border: #253040;
  --border-strong: #354253;
  --text: #e4eaf1;
  --text-2: #a7b3c0;
  --text-3: #8593a3;
  --accent: #2dd4bf;
  --accent-2: #22b8a8;
  --accent-bg: rgba(45, 212, 191, .12);
  --on-accent: #042420;
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, .12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, .12);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, .13);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, .13);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 2px 10px rgba(0, 0, 0, .18);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55), 0 3px 8px rgba(0, 0, 0, .35);
  --header-bg: rgba(19, 25, 34, .86);
  --backdrop: rgba(0, 0, 0, .6);
  --zebra: rgba(27, 35, 46, .5);
}

/* ============================================================== base */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 12px);
  background: var(--bg);
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.35; }
::selection { background: var(--accent-bg); color: var(--text); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 3000; padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent); font-weight: 600;
}
.skip-link:focus { top: 10px; text-decoration: none; }

.icon { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: -3px; }
.icon-ext { width: 12px; height: 12px; margin-left: 3px; vertical-align: -1px; opacity: .7; }

/* ============================================================== utilities */
.grid {
  display: grid; gap: 12px; min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--grid-min, 220px)), 1fr));
}
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.spread { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; min-width: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: .94em; font-variant-ligatures: none; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.right { text-align: right; }
.center { text-align: center; }
.hide, [hidden] { display: none !important; }

/* ============================================================== header */
.site-header {
  position: sticky; top: 0; z-index: 1000;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 10px var(--gutter) 0;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand status actions" "nav nav nav";
  align-items: center; column-gap: 16px; row-gap: 4px;
}
.brand {
  grid-area: brand; display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: .02em; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #14b8a6 0%, #0f766e 60%, #115e59 100%);
  box-shadow: 0 2px 6px rgba(15, 118, 110, .35), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-sub { font-size: 12px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }

.header-status { grid-area: status; display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.header-actions { grid-area: actions; display: flex; align-items: center; gap: 4px; }
.header-actions .btn { height: 32px; }

.progress-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 11px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.progress-pill .spinner { width: 12px; height: 12px; border-width: 2px; }
.progress-pill.done { background: var(--ok-bg); color: var(--ok); }
.progress-pill.warn { background: var(--warn-bg); color: var(--warn); }
[hidden] { display: none !important; }
.progress-pill .icon { width: 14px; height: 14px; }
.mode-badge { height: 26px; border-radius: 999px; padding: 0 10px; }

.site-nav {
  grid-area: nav; position: relative; display: flex; gap: 2px; overflow-x: auto; overscroll-behavior-x: contain;
  scrollbar-width: none; margin: 0 -10px; padding: 0 10px;
}
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a {
  flex: none; padding: 7px 10px 9px; color: var(--text-2); font-size: 13px; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.site-nav a:focus-visible { outline-offset: -2px; }

/* ============================================================== layout */
.container { max-width: var(--maxw); margin: 0 auto; padding: 20px var(--gutter) 40px; }
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.top-tools { margin-bottom: 16px; }
@media (min-width: 1100px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ============================================================== notice */
#notice-area:empty { display: none; }
#notice-area { display: grid; gap: 10px; margin-bottom: 16px; }
.notice { align-items: flex-start; }
.notice .callout-main { flex: 1 1 auto; }
.notice > .btn { margin: -4px -6px -4px 0; }

/* ============================================================== card */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 0; display: flex; flex-direction: column;
}
.card.full { grid-column: 1 / -1; }
.card-head {
  display: flex; align-items: flex-start; gap: 10px 12px; padding: 14px 18px 12px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head > div:first-child { flex: 1 1 220px; min-width: 0; }
.card-title {
  margin: 0; font-size: 15.5px; font-weight: 650; letter-spacing: .01em; display: flex; align-items: center; gap: 9px;
}
.card-title::before {
  content: ''; width: 4px; height: 16px; border-radius: 2px; flex: none;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
}
.card-sub { margin: 3px 0 0 13px; color: var(--text-3); font-size: 12.5px; line-height: 1.5; }
.card-sub:empty { display: none; }
.card-status {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; margin-top: 1px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
}
.card-status:empty { display: none; }
.card-status .dot { width: 7px; height: 7px; box-shadow: none; }
.card-status .spinner { width: 11px; height: 11px; border-width: 2px; }
.card-status.tone-loading { background: var(--accent-bg); color: var(--accent); }
.card-status.tone-ok { background: var(--ok-bg); color: var(--ok); }
.card-status.tone-warn { background: var(--warn-bg); color: var(--warn); }
.card-status.tone-bad, .card-status.tone-error { background: var(--bad-bg); color: var(--bad); }
.card-status.tone-info { background: var(--info-bg); color: var(--info); }
.card-status.tone-idle { background: var(--surface-2); color: var(--text-3); }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.card-actions:empty { display: none; }
.card-body { padding: 16px 18px 18px; flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; }
.card-body:empty::before {
  content: ''; display: block; height: 76px; border-radius: 6px; opacity: .9;
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) 0 0 / 62% 12px no-repeat,
    linear-gradient(var(--surface-2), var(--surface-2)) 0 32px / 86% 12px no-repeat,
    linear-gradient(var(--surface-2), var(--surface-2)) 0 64px / 44% 12px no-repeat;
  animation: pulse 1.6s ease-in-out infinite;
}
.card.is-missing .card-body { opacity: .85; }

/* ============================================================== buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 550; line-height: 1; cursor: pointer; white-space: nowrap; user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, filter .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn .icon { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; gap: 5px; }
.btn.sm .icon { width: 14px; height: 14px; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.sm.icon-only { width: 28px; }
.btn[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
.btn.busy .icon, .btn.spin .icon { animation: spin 1s linear infinite; }

.input {
  height: 34px; min-width: 0; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13.5px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
textarea.input { height: auto; padding: 8px 12px; line-height: 1.55; resize: vertical; }
select.input { padding-right: 28px; }

/* ============================================================== badges, dots */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; vertical-align: middle;
  background: var(--surface-2); color: var(--text-2);
}
.badge .icon { width: 12px; height: 12px; }
.badge.tone-ok { background: var(--ok-bg); color: var(--ok); }
.badge.tone-warn { background: var(--warn-bg); color: var(--warn); }
.badge.tone-bad { background: var(--bad-bg); color: var(--bad); }
.badge.tone-info { background: var(--info-bg); color: var(--info); }
.badge.tone-accent { background: var(--accent-bg); color: var(--accent); }
.badge.tone-muted { background: var(--surface-2); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-3); }
.dot.tone-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.tone-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.dot.tone-bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.dot.tone-info { background: var(--info); box-shadow: 0 0 0 3px var(--info-bg); }
.dot.tone-accent { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.dot.tone-muted { background: var(--text-3); }

/* ============================================================== key/value + data tables */
.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kv th {
  width: 7.5em; padding: 7px 14px 7px 0; text-align: left; vertical-align: top; white-space: nowrap;
  font-weight: 500; color: var(--text-3);
}
.kv td { padding: 7px 0; vertical-align: top; color: var(--text); overflow-wrap: anywhere; }
.kv tr + tr > th, .kv tr + tr > td { border-top: 1px dashed var(--border); }

.tbl-wrap {
  width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  padding: 8px 12px; text-align: left; white-space: nowrap; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.tbl td { padding: 8px 12px; vertical-align: middle; border-bottom: 1px solid var(--border); overflow-wrap: break-word; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:nth-child(even) td { background: var(--zebra); }
.tbl tbody tr:hover td { background: var(--accent-bg); }
.tbl .num, .tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr.tbl-empty td, .tbl tr.tbl-empty:hover td { background: transparent; }
.tbl td .ip-text { max-width: 26em; }

/* ============================================================== stat tiles, meter */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
/* four tiles: 4 / 2 / 1 columns, never a 3 + 1 orphan row (breakpoints follow the card-body width; IPv4 never wraps) */
.stats:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 880px) and (max-width: 1099px) { .stats:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .card.full .stats:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 539px) { .stats:has(> :nth-child(4):last-child) { grid-template-columns: minmax(0, 1fr); } }
.stat {
  position: relative; min-width: 0; padding: 10px 12px 10px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.stat[data-tone]::before {
  content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--text-3);
}
.stat-label { font-size: 12px; color: var(--text-3); }
.stat-value { margin-top: 2px; font-size: 18px; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.stat-sub { margin-top: 2px; font-size: 12px; color: var(--text-3); overflow-wrap: anywhere; }
.stat.tone-ok .stat-value { color: var(--ok); }   .stat.tone-ok::before { background: var(--ok); }
.stat.tone-warn .stat-value { color: var(--warn); } .stat.tone-warn::before { background: var(--warn); }
.stat.tone-bad .stat-value { color: var(--bad); }   .stat.tone-bad::before { background: var(--bad); }
.stat.tone-info .stat-value { color: var(--info); } .stat.tone-info::before { background: var(--info); }
.stat.tone-accent .stat-value { color: var(--accent); } .stat.tone-accent::before { background: var(--accent); }

.meter { height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.meter.tone-ok > span { background: var(--ok); }
.meter.tone-warn > span { background: var(--warn); }
.meter.tone-bad > span { background: var(--bad); }
.meter.tone-info > span { background: var(--info); }
.meter.tone-muted > span { background: var(--text-3); }

/* ============================================================== ring gauge */
.ring { position: relative; width: var(--size, 120px); height: var(--size, 120px); flex: none; color: var(--accent); }
.ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-track { fill: none; stroke: var(--surface-3); }
.ring-val { fill: none; stroke: currentColor; stroke-linecap: round; transition: stroke-dasharray .9s cubic-bezier(.2, .8, .2, 1); }
.ring.pending .ring-val { opacity: .45; transform-box: fill-box; transform-origin: center; animation: spin 1.3s linear infinite; }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 0 12%;
}
.ring-value { font-size: calc(var(--size, 120px) * .27); font-weight: 700; line-height: 1.05; color: var(--text); font-variant-numeric: tabular-nums; }
.ring-label { margin-top: 3px; font-size: 12px; color: var(--text-3); line-height: 1.2; }
.ring-sub { margin-top: 2px; font-size: 12.5px; font-weight: 650; color: currentColor; line-height: 1.2; }
.ring.tone-ok { color: var(--ok); }
.ring.tone-warn { color: var(--warn); }
.ring.tone-bad { color: var(--bad); }
.ring.tone-info { color: var(--info); }
.ring.tone-accent { color: var(--accent); }
.ring.tone-muted { color: var(--text-3); }

/* ============================================================== callouts & states */
.callout {
  display: flex; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13px; line-height: 1.6; color: var(--text); background: var(--surface-2);
}
.callout-icon { flex: none; display: grid; place-items: center; height: 21px; }
.callout-icon .icon { width: 17px; height: 17px; }
.callout-main { min-width: 0; }
.callout-title { font-weight: 650; }
.callout-body { color: var(--text-2); }
.callout.tone-info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.callout.tone-info .callout-icon { color: var(--info); }
.callout.tone-ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.callout.tone-ok .callout-icon { color: var(--ok); }
.callout.tone-warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 24%, transparent); }
.callout.tone-warn .callout-icon { color: var(--warn); }
.callout.tone-bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 24%, transparent); }
.callout.tone-bad .callout-icon { color: var(--bad); }
.callout.tone-accent { background: var(--accent-bg); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.callout.tone-accent .callout-icon { color: var(--accent); }
.callout.tone-muted { background: var(--surface-2); border-color: var(--border); }
.callout.tone-muted .callout-icon { color: var(--text-3); }

.spinner {
  display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; opacity: .85; vertical-align: -2px;
  animation: spin .8s linear infinite;
}
.loading { display: flex; align-items: center; gap: 10px; padding: 16px 0; font-size: 13px; color: var(--text-3); }
.loading .spinner { color: var(--accent); }
.empty { padding: 18px 8px; text-align: center; font-size: 13px; color: var(--text-3); }
.err {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--bad-bg); color: var(--bad); font-size: 13px;
}
.err .icon { margin-top: 2px; }

.skeleton-block { display: grid; gap: 10px; }
.skeleton {
  height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}
.skeleton.lg { height: 30px; }
.skeleton.md { height: 18px; }

/* ============================================================== IP text + copy */
.ip-text { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; min-width: 0; vertical-align: middle; }
.ip { font-family: var(--mono); font-variant-ligatures: none; word-break: normal; overflow-wrap: anywhere; transition: filter .2s; }
.ip.v4 { white-space: nowrap; overflow-wrap: normal; }      /* IPv4 / v4 CIDR never split mid-number */
.ip.v6 { word-break: break-all; }                           /* long IPv6 may wrap anywhere */
.copy {
  flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 5px;
  background: transparent; color: var(--text-3); cursor: pointer; opacity: .75; transition: background-color .15s, color .15s, opacity .15s;
}
.copy:hover { background: var(--surface-2); color: var(--accent); opacity: 1; }
.copy.copied { color: var(--ok); opacity: 1; }
.copy .icon { width: 14px; height: 14px; }
body.privacy .ip, html.privacy .ip { filter: blur(6px); }
body.privacy .ip:hover, body.privacy .ip-text:focus-within .ip,
html.privacy .ip:hover, html.privacy .ip-text:focus-within .ip { filter: none; }

/* ============================================================== tabs */
.tabs {
  display: inline-flex; max-width: 100%; gap: 2px; padding: 3px; overflow-x: auto; scrollbar-width: none;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 5px 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2);
  font-size: 13px; cursor: pointer; white-space: nowrap; transition: background-color .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--border); }
.tab:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================== check list */
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.check-item { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); transition: background-color .15s; }
.check-item:hover { background: var(--surface-2); }
.check-icon { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); color: var(--text-3); }
.check-icon .icon { width: 13px; height: 13px; stroke-width: 2.6; }
.check-icon .spinner { width: 12px; height: 12px; }
.check-item[data-status="pass"] .check-icon { background: var(--ok-bg); color: var(--ok); }
.check-item[data-status="warn"] .check-icon { background: var(--warn-bg); color: var(--warn); }
.check-item[data-status="fail"] .check-icon { background: var(--bad-bg); color: var(--bad); }
.check-item[data-status="unknown"] .check-icon { background: var(--surface-2); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--border); }
.check-item[data-status="pending"] .check-icon { background: var(--accent-bg); color: var(--accent); }
.check-text { flex: 1 1 auto; min-width: 0; }
.check-label { font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.check-detail { margin-top: 1px; font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.check-item[data-status="pending"] .check-label, .check-item[data-status="unknown"] .check-label { color: var(--text-2); }
.check-extra { flex: none; margin-left: auto; align-self: center; }

/* ============================================================== flags */
.flag {
  display: inline-block; flex: none; width: 20px; height: 15px; border-radius: 2px; object-fit: cover; vertical-align: -2px;
  background: var(--surface-2); box-shadow: 0 0 0 1px rgba(0, 0, 0, .1);
}
.flag.flag-text {
  width: auto; min-width: 20px; height: 16px; padding: 0 3px; font: 600 10px/16px var(--mono); text-align: center;
  color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border-strong); background: var(--surface-2);
}
.flag.flag-empty { width: 0; background: none; box-shadow: none; }

/* ============================================================== map, legend, notes, kbd */
.map {
  position: relative; z-index: 0; height: 440px; min-height: 260px; overflow: hidden;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2);
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-item > i, .legend-swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--c, var(--accent)); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--c, var(--accent));
}
.section-note { font-size: 12.5px; line-height: 1.65; color: var(--text-3); }
.section-note strong { color: var(--text-2); font-weight: 600; }
.kbd {
  display: inline-block; padding: 1px 6px; font: 12px/1.5 var(--mono); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px;
}

/* ============================================================== details / summary */
details { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
details > summary {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; list-style: none; user-select: none;
  font-size: 13px; font-weight: 600; color: var(--text-2); border-radius: var(--radius-sm);
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: ''; flex: none; width: 6px; height: 6px; margin: 0 3px 0 1px;
  border-right: 1.7px solid currentColor; border-bottom: 1.7px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s;
}
details[open] > summary::before { transform: rotate(45deg); margin-top: -3px; }
details > summary:hover { color: var(--text); background: var(--surface-2); }
details[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.details-body { padding: 10px 12px; min-width: 0; }
pre.json-view {
  margin: 0; max-height: 360px; overflow: auto; padding: 10px 12px; border-radius: 6px;
  font: 12px/1.55 var(--mono); white-space: pre-wrap; word-break: break-all; background: var(--surface-2); color: var(--text-2);
}

/* ============================================================== hero */
.hero {
  position: relative; overflow: hidden; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.hero::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent) 45%, var(--info));
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, .8fr) minmax(0, 1.35fr); }
.hero-col { min-width: 0; padding: 20px 22px; }
.hero-col + .hero-col { border-left: 1px solid var(--border); }
.hero-label {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .04em; color: var(--text-3);
}
.hero-label .icon { width: 15px; height: 15px; color: var(--accent); }
.hero-label .badge { letter-spacing: 0; }
.hero-ip-main { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; min-width: 0; }
.hero-ip-main .flag { width: 30px; height: 22px; border-radius: 3px; }
.hero-ip-main .flag.flag-text { height: 22px; line-height: 22px; font-size: 12px; padding: 0 5px; }
.hero-ip-main .ip { font-size: 30px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.hero-ip-main .ip.v6 { font-size: 21px; }
.hero-ip-main .copy { width: 28px; height: 28px; }
.hero-ip-main .copy .icon { width: 16px; height: 16px; }
.hero-loc { margin-top: 6px; font-size: 15px; font-weight: 600; }
.hero-isp { font-size: 13.5px; color: var(--text-2); }
.hero-lines { display: grid; gap: 7px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 13px; }
.hero-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.hero-line-label { flex: none; min-width: 5.2em; color: var(--text-3); }
.hero-line .muted { font-size: 12.5px; }

.hero-score { display: flex; flex-direction: column; align-items: center; text-align: center; }
.hero-score .hero-label { align-self: stretch; justify-content: center; }
.hero-hint { margin-top: 8px; max-width: 20em; font-size: 12px; line-height: 1.5; color: var(--text-3); text-wrap: balance; }
.hero-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.hero-note { margin-top: 10px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; }

.qtiles { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.qtile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0;
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); text-align: left; cursor: pointer;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.qtile:hover { border-color: var(--border-strong); background: var(--surface); box-shadow: var(--shadow); }
.qtile-label { display: flex; align-items: center; gap: 6px; width: 100%; font-size: 12px; color: var(--text-3); }
.qtile-label .icon { width: 14px; height: 14px; }
.qtile-label .dot, .qtile-label .spinner { margin-left: auto; }
.qtile-label .spinner { width: 11px; height: 11px; color: var(--accent); }
.qtile-value { font-size: 14px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.qtile-sub { font-size: 12px; color: var(--text-3); line-height: 1.35; overflow-wrap: anywhere; }
.qtile.tone-ok .qtile-value { color: var(--ok); }
.qtile.tone-warn .qtile-value { color: var(--warn); }
.qtile.tone-bad .qtile-value { color: var(--bad); }
.qtile.tone-info .qtile-value { color: var(--info); }
.qtile.tone-accent .qtile-value { color: var(--accent); }
.qtile.tone-muted .qtile-value { color: var(--text-2); }
.qtile.tone-pending .qtile-value { color: var(--text-3); font-weight: 500; }

@media (max-width: 1099px) {
  .hero-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); }
  .hero-checks { grid-column: 1 / -1; border-left: 0 !important; border-top: 1px solid var(--border); }
  .qtiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 719px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .hero-col { padding: 16px; }
  .hero-col + .hero-col { border-left: 0; border-top: 1px solid var(--border); }
  .hero-ip-main .ip { font-size: 25px; }
  .hero-ip-main .ip.v6 { font-size: 17px; }
  .qtiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* phones: the VPN / leak verdicts come right after the IP, the (IP-reputation) score ring after them, smaller */
  .hero-checks { order: 2; }
  .hero-score { order: 3; }
  .hero-score .ring { --size: 104px !important; }
}

/* ============================================================== dialog */
dialog.dialog {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.dialog[open] { display: flex; flex-direction: column; }
dialog.dialog::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.dialog-head h2 .icon { color: var(--accent); }
.dialog-body { display: grid; gap: 10px; padding: 16px 18px; overflow: auto; min-height: 0; }
.dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.summary-text { width: 100%; min-height: 280px; font: 12.5px/1.65 var(--mono); white-space: pre; overflow: auto; }

/* ============================================================== toasts */
.toasts {
  position: fixed; left: 50%; bottom: 24px; z-index: 2500; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9px;
  background: var(--text); color: var(--bg); font-size: 13px; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.toast::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); flex: none; }
.toast.tone-ok::before { background: #4ade80; }
.toast.tone-warn::before { background: #fbbf24; }
.toast.tone-bad::before { background: #f87171; }
.toast.tone-info::before { background: #60a5fa; }
.toast.show { opacity: 1; transform: none; }

/* ============================================================== footer */
.site-footer { margin-top: 8px; border-top: 1px solid var(--border); background: var(--bg-elev); }
.footer-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 26px var(--gutter) 20px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1.4fr); gap: 28px;
  font-size: 12.5px; line-height: 1.7; color: var(--text-2);
}
.footer-inner h3 { display: flex; align-items: center; gap: 7px; margin: 0 0 6px; font-size: 13px; color: var(--text); }
.footer-inner h3 .icon { width: 15px; height: 15px; color: var(--accent); }
.footer-inner p { margin: 0; }
.source-list { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; list-style: none; }
.source-list li {
  padding: 1px 8px; border-radius: 6px; font-size: 12px; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border);
}
.footer-bottom {
  max-width: var(--maxw); margin: 0 auto; padding: 12px var(--gutter) 22px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; font-size: 12px; color: var(--text-3);
}

/* ============================================================== Leaflet (loaded later by mod-map; higher specificity wins over leaflet.css) */
:root .leaflet-container { background: var(--surface-2); font: 12.5px/1.5 var(--font); color: var(--text); }
:root .leaflet-container a { color: var(--accent); }
:root .leaflet-container .leaflet-popup-content-wrapper,
:root .leaflet-container .leaflet-popup-tip {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
:root .leaflet-container .leaflet-popup-content-wrapper { border-radius: 10px; }
:root .leaflet-container .leaflet-popup-content { margin: 10px 14px; font-size: 12.5px; line-height: 1.55; }
:root .leaflet-container a.leaflet-popup-close-button { color: var(--text-3); }
:root .leaflet-container a.leaflet-popup-close-button:hover { color: var(--text); }
:root .leaflet-container .leaflet-bar { border: 1px solid var(--border-strong); box-shadow: var(--shadow); border-radius: 8px; overflow: hidden; }
:root .leaflet-container .leaflet-bar a {
  background: var(--surface); color: var(--text); border-bottom-color: var(--border);
}
:root .leaflet-container .leaflet-bar a:hover, :root .leaflet-container .leaflet-bar a:focus { background: var(--surface-2); color: var(--accent); }
:root .leaflet-container .leaflet-bar a.leaflet-disabled { background: var(--surface-2); color: var(--text-3); }
:root .leaflet-container .leaflet-control-layers {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow);
}
:root .leaflet-container .leaflet-control-layers-separator { border-top-color: var(--border); }
:root .leaflet-container .leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 82%, transparent); color: var(--text-3); font-size: 11px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
:root .leaflet-container .leaflet-control-attribution a { color: var(--text-2); }
:root .leaflet-container .leaflet-control-scale-line {
  background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--text-2); border-color: var(--text-3);
}
:root .leaflet-container .leaflet-tooltip {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow); border-radius: 6px;
}
:root .leaflet-container .leaflet-tooltip-top::before { border-top-color: var(--border-strong); }
:root .leaflet-container .leaflet-tooltip-bottom::before { border-bottom-color: var(--border-strong); }
:root .leaflet-container .leaflet-tooltip-left::before { border-left-color: var(--border-strong); }
:root .leaflet-container .leaflet-tooltip-right::before { border-right-color: var(--border-strong); }

/* ============================================================== responsive */
@media (max-width: 1099px) {
  .footer-inner { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .footer-inner .footer-sources { grid-column: 1 / -1; }
}
@media (max-width: 899px) {
  .btn-label-wide { display: none; }
}
@media (max-width: 719px) {
  :root { --gutter: 16px; }
  .header-inner { padding-top: 8px; column-gap: 10px; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand actions" "status status" "nav nav"; }
  .header-status { padding: 2px 0; }
  .brand { font-size: 16px; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; }
  .brand-sub { display: none; }
  .header-actions .btn-label { display: none; }
  .header-actions .btn { width: 34px; padding: 0; }
  .mode-badge { display: none; }
  .container { padding-top: 14px; }
  .card-head { padding: 12px 14px 10px; }
  .card-body { padding: 14px 14px 16px; }
  .map { height: 340px; }
  .footer-inner { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .kv th { width: 6em; padding-right: 10px; }
}
@media (max-width: 420px) {
  .header-actions { gap: 0; }
  .header-actions .btn { width: 32px; }
  .progress-pill { padding: 0 9px; }
}

/* ============================================================== motion */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: .9; } 50% { opacity: .45; } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .spinner, .ring.pending .ring-val { animation: spin 2.4s linear infinite !important; }
}

@media print {
  .site-header, .header-actions, .toasts, .card-actions, #notice-area { display: none !important; }
  body { background: #fff; }
  .card, .hero { box-shadow: none; break-inside: avoid; }
}
