:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --bg-soft: #eef1f5;
  --card: #ffffff;
  --card-hover: #fbfcfe;
  --border: #e3e7ee;
  --border-strong: #d2d8e3;
  --text: #0f172a;
  --text-soft: #4b5768;
  --muted: #7b8798;
  --accent: #f6821f;
  --accent-soft: #fff1e3;
  --blue: #2f6fed;
  --blue-soft: #e8f0ff;
  --green: #12855f;
  --green-soft: #e3f6ee;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 12px 28px -14px rgba(15, 23, 42, .16);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-soft: #0f151d;
  --card: #121a24;
  --card-hover: #16202c;
  --border: #1e2a38;
  --border-strong: #2a3949;
  --text: #e8eef7;
  --text-soft: #a9b6c7;
  --muted: #7c8b9d;
  --accent: #ff9d3f;
  --accent-soft: #2a1d10;
  --blue: #6ea0ff;
  --blue-soft: #142338;
  --green: #47d39a;
  --green-soft: #10261f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 18px 36px -18px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.wrap {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.glow {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 420px;
  background:
    radial-gradient(48% 60% at 22% 20%, rgba(246, 130, 31, .16), transparent 70%),
    radial-gradient(42% 55% at 78% 10%, rgba(47, 111, 237, .12), transparent 70%);
  filter: blur(18px);
  pointer-events: none;
  z-index: 0;
}

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), #e06a0a);
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(246, 130, 31, .9);
}
.brand-mark svg { width: 20px; height: 20px; }

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand-text p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- live pill ---------- */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--muted);
  background: var(--bg-soft);
  transition: color .2s ease, background .2s ease, border-color .2s ease;
}
.live-pill .dot {
  position: relative;
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}
.live-pill .dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
}
.live-pill[data-state="live"] {
  color: var(--green);
  background: var(--green-soft);
  border-color: color-mix(in srgb, var(--green) 30%, transparent);
}
.live-pill[data-state="live"] .dot::after { animation: ripple 1.9s ease-out infinite; }
@keyframes ripple {
  0%   { transform: scale(1);   opacity: .55; }
  70%  { transform: scale(3.2); opacity: 0; }
  100% { transform: scale(3.2); opacity: 0; }
}
.live-pill[data-state="stale"] {
  color: #b45309;
  background: var(--accent-soft);
  border-color: color-mix(in srgb, #b45309 30%, transparent);
}
[data-theme="dark"] .live-pill[data-state="stale"] { color: var(--accent); }
.live-pill[data-state="error"] {
  color: #dc2626;
  background: rgba(220, 38, 38, .08);
  border-color: color-mix(in srgb, #dc2626 30%, transparent);
}
[data-theme="dark"] .live-pill[data-state="error"] { color: #f87171; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text-soft);
  cursor: pointer;
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-hover); }
.icon-btn:active { transform: scale(.96); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.i-moon { display: none; }
[data-theme="dark"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: block; }

/* ---------- hero ---------- */
.hero { position: relative; z-index: 1; padding: 44px 0 26px; }
.hero h2 {
  margin: 0 0 10px;
  font-size: clamp(26px, 4.2vw, 36px);
  line-height: 1.22;
  letter-spacing: -.02em;
  font-weight: 700;
}
.hero p {
  margin: 0;
  max-width: 620px;
  color: var(--text-soft);
  font-size: 15px;
}

/* ---------- stats ---------- */
.stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); background: var(--card-hover); }
.stat-num { font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat[data-jump="all"] .stat-num { color: var(--accent); }
.stat[data-jump="telecom"] .stat-num { color: var(--blue); }
.stat[data-jump="unicom"] .stat-num { color: var(--green); }
.stat[data-jump="mobile"] .stat-num { color: #b45309; }
[data-theme="dark"] .stat[data-jump="mobile"] .stat-num { color: #f0b429; }

/* ---------- panel ---------- */
.panel {
  position: relative;
  z-index: 1;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.tab {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 15px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
}

.panel-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.updated { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-soft);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn svg { width: 14px; height: 14px; }
.btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--card-hover); }

/* ---------- node list ---------- */
.nodes {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.node {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
  min-width: 0;
}
.node:hover { border-color: var(--accent); background: var(--card-hover); }
.node:active { transform: scale(.995); }

.node-main { flex: 1; min-width: 0; }
.node-ip {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.node-meta {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chip-latency { background: var(--blue-soft); color: var(--blue); }
.chip-latency.good { background: var(--green-soft); color: var(--green); }
.chip-latency.bad { background: var(--accent-soft); color: #c2410c; }
[data-theme="dark"] .chip-latency.bad { color: var(--accent); }
.chip-loss { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.chip-score { background: transparent; color: var(--muted); font-size: 11px; }

.node-copy {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--bg-soft);
  color: var(--muted);
  transition: background .15s ease, color .15s ease;
}
.node:hover .node-copy { color: var(--accent); background: var(--accent-soft); }
.node-copy svg { width: 15px; height: 15px; }

.empty { padding: 56px 20px; text-align: center; }
.empty p { margin: 0 0 6px; }

/* ---------- howto ---------- */
.howto {
  position: relative;
  z-index: 1;
  margin: 22px 0 34px;
  padding: 22px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: 16px;
  background: color-mix(in srgb, var(--card) 60%, transparent);
}
.howto h3 { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.howto ol { margin: 0 0 12px; padding-left: 20px; color: var(--text-soft); }
.howto li { margin-bottom: 6px; }
.howto li::marker { color: var(--accent); font-weight: 600; }

/* ---------- footer ---------- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 20px 0 30px;
}
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.site-footer p { margin: 0; font-size: 12.5px; color: var(--text-soft); }

.footer-links { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.footer-links .sep { color: var(--border-strong); }
.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.footer-links a svg { width: 14px; height: 14px; opacity: .75; }
.footer-links a:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.footer-links a:hover svg { opacity: 1; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  padding: 10px 18px;
  border-radius: 12px;
  background: #101826;
  color: #fff;
  font-size: 13.5px;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, .55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 60;
  max-width: calc(100vw - 40px);
  text-align: center;
}
[data-theme="dark"] .toast { background: #e8eef7; color: #0b0f14; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .hero { padding: 32px 0 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px 15px; }
  .stat-num { font-size: 22px; }
  .nodes { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 7px 0; }
  .panel-tools { width: 100%; justify-content: space-between; }
  .howto { padding: 18px; }
}

@media (max-width: 560px) {
  .brand-text p { display: none; }
  .live-pill { padding: 4px 10px 4px 8px; font-size: 12px; }
  .header-inner { height: 58px; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* focus */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
