*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b1120;
  --bg-elevated: #111827;
  --surface: rgba(17, 24, 39, 0.72);
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --dl: #22d3ee;
  --ul: #a78bfa;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.35);

  /* 统一间距 */
  --space-page-x: 1.25rem;
  --space-page-y: 2rem;
  --space-page-bottom: 2.5rem;
  --space-section: 1rem;
  --space-panel: 1.25rem;
  --space-panel-sm: 0.85rem;
  --space-inner: 0.75rem;
}

html { scroll-behavior: smooth; }

body {
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(59, 130, 246, 0.18), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(34, 211, 238, 0.08), transparent 55%);
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-page-y) var(--space-page-x) var(--space-page-bottom);
  display: flex;
  flex-direction: column;
  gap: var(--space-section);
}

/* ── Header ── */
.site-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  overflow: visible;
}

.brand-text {
  flex: 1;
  min-width: 0;
}

.lang-switch {
  position: relative;
  flex-shrink: 0;
  margin-inline-start: auto;
}

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.78rem;
  padding: 0.38rem 0.55rem 0.38rem 0.45rem;
  cursor: pointer;
  max-width: 10.5rem;
  line-height: 1.2;
}

.lang-trigger:hover {
  border-color: var(--border-strong);
  background: rgba(17, 24, 39, 0.88);
}

.lang-trigger:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.lang-flag {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  width: 1.15rem;
  text-align: center;
}

.lang-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.lang-chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg) translateY(-1px);
  flex-shrink: 0;
  margin-inline-start: 0.1rem;
  transition: transform 0.15s ease;
}

.lang-open .lang-chevron {
  transform: rotate(225deg) translateY(1px);
}

.lang-dropdown {
  width: 100%;
  margin-top: -0.35rem;
}

.lang-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem;
  margin: 0;
  padding: 0.65rem;
  list-style: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text);
  border: 1px solid transparent;
}

.lang-option:hover {
  background: var(--accent-soft);
  border-color: var(--border);
}

.lang-option.lang-option-active {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.45);
}

.lang-option-name {
  flex: 1;
  min-width: 0;
}

@media (min-width: 480px) {
  .lang-menu {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 640px) {
  .lang-menu {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

html[dir="rtl"] .site-header {
  flex-direction: row-reverse;
}

html[dir="rtl"] .region-legend,
html[dir="rtl"] .map-route-bar,
html[dir="rtl"] .probe-block-head,
html[dir="rtl"] .history-header,
html[dir="rtl"] .ad-link {
  direction: rtl;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-text h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-text p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 0.1rem;
}

/* ── Panels ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.panel-main { overflow: hidden; }

/* ── Visitor：单行次要信息，不抢测速主视觉 ── */
.visitor-line {
  margin: 0;
  padding: 0 0.25rem;
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.visitor-line code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.74rem;
  color: #7dd3fc;
  font-weight: 500;
}

.visitor-sep {
  margin: 0 0.4rem;
  opacity: 0.45;
}

.visitor-tz {
  color: #7dd3fc;
  font-variant-numeric: tabular-nums;
}

/* ── Region map ── */
.panel-region {
  padding: var(--space-panel-sm) var(--space-panel) var(--space-panel);
}

.region-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: var(--space-inner);
}

.region-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.region-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.region-tz {
  font-size: 0.74rem;
  color: #7dd3fc;
  font-variant-numeric: tabular-nums;
}

.map-route-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-bottom: var(--space-inner);
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.55);
  font-size: 0.78rem;
}

.route-end {
  font-weight: 600;
  color: #e2e8f0;
}

.route-from { color: #7dd3fc; }
.route-to { color: #c4b5fd; }

.route-arrow {
  color: var(--muted);
  opacity: 0.7;
}

.route-dist {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  font-variant-numeric: tabular-nums;
}

.region-map-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #0a1628;
  overflow: hidden;
}

.region-map-wrap.map-toggleable {
  cursor: pointer;
}

.map-view-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.55);
}

.map-view-bar.hidden,
.map-view-hint.hidden {
  display: none !important;
}

.map-view-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #7dd3fc;
}

.btn-map-toggle {
  font-size: 0.62rem;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  border: 1px solid rgba(96, 165, 250, 0.35);
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  cursor: pointer;
  white-space: nowrap;
}

.btn-map-toggle:hover {
  background: rgba(59, 130, 246, 0.22);
  color: #bfdbfe;
}

.map-view-hint {
  margin: 0;
  padding: 0.25rem 0.55rem 0;
  font-size: 0.62rem;
  color: var(--muted);
  opacity: 0.8;
}

.world-map-dual {
  position: relative;
  width: 100%;
  aspect-ratio: 2850 / 1860;
  background: #0a1628;
  line-height: 0;
}

.world-map-global,
.map-inset-panel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.world-map-dual.has-inset.mode-regional .world-map-global {
  visibility: hidden;
  pointer-events: none;
}

.world-map-dual.has-inset.mode-global .map-inset-panel {
  visibility: hidden;
  pointer-events: none;
}

.world-map-dual.has-inset.mode-regional .map-inset-panel {
  display: block !important;
  padding: 0;
  border: none;
  background: transparent;
}

.world-map-stack,
.map-inset-stack {
  position: relative;
  width: 100%;
  height: 100%;
  background: #0a1628;
  line-height: 0;
  overflow: hidden;
}

.map-inset-panel.hidden {
  display: none !important;
}

.map-inset-stack {
  --map-zoom: 1;
  shape-rendering: geometricPrecision;
}

svg.world-map-inset-land,
svg.world-map-inset {
  shape-rendering: geometricPrecision;
}

svg.world-map-inset-land {
  display: block;
  width: 100%;
  height: 100%;
}

.world-map-inset {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.map-viewport {
  fill: rgba(251, 191, 36, 0.08);
  stroke: rgba(251, 191, 36, 0.85);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.map-viewport.hidden {
  display: none;
}

.world-map-land-slot {
  display: block;
  width: 100%;
  min-height: 180px;
  background: #0a1628;
}

svg.world-map-land {
  display: block;
  width: 100%;
  height: 100%;
}

.world-map-land path {
  fill: #4a7ab0;
  stroke: #6b9fd4;
  stroke-width: 0.35;
}

.world-map-inset-land #world-land-group-inset path {
  fill: #4a7ab0;
  stroke: #5d8ec8;
  stroke-width: calc(0.42 / var(--map-zoom, 1));
}

.world-map-inset-land #world-border-group-inset .map-border-line {
  fill: none;
  stroke: rgba(226, 232, 240, 0.52);
  stroke-width: calc(0.72 / var(--map-zoom, 1));
  stroke-linejoin: round;
  stroke-linecap: round;
}

.world-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.map-grid-line {
  stroke: rgba(148, 163, 184, 0.14);
  stroke-width: 0.6;
}

.map-focus {
  fill: rgba(59, 130, 246, 0.08);
  stroke: rgba(96, 165, 250, 0.35);
  stroke-width: 1;
  stroke-dasharray: 5 4;
}

.map-focus.hidden {
  display: none;
}

.map-line-dl {
  fill: none;
  stroke: var(--dl);
  stroke-linecap: round;
  opacity: 0.55;
}

.map-line-ul {
  fill: none;
  stroke: var(--ul);
  stroke-linecap: round;
  opacity: 0.55;
}

.map-line-dl.map-line-measured {
  filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.35));
}

.map-line-ul.map-line-measured {
  filter: drop-shadow(0 0 4px rgba(167, 139, 250, 0.35));
}

.map-line-dl.map-line-anim-ping,
.map-line-ul.map-line-anim-ping {
  stroke-dasharray: 10 14;
  animation: map-line-pulse 1.1s ease-in-out infinite;
}

.map-line-dl.map-line-anim-dl {
  stroke-dasharray: 14 10;
  animation: map-line-stream-dl 1s linear infinite;
  opacity: 0.92 !important;
  filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.55));
}

.map-line-ul.map-line-anim-ul {
  stroke-dasharray: 14 10;
  animation: map-line-stream-ul 1s linear infinite;
  opacity: 0.92 !important;
  filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.55));
}

.map-line-dl.map-line-anim-dim,
.map-line-ul.map-line-anim-dim {
  opacity: 0.22 !important;
  filter: none;
}

@keyframes map-line-pulse {
  0%, 100% { stroke-dashoffset: 0; opacity: 0.45; }
  50% { stroke-dashoffset: -24; opacity: 0.95; }
}

@keyframes map-line-stream-dl {
  from { stroke-dashoffset: 48; }
  to { stroke-dashoffset: 0; }
}

@keyframes map-line-stream-ul {
  from { stroke-dashoffset: 48; }
  to { stroke-dashoffset: 0; }
}

.map-anim-active .map-marker-live {
  animation: map-marker-pulse 1.4s ease-in-out infinite;
}

.map-anim-ping .map-marker-live {
  animation-duration: 0.85s;
}

@keyframes map-marker-pulse {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); }
  50% { filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.45)); }
}

.map-anim-active .map-marker-ring {
  animation: map-ring-expand 1.6s ease-out infinite;
}

@keyframes map-ring-expand {
  0% { opacity: 0.75; stroke-width: inherit; }
  70% { opacity: 0.15; }
  100% { opacity: 0; }
}

.map-stat-live {
  animation: map-stat-glow 0.9s ease-in-out infinite;
}

@keyframes map-stat-glow {
  0%, 100% { opacity: 0.82; }
  50% { opacity: 1; }
}

.map-flow-dot {
  pointer-events: none;
}

.map-flow-ping {
  fill: #e2e8f0;
  animation: map-flow-ping-pulse 0.9s ease-in-out infinite;
}

.map-flow-ping-b {
  animation-delay: 0.45s;
}

@keyframes map-flow-ping-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

.map-flow-dot.map-flow-dl { fill: var(--dl); }
.map-flow-dot.map-flow-ul { fill: var(--ul); }

.map-flow-travel.map-flow-dl .map-flow-dot {
  fill: var(--dl);
  filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.8));
}

.map-flow-travel.map-flow-ul .map-flow-dot {
  fill: var(--ul);
  filter: drop-shadow(0 0 4px rgba(167, 139, 250, 0.8));
}

.map-flow-travel {
  animation: map-flow-move var(--fdur, 1s) linear infinite;
  animation-delay: var(--fdelay, 0s);
}

@keyframes map-flow-move {
  0% {
    transform: translate(var(--x1), var(--y1));
    opacity: 0;
  }
  8% { opacity: 1; }
  92% { opacity: 1; }
  100% {
    transform: translate(var(--x2), var(--y2));
    opacity: 0;
  }
}

.map-flow-dl.map-flow-mid,
.map-flow-ul.map-flow-mid {
  animation: map-flow-mid-pulse 1.8s ease-in-out infinite;
}

@keyframes map-flow-mid-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.95; }
}

.map-stat {
  font-family: system-ui, sans-serif;
  font-weight: 700;
  paint-order: stroke;
  stroke: rgba(8, 15, 30, 0.9);
}

.map-stat-ping { fill: #cbd5e1; }
.map-stat-dl { fill: var(--dl); }
.map-stat-ul { fill: var(--ul); }

.map-marker {
  stroke: #0b1120;
}

.map-marker-ring {
  fill: none;
  opacity: 0.75;
}

.map-marker-client { fill: var(--dl); }
.map-marker-client + .map-marker-ring { stroke: var(--dl); }
.map-marker-server { fill: var(--ul); }
.map-marker-server + .map-marker-ring { stroke: var(--ul); }

.map-marker-label {
  font-weight: 600;
  fill: #f8fafc;
  font-family: system-ui, sans-serif;
  paint-order: stroke;
  stroke: rgba(8, 15, 30, 0.85);
  stroke-width: 0.18em;
}

.region-legend {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem 0.55rem;
  font-size: 0.72rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.region-legend i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.leg-client i { background: var(--dl); }
.leg-server i { background: var(--ul); }
.region-legend b {
  color: var(--text);
  font-weight: 600;
}

.panel-probe {
  padding: var(--space-panel);
}

.probe-header {
  margin-bottom: var(--space-inner);
}

.probe-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.probe-header p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.probe-blocks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

.probe-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(8, 15, 30, 0.45);
  padding: 0.5rem 0.55rem 0.55rem;
  min-width: 0;
}

.probe-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.external-caption {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.85;
}

.probe-badge {
  font-size: 0.62rem;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.probe-badge.auto {
  color: #7dd3fc;
  background: rgba(34, 211, 238, 0.1);
}

.btn-probe-all {
  font-size: 0.62rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  border: 1px solid rgba(96, 165, 250, 0.35);
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-probe-all:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.22);
  color: #bfdbfe;
}

.btn-probe-all:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.external-ping {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem;
}

.probe-idle .ext-item-idle {
  border-style: dashed;
  border-color: rgba(96, 165, 250, 0.25);
}

.external-loading {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 0.74rem;
  color: var(--muted);
  padding: 0.35rem;
}

.ext-item {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font-size: 0.72rem;
}

.ext-name {
  color: var(--muted);
  display: block;
  margin-bottom: 0.15rem;
}

.ext-latency {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ext-latency.idle { color: var(--muted); font-weight: 500; font-size: 0.68rem; }
.ext-latency.loading { color: #93c5fd; font-weight: 500; font-size: 0.68rem; }

.ext-item-click {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.ext-item-click:hover {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(30, 58, 95, 0.35);
}

.ext-item-click:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.55);
  outline-offset: 1px;
}
.ext-latency.ok { color: var(--dl); }
.ext-latency.warn { color: #fbbf24; }
.ext-latency.bad { color: #f87171; }

/* ── Speed core ── */
.speed-core {
  padding: var(--space-panel);
}

.gauge-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: var(--space-section);
}

.gauge {
  position: relative;
  width: 130px;
  height: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge svg { width: 130px; height: 130px; }

.gauge-track {
  fill: none;
  stroke: rgba(30, 41, 59, 0.9);
  stroke-width: 7;
}

.gauge-arc {
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s ease;
}

.gauge-arc-dl { stroke: var(--dl); filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.4)); }
.gauge-arc-ul { stroke: var(--ul); filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.4)); }

.gauge-text {
  position: absolute;
  top: 42px;
  text-align: center;
  width: 100%;
}

.gauge-value {
  font-size: 1.55rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

#gauge-dl .gauge-value { color: var(--dl); }
#gauge-ul .gauge-value { color: var(--ul); }

.gauge-unit {
  font-size: 0.72rem;
  color: var(--muted);
  display: block;
  margin-top: 0.1rem;
}

.gauge-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.btn-start {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--accent), #6366f1);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  flex-shrink: 0;
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.45);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s;
}

.btn-start:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(59, 130, 246, 0.55);
}

.btn-start:active:not(:disabled) { transform: translateY(0); }
.btn-start:disabled { opacity: 0.55; cursor: not-allowed; }

.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Metrics row ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

.metric {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.metric-ping::before { background: #64748b; }
.metric-dl::before { background: var(--dl); }
.metric-ul::before { background: var(--ul); }

.metric-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.metric-value {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.metric-ping .metric-value { color: #cbd5e1; }
.metric-dl .metric-value { color: var(--dl); }
.metric-ul .metric-value { color: var(--ul); }

/* ── Progress ── */
.progress-area { margin-top: var(--space-section); }

.progress-bar {
  height: 4px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--dl));
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

.progress-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.5rem;
}

.panel-history {
  padding: var(--space-panel);
  scroll-margin-top: var(--space-section);
}

.history-header { margin-bottom: var(--space-inner); }

.history-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.history-header p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.history-count { color: var(--dl); font-weight: 500; }

.history-chart-wrap {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-panel-sm) var(--space-inner) var(--space-inner);
  margin-bottom: var(--space-inner);
}

.chart-legend {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.legend-dl::before,
.legend-ul::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.legend-dl::before { background: var(--dl); }
.legend-ul::before { background: var(--ul); }

.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 3px;
  height: 140px;
  border-bottom: 1px solid var(--border);
  padding: 0 0.15rem;
}

.bar-group {
  flex: 1;
  min-width: 24px;
  max-width: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.bar-pair {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
}

.bar {
  width: 42%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: height 0.35s ease;
}
.bar-dl { background: var(--dl); opacity: 0.85; }
.bar-ul { background: var(--ul); opacity: 0.85; }

.bar-label {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 0.2rem;
  font-variant-numeric: tabular-nums;
}

.chart-axis {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.4rem;
}

.history-loading,
.history-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1rem;
}

.history-empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.85rem;
}

.history-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.35);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.history-table th,
.history-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.history-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.72rem;
}

.history-table td { font-variant-numeric: tabular-nums; }
.history-table tbody tr:last-child td { border-bottom: none; }
.history-table tbody tr:hover { background: rgba(59, 130, 246, 0.06); }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ── 广告位（本地资源，非固定/非遮挡） ── */
.ad-slot {
  position: relative;
  margin: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(8, 15, 30, 0.55);
  border: 1px dashed rgba(148, 163, 184, 0.18);
  isolation: isolate;
}

.ad-close {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 3;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background: rgba(11, 17, 32, 0.88);
  color: #94a3b8;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.ad-close:hover,
.ad-close:focus-visible {
  color: #f1f5f9;
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(148, 163, 184, 0.4);
  outline: none;
}

.ad-close span {
  display: block;
  margin-top: -1px;
}

.ad-slot.ad-closed {
  display: none;
}

.ad-label {
  position: absolute;
  top: 5px;
  left: 6px;
  z-index: 1;
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(11, 17, 32, 0.82);
  padding: 1px 6px;
  border-radius: 3px;
  pointer-events: none;
  line-height: 1.4;
}

.ad-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 2.5rem 0.7rem 0.85rem;
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  min-height: 0;
}

.ad-banner { min-height: 72px; }
.ad-card { min-height: 96px; flex-wrap: wrap; }
.ad-banner-compact { min-height: 56px; padding: 0.55rem 0.75rem; }

.ad-logo {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.ad-logo-round {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
}

.ad-logo-telecom {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.ad-logo-sim {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(160deg, #38bdf8, #0284c7);
  position: relative;
}

.ad-logo-sim::before {
  content: "";
  position: absolute;
  inset: 8px 14px 8px 8px;
  border-radius: 3px;
  background: #0c4a6e;
  border: 1.5px dashed rgba(186, 230, 253, 0.5);
}

.ad-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ad-title {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.3;
  color: #f1f5f9;
}

.ad-desc {
  font-size: 0.72rem;
  line-height: 1.4;
  color: #94a3b8;
}

.ad-meta {
  font-size: 0.65rem;
  color: #64748b;
  margin-top: 0.1rem;
}

.ad-cta {
  flex-shrink: 0;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  color: #fff;
}

.ad-cta-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.7rem;
}

.ad-side {
  flex-shrink: 0;
  text-align: center;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.ad-side-label {
  display: block;
  font-size: 0.6rem;
  color: #94a3b8;
}

.ad-side-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: #22d3ee;
  line-height: 1.2;
}

.ad-side-value small {
  font-size: 0.65rem;
  font-weight: 600;
  color: #fdba74;
}

.ad-price {
  flex-shrink: 0;
  text-align: center;
}

.ad-price-main {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
}

.ad-price-sub {
  display: block;
  font-size: 0.6rem;
  color: #6ee7b7;
  margin-top: 0.1rem;
}

.ad-price-inline {
  font-size: 0.68rem;
  color: #fdba74;
  margin-top: 0.15rem;
}

.ad-price-inline s {
  color: #78716c;
  margin-right: 0.25rem;
}

.ad-price-inline b {
  color: #fb923c;
  font-size: 0.82rem;
}

.ad-speed-bar {
  display: block;
  width: 72px;
  height: 4px;
  margin-top: 0.3rem;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.ad-speed-bar i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: #f97316;
}

.ad-theme-aliyun {
  background: linear-gradient(135deg, #0c1a3a 0%, #122a52 55%, #0a1628 100%);
}

.ad-theme-aliyun .ad-logo {
  background: linear-gradient(135deg, #ff6a00, #ff8f3d);
  color: #fff;
}

.ad-theme-aliyun .ad-cta {
  background: linear-gradient(135deg, #ff6a00, #ff8f3d);
}

.ad-theme-game {
  background: linear-gradient(135deg, #1a0a2e, #2d1b4e);
}

.ad-theme-game .ad-logo {
  background: rgba(124, 58, 237, 0.35);
  border: 2px solid #a855f7;
  font-size: 1.2rem;
}

.ad-theme-game .ad-cta {
  background: #7c3aed;
}

.ad-theme-game .ad-title { color: #faf5ff; }
.ad-theme-game .ad-desc { color: #a78bfa; }

.ad-theme-vpn {
  background: linear-gradient(90deg, #0d2818, #134e2a);
}

.ad-theme-vpn .ad-logo {
  background: transparent;
  border: 3px solid #10b981;
  color: #34d399;
}

.ad-theme-vpn .ad-title { color: #ecfdf5; }
.ad-theme-vpn .ad-desc { color: #6ee7b7; }

.ad-theme-telecom {
  background: linear-gradient(135deg, #1c0a00, #3d1508, #1a0800);
  border-left: 4px solid #dc2626;
}

.ad-theme-telecom .ad-logo-telecom {
  background: #dc2626;
  color: #fff;
}

.ad-theme-telecom .ad-title { color: #fff; }

.ad-theme-mobile {
  background: linear-gradient(90deg, #0c1929, #0f2744, #0c1929);
}

.ad-theme-mobile .ad-title { color: #f0f9ff; }
.ad-theme-mobile .ad-cta { background: #0284c7; }

.hidden { display: none !important; }

@media (max-width: 960px) {
  .probe-blocks { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  :root {
    --space-page-x: 1rem;
    --space-page-y: 1.25rem;
    --space-page-bottom: 2rem;
    --space-section: 0.75rem;
    --space-panel: 1rem;
    --space-panel-sm: 0.75rem;
    --space-inner: 0.65rem;
  }

  /* 手机：测速优先，主流程无广告穿插；5 个广告统一沉底展示 */
  .site-header { order: 1; }
  .lang-dropdown { order: 2; }
  .visitor-line { order: 3; }
  .panel-main { order: 4; }
  .panel-region { order: 5; }
  #history-section { order: 6; }
  #probe-section { order: 7; }

  #ad-slot-top { order: 20; }
  #ad-slot-map-after { order: 21; }
  #ad-slot-speed-after { order: 22; }
  #ad-slot-history-after { order: 23; }
  #ad-slot-footer { order: 24; }
  .container > footer { order: 30; }

  .panel-region {
    flex-shrink: 0;
    overflow: visible;
  }

  .map-route-bar {
    font-size: 0.72rem;
  }

  .map-view-bar {
    padding: 0.3rem 0.5rem;
  }

  .map-view-hint {
    padding-bottom: 0.15rem;
  }

  .region-map-wrap {
    overflow: visible;
  }

  .region-map-wrap.map-toggleable {
    -webkit-tap-highlight-color: transparent;
  }

  /* 按宽度等比缩放，完整显示地图（不裁切下半部分） */
  .world-map-dual {
    width: 100%;
    aspect-ratio: 2850 / 1860;
    height: auto;
    max-height: none;
    min-height: 0;
    flex-shrink: 0;
  }

  .world-map-stack,
  .map-inset-stack {
    overflow: visible;
  }

  .region-legend {
    padding: 0.35rem 0.5rem 0.45rem;
    font-size: 0.68rem;
    flex-wrap: wrap;
    gap: 0.3rem 0.5rem;
  }

  .region-legend .leg-client,
  .region-legend .leg-server {
    min-width: 0;
    flex: 1 1 45%;
  }

  .ad-close {
    width: 36px;
    height: 36px;
    top: 4px;
    right: 4px;
  }

  .ad-link {
    gap: 0.55rem;
    padding: 0.55rem 2.5rem 0.55rem 0.65rem;
  }

  .ad-banner { min-height: auto; }
  .ad-card { flex-direction: column; align-items: stretch; }

  .ad-logo {
    width: 36px;
    height: 36px;
    font-size: 0.72rem;
  }

  .ad-title { font-size: 0.84rem; }
  .ad-desc { font-size: 0.68rem; }

  .ad-side,
  .ad-price {
    align-self: flex-start;
  }

  .ad-cta {
    align-self: stretch;
    text-align: center;
    margin-top: 0.25rem;
  }

  .ad-card .ad-cta-sm {
    align-self: stretch;
  }

  .ad-banner-compact {
    flex-wrap: wrap;
  }

  .ad-banner-compact .ad-cta {
    width: 100%;
    margin-top: 0.15rem;
  }

  .visitor-line {
    font-size: 0.72rem;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .external-ping { grid-template-columns: 1fr; }

  .gauge-area {
    flex-direction: column;
    gap: 0.75rem;
  }

  .gauge { width: 110px; height: 128px; }
  .gauge svg { width: 110px; height: 110px; }
  .gauge-text { top: 34px; }
  .gauge-value { font-size: 1.35rem; }

  .btn-start {
    width: 100%;
    height: 48px;
    border-radius: var(--radius-sm);
    order: -1;
    margin-bottom: 0.5rem;
  }

  .speed-core .gauge-area { display: grid; grid-template-columns: 1fr 1fr; }
  .speed-core .btn-start { grid-column: 1 / -1; }

  /* 测速中压缩面板高度，避免把地图挤出视口 */
  .panel-main.is-testing .speed-core {
    padding: 0.65rem 0.75rem 0.55rem;
  }

  .panel-main.is-testing .gauge-area {
    margin-bottom: 0.45rem;
    gap: 0.4rem;
  }

  .panel-main.is-testing .btn-start {
    height: 40px;
    margin-bottom: 0.25rem;
  }

  .panel-main.is-testing .gauge {
    width: 92px;
    height: 104px;
  }

  .panel-main.is-testing .gauge svg {
    width: 92px;
    height: 92px;
  }

  .panel-main.is-testing .gauge-text {
    top: 26px;
  }

  .panel-main.is-testing .gauge-value {
    font-size: 1.1rem;
  }

  .panel-main.is-testing .gauge-label {
    font-size: 0.68rem;
    margin-top: 0.05rem;
  }

  .panel-main.is-testing .metrics {
    display: none;
  }

  .panel-main.is-testing .progress-area {
    margin-top: 0.4rem;
  }

  .panel-main.is-testing .progress-label {
    font-size: 0.7rem;
    margin-top: 0.3rem;
    line-height: 1.3;
  }
}
