/* speet.xyz · iOS-inspired light theme
 * 设计参考：iPhone 系统级"网络测速"界面 + speedtest.net 仪表盘
 * 字体：SF Pro / system-ui
 * 主色：iOS Blue (#007aff)
 * 背景：白底 + 顶部到底部的浅蓝径向渐变光晕
 */

:root {
  --bg: #ffffff;
  --bg-tint: #f5f8ff;
  --text: #1a1a1f;
  --text-dim: #6b7280;
  --text-faint: #a3a8b3;
  --accent: #007aff;
  --accent-light: #5ac8ff;
  --accent-faint: rgba(0, 122, 255, 0.08);
  --line: rgba(0, 0, 0, 0.06);
  --line-strong: rgba(0, 0, 0, 0.10);
  --card: rgba(255, 255, 255, 0.85);
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 8px 32px rgba(0, 122, 255, 0.07);
  --radius: 14px;
  --radius-lg: 22px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'SF Pro Text', 'SF Pro Display', BlinkMacSystemFont,
               'PingFang SC', 'Helvetica Neue', system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
  min-height: 100vh;
}

body {
  /* 整体淡蓝径向渐变（截图同款的氛围光） */
  background:
    radial-gradient(ellipse at 50% 100%, rgba(0, 122, 255, 0.10) 0%, rgba(90, 200, 255, 0.04) 35%, transparent 60%),
    radial-gradient(ellipse at 50% 0%, rgba(220, 235, 255, 0.6) 0%, transparent 50%),
    #ffffff;
  background-attachment: fixed;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 17px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 22px; height: 22px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  border-radius: 7px;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25);
}
.brand-mark::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 7px solid white;
}

.nav { display: flex; gap: 2px; }
.nav-link {
  padding: 7px 14px;
  font-size: 14px;
  color: var(--text-dim);
  border-radius: var(--radius-pill);
  transition: all 0.15s;
  font-weight: 500;
}
.nav-link:hover { color: var(--text); background: var(--accent-faint); }
.nav-link.active { color: var(--accent); background: var(--accent-faint); }

/* ============ 主区 ============ */
.main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 80px;
  display: flex; flex-direction: column;
  gap: 28px;
  align-items: center;
}

/* ============ 节点选择器 ============ */
.node-select-wrap {
  width: 100%; max-width: 360px;
  position: relative;
}
.node-select-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
  text-align: center;
}
.node-select { position: relative; }
.node-select-current {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.node-select-current:hover {
  border-color: var(--accent);
}
.node-select.open .node-chevron { transform: rotate(180deg); }
.node-chevron {
  color: var(--text-faint);
  transition: transform 0.2s;
}

.node-dropdown {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  z-index: 30;
  max-height: 320px;
  overflow-y: auto;
}
.node-option {
  padding: 12px 18px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
  display: flex; align-items: center; justify-content: space-between;
}
.node-option:hover { background: var(--accent-faint); }
.node-option.active { color: var(--accent); font-weight: 500; }
.node-option.active::after {
  content: '✓';
  color: var(--accent);
  font-weight: 600;
}
.node-option.disabled { color: var(--text-faint); cursor: not-allowed; }

/* ============ 仪表盘 ============ */
.gauge-stage {
  position: relative;
  width: 100%;
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 0;
}

.aura {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 480px; height: 480px;
  background: radial-gradient(circle,
    rgba(0, 122, 255, 0.18) 0%,
    rgba(90, 200, 255, 0.10) 30%,
    rgba(220, 235, 255, 0.05) 55%,
    transparent 75%);
  filter: blur(20px);
  z-index: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.aura.active {
  animation: aura-pulse 2s ease-in-out infinite;
}
@keyframes aura-pulse {
  0%, 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.85; transform: translate(-50%, -50%) scale(1.06); }
}

.gauge-shell {
  position: relative;
  width: 320px; height: 320px;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
@media (max-width: 420px) {
  .aura { width: 380px; height: 380px; }
  .gauge-shell { width: 280px; height: 280px; }
}

.gauge-svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  overflow: visible;  /* 允许刻度数字溢出 viewBox */
}
.gauge-progress {
  filter: drop-shadow(0 0 8px rgba(0, 122, 255, 0.4));
  transition: stroke-dashoffset 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* speedtest.net 同款刻度数字（环外侧，不与中央数字冲突） */
.gauge-label {
  fill: rgba(0, 0, 0, 0.45);
  font-family: -apple-system, 'SF Pro Text', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: middle;
  letter-spacing: -0.01em;
  user-select: none;
}
.gauge-label.major { fill: rgba(0, 0, 0, 0.65); font-weight: 600; font-size: 12px; }

/* 中央卡片 */
.gauge-card {
  position: relative;
  width: 62%; height: 62%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 1) 0%, rgba(245, 248, 255, 0.95) 100%);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 20px 60px rgba(0, 122, 255, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  z-index: 2;
}
.gauge-phase {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0;
}
.gauge-number {
  display: flex; align-items: baseline; justify-content: center;
  font-family: -apple-system, 'SF Pro Display', 'SF Pro Rounded', system-ui, sans-serif;
  font-size: 52px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  height: 56px;
  position: relative;
}
@media (max-width: 420px) {
  .gauge-number { font-size: 44px; height: 48px; }
}
.num {
  display: inline-block;
  /* 平滑过渡：iOS 系统级速度测试同款 —— 数字像物理仪表针一样流畅插值，不闪不糊 */
  transition: none;
}
.gauge-unit {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.gauge-icon {
  margin-top: 4px;
  height: 28px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.3s ease;
}
.gauge-icon.spin svg {
  animation: rot 1.4s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ============ 主操作按钮 ============ */
.btn-action {
  margin-top: 32px;
  padding: 14px 44px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.32);
  z-index: 2;
  position: relative;
}
.btn-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}
.btn-action:active {
  transform: translateY(0);
  background: #0066d6;
}
.btn-action.testing {
  background: rgba(255, 59, 48, 0.1);
  color: #ff3b30;
  box-shadow: 0 4px 14px rgba(255, 59, 48, 0.18);
}

/* ============ 结果摘要 ============ */
.results {
  width: 100%;
  display: flex; flex-direction: column;
  gap: 12px;
  animation: fadeUp 0.4s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.result-row.secondary {
  grid-template-columns: repeat(3, 1fr);
}

.result-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}
.result-icon {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.result-icon.down { background: rgba(0, 122, 255, 0.1); color: var(--accent); }
.result-icon.up   { background: rgba(48, 209, 88, 0.1); color: #30d158; }
.result-info { flex: 1; min-width: 0; }
.result-label {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}
.result-value {
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.result-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin-left: 4px;
  letter-spacing: 0;
}

.result-pill {
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  font-variant-numeric: tabular-nums;
}
.pill-label {
  font-size: 12px;
  color: var(--text-dim);
}
.pill-value {
  font-family: -apple-system, 'SF Pro Display', system-ui, sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.pill-unit {
  font-size: 11px;
  color: var(--text-faint);
}

/* ============ Meta ============ */
.meta-card {
  width: 100%;
  display: flex; flex-direction: column;
  gap: 0;
  padding: 4px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.meta-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.meta-item:last-child { border-bottom: none; }
.meta-label {
  color: var(--text-dim);
  font-weight: 500;
}
.meta-value {
  color: var(--text);
  font-family: -apple-system, 'SF Mono', Menlo, monospace;
  font-size: 13px;
  text-align: right;
  max-width: 65%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ 页脚 ============ */
.foot {
  text-align: center;
  padding: 20px 16px;
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}

/* ============ 通用：内容页（history/leaderboard/about） ============ */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  flex: 1;
}
.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 24px;
}
.page-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 0;
  overflow: hidden;
}
.page-card .row {
  display: grid;
  grid-template-columns: 2fr 1.5fr 1fr 1fr 1fr;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  align-items: center;
}
.page-card .row:last-child { border-bottom: none; }
.page-card .row.head {
  background: rgba(0, 0, 0, 0.015);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-card .row .num-cell {
  font-family: 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-faint);
}
.empty-state .ico {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--accent-faint);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.range-tabs {
  display: flex; gap: 4px;
  margin-bottom: 16px;
  background: var(--accent-faint);
  border-radius: var(--radius-pill);
  padding: 3px;
  width: fit-content;
}
.range-tab {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-dim);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.range-tab.active {
  background: white;
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.about-section { margin-bottom: 28px; }
.about-section h2 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.about-section p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.about-section ul {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-dim);
  padding-left: 22px;
  margin-bottom: 8px;
}
.about-section a { color: var(--accent); }

/* ============ 响应式 ============ */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; }
  .nav-link { padding: 6px 10px; font-size: 13px; }
  .main { padding: 20px 16px 60px; gap: 24px; }
  .meta-value { font-size: 12px; }
  .page { padding: 20px 16px 60px; }
}

/* 隐藏属性 */
[hidden] { display: none !important; }
