/* ==========================================================================
   NetSpeed Tester - 主样式
   - CSS 变量支持深/浅主题
   - 玻璃拟态（Glass Morphism）卡片
   - 流畅动效 + 性能优化（GPU 加速）
   ========================================================================== */

/* ---------- 主题变量 ---------- */
:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --surface: rgba(30, 41, 59, 0.5);
  --surface-2: rgba(30, 41, 59, 0.7);
  --glass: rgba(15, 23, 42, 0.55);
  --glass-border: rgba(148, 163, 184, 0.15);
  --glass-soft: rgba(30, 41, 59, 0.4);
  --text: #e2e8f0;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --accent: #06b6d4;
  --accent-2: #8b5cf6;
  --accent-glow: rgba(6, 182, 212, 0.4);
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --gradient: linear-gradient(135deg, #06b6d4, #8b5cf6);
  --gradient-2: linear-gradient(135deg, #f59e0b, #ef4444);
  --gradient-ok: linear-gradient(135deg, #10b981, #06b6d4);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --maxw: 1180px;
  --topbar-h: 64px;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-2: #ffffff;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-2: rgba(255, 255, 255, 0.85);
  --glass: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(15, 23, 42, 0.08);
  --glass-soft: rgba(241, 245, 249, 0.7);
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --accent: #0891b2;
  --accent-2: #7c3aed;
  --accent-glow: rgba(8, 145, 178, 0.25);
  --shadow: 0 10px 40px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
}

/* ---------- 全局 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 16px);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.3s, color 0.3s;
}

/* 背景渐变 + 网格 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 60% 50% at 20% 0%, rgba(6, 182, 212, 0.15), transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 30%, rgba(139, 92, 246, 0.12), transparent 60%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(245, 158, 11, 0.08), transparent 60%);
}

[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse 60% 50% at 20% 0%, rgba(6, 182, 212, 0.1), transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 30%, rgba(139, 92, 246, 0.08), transparent 60%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(245, 158, 11, 0.05), transparent 60%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
}

h1, h2, h3, h4 { margin: 0 0 0.5em; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-2); }
button { font-family: inherit; }
img, svg { max-width: 100%; display: block; }

::selection { background: var(--accent); color: #fff; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.5); }

/* 无障碍工具 */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link:focus {
  top: 0;
}

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-bottom: 1px solid var(--glass-border);
  height: var(--topbar-h);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand img { width: 36px; height: 36px; }

.brand-name { white-space: nowrap; }
.brand-accent {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav {
  display: flex;
  gap: 6px;
  margin: 0 auto;
}

.nav a {
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  transition: all 0.2s;
}

.nav a:hover {
  background: var(--glass-soft);
  color: var(--text);
}

.nav-sep {
  color: var(--muted);
  margin: 0 4px;
  opacity: 0.4;
  font-size: 12px;
  user-select: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--glass-border);
  background: var(--glass-soft);
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--text-2);
  transition: all 0.2s;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.icon-btn .icon-sun { display: none; }
[data-theme="light"] .icon-btn .icon-moon { display: none; }
[data-theme="light"] .icon-btn .icon-sun { display: block; }

.lang-switcher select {
  height: 40px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass-soft);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  transition: all 0.2s;
}

.lang-switcher select:hover {
  border-color: var(--accent);
}

.lang-switcher select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lang-switcher select option {
  background: var(--bg-2);
  color: var(--text);
}

/* ---------- 容器 ---------- */
.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 32px 16px 40px;
  position: relative;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text), var(--accent) 50%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  font-size: clamp(14px, 2vw, 16px);
  color: var(--muted);
  margin-bottom: 24px;
}

.ip-quick {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-2);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ip-quick b { color: var(--accent); font-weight: 600; }

.ip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse 1.6s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* ---------- 玻璃拟态面板 ---------- */
.glass,
.glass-soft {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(120% 50% at 22% -8%, rgba(255, 255, 255, 0.06), transparent 55%),
    radial-gradient(80% 40% at 85% 110%, rgba(6, 182, 212, 0.08), transparent 60%);
}

.glass-soft {
  background: var(--glass-soft);
  box-shadow: none;
}

.panel {
  padding: 28px;
  margin-bottom: 24px;
}

.panel-head {
  text-align: center;
  margin-bottom: 24px;
}

.panel-head h2 {
  font-size: clamp(20px, 3.2vw, 26px);
  margin-bottom: 4px;
}

.panel-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  user-select: none;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px var(--accent-glow);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-ghost {
  background: var(--glass-soft);
  color: var(--text);
  border: 1px solid var(--glass-border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-outline:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}

.btn.danger {
  background: var(--bad);
  color: #fff;
}

.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 24px 0;
  flex-wrap: wrap;
}

.controls-inline {
  margin: 0 0 16px;
  justify-content: flex-start;
}

/* ---------- 仪表盘 ---------- */
.gauge-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 24px;
  margin-bottom: 8px;
}

.gauge-wrap {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-ring {
  position: relative;
  width: 100%;
  max-width: 240px;
  aspect-ratio: 1;
}

.gauge-ring svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.gauge-bg {
  fill: none;
  stroke: var(--glass-border);
  stroke-width: 12;
}

.gauge-arc {
  fill: none;
  stroke: url(#gaugeGrad);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 628.32;
  stroke-dashoffset: 628.32;
  transition: stroke-dashoffset 0.2s linear;
  filter: drop-shadow(0 0 8px var(--accent-glow));
  transform: rotate(-90deg);
  transform-origin: center;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.gauge-num {
  font-size: clamp(40px, 7vw, 56px);
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.gauge-unit {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 2px;
  margin-top: 4px;
}

/* 仪表盘下方详情 —— 现代卡片式 */
.gauge-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 10px;
  width: 100%;
}

.gd-item {
  background: var(--glass-soft);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 6px 8px;
  text-align: center;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.gd-item::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient);
  opacity: 0;
  transition: opacity 0.3s;
}

.gd-item.done::before { opacity: 1; }

.gd-item-icon {
  display: none;
}

.gd-item-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.gd-item-label {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 1px;
}

.gd-item.highlight {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.08), rgba(139, 92, 246, 0.06));
  border-color: rgba(6, 182, 212, 0.3);
  padding: 7px 12px;
}

.gd-item.highlight .gd-item-value {
  font-size: 17px;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.chart-card {
  background: var(--glass-soft);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
}

.chart-card h3 {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}

.chart-phase {
  color: var(--accent);
  font-weight: 600;
  margin-left: 8px;
}

#speedChart {
  width: 100%;
  height: 180px;
  display: block;
  flex: 1;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.chart-legend i {
  display: inline-block;
  width: 10px;
  height: 3px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

.lg-dl { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.lg-up { background: var(--warn); box-shadow: 0 0 6px var(--warn); }

.chart-stats-text {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  font-weight: 500;
}

/* ---------- 结果卡片 ---------- */
.results {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 8px;
}

.result-card {
  padding: 18px 12px;
  text-align: center;
  border-radius: var(--radius);
  background: var(--glass-soft);
  border: 1px solid var(--glass-border);
  transition: all 0.3s;
}

.result-card.pending .r-value {
  color: var(--muted);
}

.r-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.r-value {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.r-value small {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 4px;
}

.r-grade {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
}

.grade-ex { color: var(--ok); background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.3); }
.grade-good { color: var(--accent); background: rgba(6, 182, 212, 0.12); border: 1px solid rgba(6, 182, 212, 0.3); }
.grade-mid { color: var(--warn); background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.3); }
.grade-bad { color: var(--bad); background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.3); }

/* ---------- 历史记录 ---------- */
.history {
  margin-top: 20px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--glass-soft);
  border: 1px solid var(--glass-border);
}

.history summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.history summary::before {
  content: "▸";
  color: var(--accent);
  transition: transform 0.2s;
  font-size: 12px;
}

.history[open] summary::before {
  transform: rotate(90deg);
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-list li {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  font-size: 13px;
  color: var(--text-2);
}

.history-list .h-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.history-list .h-metrics { display: flex; gap: 14px; flex-wrap: wrap; }
.history-list .h-metrics b { color: var(--accent); font-weight: 600; }
.history-empty { justify-content: center; color: var(--muted); }

/* ---------- IP 信息 ---------- */
.ip-grid-main {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 24px;
  align-items: start;
}

.ip-addr {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ip-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--glass-soft);
  border: 1px solid var(--glass-border);
  font-size: 14px;
  overflow: hidden;
}

.ip-line b {
  flex: 1;
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ip-tag {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 600;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.ip-tag.v4 { color: var(--accent); background: rgba(6, 182, 212, 0.12); border: 1px solid rgba(6, 182, 212, 0.3); }
.ip-tag.v6 { color: var(--accent-2); background: rgba(139, 92, 246, 0.12); border: 1px solid rgba(139, 92, 246, 0.3); }

.copy-btn {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.ip-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.meta-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--glass-soft);
  border: 1px solid var(--glass-border);
}

.meta-key {
  display: block;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.meta-val {
  display: block;
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
}

/* ---------- 地图 ---------- */
.map-wrapper {
  position: relative;
  width: 100%;
  height: 360px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--glass-border);
}

.map {
  width: 100%;
  height: 100%;
  background: var(--bg-2);
}

[data-theme="light"] .map { background: #e2e8f0; }

.map-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--glass);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--muted);
  font-size: 14px;
  z-index: 10;
  transition: opacity 0.4s;
}

.map-overlay.hide {
  opacity: 0;
  pointer-events: none;
}

.map-overlay-icon {
  font-size: 36px;
  animation: bounce 1.6s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.map-tip {
  margin: 12px 0 0;
  padding: 10px 14px;
  background: var(--glass-soft);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-size: 12px;
}

/* Leaflet 暗色主题调整 */
.leaflet-container { font-family: inherit; background: var(--bg-2); }

/* ---------- 网络质量评分 ---------- */
.quality-main {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 32px;
  align-items: center;
  margin-bottom: 20px;
}

.quality-score-wrap {
  position: relative;
  width: 100%;
  max-width: 240px;
  margin: 0 auto;
  aspect-ratio: 1;
}

.quality-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.quality-bg { fill: none; stroke: var(--glass-border); stroke-width: 12; }
.quality-arc {
  fill: none;
  stroke: url(#qualityGrad);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 534.07;
  stroke-dashoffset: 534.07;
  transition: stroke-dashoffset 0.6s ease;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.quality-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.quality-num {
  font-size: 56px;
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.quality-label {
  font-size: 14px;
  color: var(--muted);
  margin-top: 6px;
  letter-spacing: 1px;
}

.quality-details {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.q-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.q-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.q-row span:first-child { color: var(--muted); }
.q-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.q-bar {
  height: 8px;
  background: var(--glass-soft);
  border-radius: 4px;
  overflow: hidden;
}

.q-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 4px;
  transition: width 0.6s ease;
  width: 0;
}

.quality-tip {
  padding: 16px 20px;
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  background: var(--glass-soft);
}

.quality-tip h4 {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text);
}

.quality-tip p {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
}

/* ---------- 跨国延迟表 ---------- */
.progress-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.progress-mini-bar {
  width: 140px;
  height: 6px;
  background: var(--glass-soft);
  border-radius: 3px;
  overflow: hidden;
}

.progress-mini-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 3px;
  width: 0;
  transition: width 0.3s;
}

.global-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
}

.global-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 560px;
}

.global-table th {
  background: var(--glass-soft);
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--glass-border);
}

.global-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.global-table tr:last-child td { border-bottom: none; }
.global-table tr:hover td { background: var(--glass-soft); }
.global-table tr.testing td { color: var(--accent); }
.global-table tr.timeout td { color: var(--bad); }

.global-empty td {
  text-align: center;
  color: var(--muted);
  padding: 32px 14px;
  font-style: italic;
}

.global-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.global-bar-fill {
  height: 6px;
  border-radius: 3px;
  background: var(--gradient);
  min-width: 2px;
  transition: width 0.5s;
}

/* ---------- 关于 ---------- */
.panel h2 { font-size: clamp(18px, 2.8vw, 22px); margin-bottom: 16px; }

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.about-grid h3 {
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 6px;
}

.about-grid p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.7;
}

/* ---------- 页脚 ---------- */
.footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--glass-border);
}

.footer p { margin: 4px 0; }
.footer-sub { font-size: 12px; opacity: 0.7; }

.footer-links {
  margin-top: 12px;
  font-size: 12px;
}

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
  padding: 0 6px;
}

.footer-links a:hover {
  color: var(--accent);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface-2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 999;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 多 Toast 容器（源自 netdev-tool） */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 360px;
}

.toast-item {
  background: var(--surface-2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
  color: var(--text);
  pointer-events: auto;
  border-left: 3px solid var(--accent);
}

.toast-item.hide { animation: toastOut 0.3s ease forwards; }
.toast-item.toast-success { border-left-color: var(--ok); }
.toast-item.toast-success .toast-icon { color: var(--ok); }
.toast-item.toast-error { border-left-color: var(--bad); }
.toast-item.toast-error .toast-icon { color: var(--bad); }
.toast-item.toast-warn { border-left-color: var(--warn); }
.toast-item.toast-warn .toast-icon { color: var(--warn); }
.toast-item.toast-info { border-left-color: var(--accent); }
.toast-item.toast-info .toast-icon { color: var(--accent); }

.toast-icon {
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

.toast-msg { line-height: 1.4; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px); }
}

@media (max-width: 480px) {
  .toast-container { left: 16px; right: 16px; max-width: none; }
}

/* ---------- 输入行（源自 netdev-tool） ---------- */
.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.input {
  flex: 1;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.input::placeholder {
  color: var(--muted);
}

.input.input-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%2394a3b8' d='M6 8L1 3h10z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 30px;
  cursor: pointer;
}

.input.input-select option {
  background: var(--bg-2);
  color: var(--text);
}

/* ---------- Chip（快速测试按钮） ---------- */
.chip {
  background: var(--glass-soft);
  border: 1px solid var(--glass-border);
  color: var(--text-2);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(6, 182, 212, 0.08);
}

.quick-ping {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}

.quick-ping .dim { color: var(--muted); margin-right: 4px; }

/* ---------- 工具卡片网格 ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

@media (max-width: 700px) {
  .tool-grid { grid-template-columns: 1fr; }
}

.tool-card {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--glass-soft);
  border: 1px solid var(--glass-border);
  transition: border-color 0.2s;
}

.tool-card:hover { border-color: rgba(6, 182, 212, 0.4); }

.tool-card-wide { grid-column: 1 / -1; }

/* 自成一组的完整工具卡（包含输入 + 结果） */
.tool-card-full {
  margin-bottom: 16px;
}

.tool-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.tool-card-head .tool-card-title { margin-bottom: 0; }

.tool-card-status {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
}

.tool-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.tool-card-desc {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.6;
}

/* 内嵌结果区（紧贴输入下方） */
.inline-result {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--glass-border);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 滚动进入动画 ---------- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

.reveal.reveal-active {
  opacity: 1;
  transform: translateY(0);
}

.reveal-stagger > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-stagger.reveal-active > *:nth-child(1) { transition-delay: 0.05s; }
.reveal-stagger.reveal-active > *:nth-child(2) { transition-delay: 0.15s; }
.reveal-stagger.reveal-active > *:nth-child(3) { transition-delay: 0.25s; }
.reveal-stagger.reveal-active > *:nth-child(4) { transition-delay: 0.35s; }
.reveal-stagger.reveal-active > *:nth-child(5) { transition-delay: 0.45s; }
.reveal-stagger.reveal-active > *:nth-child(6) { transition-delay: 0.55s; }
.reveal-stagger.reveal-active > *:nth-child(7) { transition-delay: 0.65s; }
.reveal-stagger.reveal-active > *:nth-child(8) { transition-delay: 0.75s; }
.reveal-stagger.reveal-active > * { opacity: 1; transform: translateY(0); }

/* ---------- Hero 视觉优化 ---------- */
.hero {
  position: relative;
  isolation: isolate;
}

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 30% 40%, rgba(6, 182, 212, 0.15), transparent 50%),
    radial-gradient(circle at 70% 60%, rgba(139, 92, 246, 0.12), transparent 50%);
  animation: heroFloat 12s ease-in-out infinite;
}

@keyframes heroFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(2%, -1%) scale(1.02); }
  66% { transform: translate(-1%, 1%) scale(0.98); }
}

/* ---------- Panel 视觉层次强化 ---------- */
.panel {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.panel:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .panel:hover {
  box-shadow: 0 16px 50px rgba(15, 23, 42, 0.1);
}

/* ---------- 卡片悬停效果 ---------- */
.tool-card,
.ip-line,
.meta-item,
.result-card {
  transition: all 0.2s ease;
}

.result-card:hover {
  transform: translateY(-3px);
  border-color: rgba(6, 182, 212, 0.3);
  background: var(--surface);
}

/* ---------- 按钮点击波纹 ---------- */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.4), transparent);
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.4s, transform 0.4s;
}

.btn:active::after {
  opacity: 1;
  transform: scale(2);
  transition: 0s;
}

/* ---------- 顶部"回到顶部"按钮 ---------- */
.back-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px var(--accent-glow);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 50;
  border: none;
}

.back-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.back-top:hover {
  transform: translateY(-3px);
}

/* ---------- 平滑滚动 ---------- */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal-stagger > * {
    transition-duration: 0.01s;
    animation: none !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- 信任徽章 ---------- */
.trust-badges {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.trust-badge {
  text-align: center;
  min-width: 80px;
}

.trust-num {
  font-size: clamp(20px, 3.5vw, 28px);
  font-weight: 800;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.trust-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ---------- 测速中按钮动画 ---------- */
.btn.btn-loading {
  pointer-events: none;
  opacity: 0.85;
}

.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btnSpin 0.8s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}

@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

/* ---------- 快捷键弹窗 ---------- */
.shortcuts-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.2s;
}

.shortcuts-box {
  padding: 28px;
  max-width: 360px;
  width: 90%;
  border-radius: var(--radius-lg);
}

.shortcuts-box h3 {
  margin: 0 0 16px;
  font-size: 18px;
}

.shortcuts-box dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 16px;
  margin-bottom: 20px;
  font-size: 13px;
}

.shortcuts-box dt {
  background: var(--glass);
  padding: 4px 8px;
  border-radius: 6px;
  font-family: 'SF Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--glass-border);
  align-self: center;
  white-space: nowrap;
}

.shortcuts-box dd {
  margin: 0;
  color: var(--text-2);
}

.inline-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.inline-result-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.output-box.inline {
  max-height: 280px;
  min-height: 80px;
}

/* ---------- 输出框 ---------- */
.output-section { margin-top: 16px; }

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.output-title {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.output-actions { display: flex; gap: 6px; }

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
  background: var(--glass-soft);
  border: 1px solid var(--glass-border);
  color: var(--text-2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

.output-box {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  min-height: 120px;
  max-height: 360px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.8;
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
}

[data-theme="light"] .output-box {
  background: rgba(15, 23, 42, 0.04);
}

.output-line {
  display: block;
  margin-bottom: 2px;
  word-break: break-all;
}

.output-line.success { color: var(--ok); }
.output-line.error { color: var(--bad); }
.output-line.warn { color: var(--warn); }
.output-line.info { color: var(--accent); }
.output-line.dim { color: var(--muted); font-size: 12px; }
.output-line.accent { color: var(--accent-2); font-weight: 600; }

/* ---------- 统计卡片（复用 + 增强） ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 700px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--glass-soft);
  border: 1px solid var(--glass-border);
  text-align: center;
}

.stat-value {
  font-size: clamp(20px, 3.5vw, 26px);
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-card.ok .stat-value { color: var(--ok); }
.stat-card.warn .stat-value { color: var(--warn); }
.stat-card.error .stat-value { color: var(--bad); }

/* ---------- Traceroute 等表格的微调 ---------- */
.global-table tr.testing td { color: var(--accent); }
.global-table tr.timeout td { color: var(--bad); }
.global-table tr:hover td { background: var(--glass-soft); }

/* ---------- 网络能做什么 ---------- */
.usecase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.usecase-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.usecase-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--muted);
  transition: background 0.2s;
}

.usecase-excellent::before { background: var(--ok); }
.usecase-good::before { background: var(--accent); }
.usecase-fair::before { background: var(--warn); }
.usecase-poor::before { background: var(--bad); }

.usecase-item:hover {
  transform: translateX(2px);
  border-color: rgba(6, 182, 212, 0.4);
}

.usecase-icon {
  font-size: 28px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--glass);
  border-radius: 10px;
  flex-shrink: 0;
}

.usecase-content {
  flex: 1;
  min-width: 0;
}

.usecase-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.usecase-meta {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.usecase-req {
  font-size: 10px;
  padding: 1px 6px;
  background: var(--glass);
  border-radius: 4px;
}

.usecase-status {
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.usecase-status-excellent {
  background: rgba(16, 185, 129, 0.15);
  color: var(--ok);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.usecase-status-good {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.usecase-status-fair {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.usecase-status-poor {
  background: rgba(239, 68, 68, 0.15);
  color: var(--bad);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.usecase-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

.usecase-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

@media (max-width: 600px) {
  .usecase-grid {
    grid-template-columns: 1fr;
  }
  .usecase-status { font-size: 9px; padding: 3px 8px; }
}
