/* 网页 WiFi 测速工具 —— 样式（移动端优先，PC 自适应） */
:root {
  --bg1: #eef4ff;
  --bg2: #fdf3ff;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #3b82f6;
  --accent2: #8b5cf6;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(59, 130, 246, .12);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
/* 修复：display:grid/flex 等作者样式会覆盖 hidden 属性的 UA 默认 display:none */
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  /* 不用 background-attachment:fixed —— iOS Safari 不支持且影响截图/滚动性能 */
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 100%) no-repeat, var(--bg1);
  background-size: 100% 100%;
  min-height: 100vh;
}
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

/* 顶部 */
.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font-size: clamp(26px, 6vw, 36px); letter-spacing: 1px; }
.hero .sub { color: var(--muted); font-size: 13.5px; margin-top: 8px; }

/* 错误提示 */
.banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  margin-top: 16px;
  text-align: center;
}

.banner.info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

/* 访客网络信息条（IP / 运营商 / 地区 + 测速节点） */
.netinfo {
  margin-top: 16px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* 仪表盘 */
.gauge-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 16px 26px;
  text-align: center;
  margin-top: 16px;
}
.gauge { position: relative; width: min(64vw, 240px); margin: 0 auto; }
.gauge svg { width: 100%; display: block; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: #eef2f7; stroke-width: 12; }
.gauge-fill {
  fill: none;
  stroke: url(#gaugeGrad);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 603.2;
  stroke-dashoffset: 603.2;
  transition: stroke-dashoffset .2s linear;
}
.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.speed-num {
  font-size: clamp(36px, 9vw, 52px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  line-height: 1.1;
}
.speed-unit { color: var(--muted); font-size: 14px; margin-top: 4px; }
.phase { color: var(--muted); margin: 16px 0 18px; font-size: 15px; min-height: 22px; }

.btn-start {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  padding: 14px 56px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(99, 102, 241, .35);
  transition: transform .15s, opacity .2s;
  min-height: 48px;
}
.btn-start:active { transform: scale(.96); }
.btn-start:disabled { opacity: .55; cursor: not-allowed; }

/* 结果区 */
.results {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 20px;
}
.stat {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.stat-icon { font-size: 24px; flex: none; }
.stat b {
  display: block;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat i { font-style: normal; color: var(--muted); font-size: 12px; }
.verdict {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #eef6ff, #f5f0ff);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  text-align: center;
}

/* 广告占位（上线后替换为联盟广告代码） */
.ad-slot {
  min-height: 90px;
  margin-top: 20px;
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 13px;
  background: rgba(255, 255, 255, .6);
}

/* 历史记录 */
.history {
  margin-top: 24px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.history h2 { font-size: 16px; }
.history small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.btn-ghost {
  border: 1px solid #e2e8f0;
  background: #fff;
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 14px;
  cursor: pointer;
  font-size: 13px;
  min-height: 32px;
}
#historyList { list-style: none; }
#historyList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 2px;
  border-top: 1px solid #f1f5f9;
  font-size: 13px;
  color: var(--muted);
}
#historyList li:first-child { border-top: 0; }
#historyList b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }

/* 页脚 */
.tips {
  color: #8a94a6;
  font-size: 12.5px;
  line-height: 1.8;
  margin-top: 28px;
  text-align: center;
}
.tips p { margin-top: 6px; }
.tips a { color: var(--muted); }

/* 查询类工具：输入框 / 类型选择 / 快捷 chips */
.input-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 6px 0 14px;
}
.input-row input[type="text"] {
  flex: 1;
  min-width: 220px;
  max-width: 420px;
  border: 1.5px solid #dbe4f0;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 15px;
  outline: none;
  min-height: 46px;
}
.input-row input[type="text"]:focus { border-color: var(--accent); }
.type-select {
  border: 1.5px solid #dbe4f0;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  min-height: 46px;
}
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  border: 1px solid #dbe4f0;
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  cursor: pointer;
  min-height: 32px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

/* PC 端（≥600px）：结果一行四个 */
@media (min-width: 600px) {
  .results { grid-template-columns: repeat(4, 1fr); }
  .stat { flex-direction: column; align-items: flex-start; gap: 6px; padding: 18px 16px; }
  .page { padding-left: 24px; padding-right: 24px; }
}

/* ========== 公共导航（全站互链） ========== */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.site-nav .brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  white-space: nowrap;
}
.nav-links { display: flex; flex-wrap: wrap; gap: 2px; }
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  padding: 7px 12px;
  border-radius: 8px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.nav-links a:hover { background: #f1f5f9; color: var(--accent); }
.nav-links a.active { background: #eef4ff; color: var(--accent); font-weight: 600; }

/* ========== 内页（文章/工具页）排版 ========== */
.tool-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 16px;
  margin-top: 16px;
  text-align: center;
}
.article {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 18px;
  margin-top: 16px;
  font-size: 15px;
  line-height: 1.9;
}
.article h1 { font-size: clamp(22px, 5vw, 30px); line-height: 1.4; margin-bottom: 6px; }
.article h2 { font-size: 19px; margin: 26px 0 10px; }
.article h3 { font-size: 16px; margin: 20px 0 8px; }
.article p { margin: 10px 0; color: #334155; }
.article ul, .article ol { padding-left: 22px; margin: 10px 0; color: #334155; }
.article li { margin: 6px 0; }
.article a { color: var(--accent); }
.article .lead { color: var(--muted); font-size: 13.5px; }
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}
.article th, .article td {
  border: 1px solid #e2e8f0;
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
}
.article th { background: #f8fafc; font-weight: 600; }
.article code {
  background: #f1f5f9;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 13.5px;
  font-family: Consolas, "Courier New", monospace;
}
.article .cta {
  margin-top: 22px;
  padding: 16px;
  background: linear-gradient(135deg, #eef6ff, #f5f0ff);
  border-radius: 12px;
  text-align: center;
}

/* Ping 测试结果表 */
.ping-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 4px;
  font-size: 14px;
}
.ping-table th, .ping-table td {
  padding: 11px 8px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  white-space: nowrap;
}
.ping-table th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.ping-table .p-name { font-weight: 600; }
.ping-table .p-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.grade-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.grade-tag.g1 { background: #dcfce7; color: #15803d; }
.grade-tag.g2 { background: #e0f2fe; color: #0369a1; }
.grade-tag.g3 { background: #fef9c3; color: #a16207; }
.grade-tag.g4 { background: #fee2e2; color: #b91c1c; }
.ping-note { color: var(--muted); font-size: 12.5px; text-align: left; }

/* IP 查询页 */
.ip-big {
  font-size: clamp(24px, 6vw, 40px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  word-break: break-all;
}
.ip-rows { max-width: 420px; margin: 14px auto 0; text-align: left; }
.ip-rows div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  border-top: 1px solid #f1f5f9;
  font-size: 14px;
}
.ip-rows span:first-child { color: var(--muted); flex: none; }
.ip-rows span:last-child { text-align: right; word-break: break-all; }

/* 相关工具/页脚链接区 */
.related {
  margin-top: 20px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}
.related h2 { font-size: 16px; margin-bottom: 10px; }
.related ul { list-style: none; display: grid; gap: 6px; }
.related li a {
  color: #334155;
  text-decoration: none;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 8px;
  min-height: 40px;
  align-items: center;
}
.related li a:hover { background: #f1f5f9; }
.related li a span:last-child { color: #cbd5e1; }
@media (min-width: 600px) {
  .tool-card, .article { padding: 28px 26px; }
}
