/* ============================================================
   NetPing 网络工具箱 - 深色科技风
   ============================================================ */
:root {
  --bg: #0b1020;
  --bg-2: #111731;
  --card: #151c3d;
  --card-2: #1b2447;
  --line: #25305c;
  --line-soft: #1e2849;
  --text: #e8ecff;
  --text-dim: #9aa3c7;
  --accent: #38e1ff;
  --accent-2: #7c6bff;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(124, 107, 255, 0.14), transparent 60%),
    radial-gradient(900px 500px at 10% -10%, rgba(56, 225, 255, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* ============ Header ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}

.logo-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #071020;
  box-shadow: 0 0 22px rgba(56, 225, 255, 0.45);
}

.logo-icon svg { width: 22px; height: 22px; }

.logo-text {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.logo-text em {
  font-style: normal;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  display: block;
  letter-spacing: 2px;
  margin-top: -2px;
}

.main-nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13.5px;
  font-family: inherit;
  padding: 8px 13px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s;
}

/* 独立栏目页导航使用 <a> 链接，样式与按钮一致 */
a.nav-btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.nav-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.nav-btn.active {
  color: #061018;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 700;
}

/* ============ Main ============ */
.site-main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 20px 60px;
}

.tool-panel { display: none; animation: fadeIn 0.3s ease; }
.tool-panel.active { display: block; }

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

.panel-head { margin-bottom: 26px; }

.panel-head h1 {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(90deg, #fff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.panel-head p { color: var(--text-dim); font-size: 14px; }

/* ============ Forms ============ */
.tool-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.tool-form input[type="text"],
.tool-form input[type="number"],
.batch-board textarea {
  flex: 1;
  min-width: 220px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 11px 14px;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.tool-form input:focus,
.batch-board textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 225, 255, 0.15);
}

.tool-form input::placeholder,
.batch-board textarea::placeholder { color: #5a6387; }

.tool-form select,
.batch-controls select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}

.tool-form .w-port { flex: 0 0 90px; min-width: 0; }
.tool-form .w-custom { flex: 0 1 300px; min-width: 0; }

.btn-primary,
.btn-ghost {
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 11px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #061018;
  box-shadow: 0 4px 18px rgba(56, 225, 255, 0.3);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(56, 225, 255, 0.45); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
}

.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ Result ============ */
.result-box { min-height: 60px; }

.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.result-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

.result-card .card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14px;
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.badge-green { background: rgba(52, 211, 153, 0.16); color: var(--green); }
.badge-red { background: rgba(248, 113, 113, 0.16); color: var(--red); }
.badge-yellow { background: rgba(251, 191, 36, 0.16); color: var(--yellow); }
.badge-blue { background: rgba(56, 225, 255, 0.14); color: var(--accent); }
.badge-gray { background: rgba(154, 163, 199, 0.14); color: var(--text-dim); }

.result-card .card-body { padding: 16px 18px; }

/* 关键指标卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 12px 14px;
}

.stat .stat-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.stat .stat-value { font-size: 20px; font-weight: 800; }
.stat .stat-value small { font-size: 12px; font-weight: 500; color: var(--text-dim); }
.stat .stat-value.ok { color: var(--green); }
.stat .stat-value.warn { color: var(--yellow); }
.stat .stat-value.bad { color: var(--red); }

/* 表格 */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.data-table th {
  text-align: left;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  word-break: break-all;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* 条形图（延迟对比） */
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.bar-row .bar-label { width: 56px; font-size: 12.5px; color: var(--text-dim); flex-shrink: 0; }
.bar-row .bar-track { flex: 1; height: 14px; background: var(--bg-2); border-radius: 7px; overflow: hidden; }
.bar-row .bar-track .bar { height: 100%; border-radius: 7px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.6s ease; }
.bar-row .bar-val { width: 90px; text-align: right; font-size: 12.5px; font-weight: 700; flex-shrink: 0; }

/* 逐次 ping 结果 */
.ping-seq { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.ping-dot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  min-width: 64px;
}

.ping-dot .seq { font-size: 11px; color: var(--text-dim); }
.ping-dot .ms { font-size: 15px; font-weight: 800; }
.ping-dot.lost .ms { color: var(--red); }

/* DNS 记录 */
.dns-group { margin-bottom: 14px; }
.dns-group .group-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.key-value { display: flex; gap: 8px; padding: 4px 0; font-size: 13.5px; flex-wrap: wrap; }
.key-value .kv-key { color: var(--text-dim); flex-shrink: 0; min-width: 110px; }
.key-value .kv-val { word-break: break-all; font-weight: 500; }

/* Whois raw */
.raw-box {
  background: #0a0f1e;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.7;
  color: #9fb4e8;
  max-height: 380px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 端口扫描结果 */
.port-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.port-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  background: var(--card-2);
  border: 1px solid var(--line-soft);
}

.port-item .port-num { font-weight: 800; }
.port-item .port-svc { font-size: 11px; color: var(--text-dim); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-open { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-closed { background: #3a4470; }

/* ============ 网络测速 ============ */
.speed-board {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.speed-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.speed-meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

.meter { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 10px; padding: 16px; }

.meter-label { font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; }
.meter-value { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; margin-bottom: 10px; }
.meter-value small { font-size: 13px; font-weight: 500; color: var(--text-dim); }

.meter-bar { height: 8px; background: var(--bg-2); border-radius: 4px; overflow: hidden; }
.meter-bar .bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

.speed-log {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--text-dim);
  min-height: 18px;
}

/* ============ 批量 ============ */
.batch-board {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.batch-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.batch-board textarea {
  width: 100%;
  resize: vertical;
  margin-bottom: 16px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

/* 批量结果行 */
.batch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}

.batch-row:last-child { border-bottom: none; }
.batch-row .target { flex: 1; font-weight: 600; word-break: break-all; }
.batch-row .meta { color: var(--text-dim); font-size: 12.5px; white-space: nowrap; }

/* ============ Footer ============ */
.site-footer {
  border-top: 1px solid var(--line-soft);
  background: rgba(11, 16, 32, 0.7);
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

.footer-inner a { color: var(--text-dim); text-decoration: none; }
.footer-inner a:hover { color: var(--accent); }

.footer-inner .sep { margin: 0 8px; color: #3a4470; }
.footer-meta { margin-top: 6px; font-size: 12px; color: #5a6387; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: var(--card-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 100;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); }

/* ============ 响应式 ============ */
@media (max-width: 720px) {
  .header-inner { height: auto; padding: 10px 14px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .main-nav { width: 100%; padding-bottom: 4px; }
  .site-main { padding: 24px 14px 40px; }
  .tool-form { flex-direction: column; }
  .tool-form input, .tool-form select, .tool-form .w-port, .tool-form .w-custom { width: 100%; flex: none; min-width: 0; }
  .panel-head h1 { font-size: 21px; }
}

/* ============ 宽带测速 ============ */
.bw-board {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
}

.bw-hero { text-align: center; }

.bw-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 22px;
  font-size: 13px;
  flex-wrap: wrap;
}

.bw-stage-item {
  color: var(--text-dim);
  padding: 6px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: all 0.2s;
  user-select: none;
}

.bw-stage-item.active {
  color: #061018;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  box-shadow: 0 0 16px rgba(56, 225, 255, 0.35);
}

.bw-stage-arrow { color: #3a4470; font-size: 15px; }

.bw-go {
  position: relative;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: #061018;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.35), transparent 45%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 40px rgba(56, 225, 255, 0.35), inset 0 -6px 18px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s, box-shadow 0.2s;
  display: grid;
  place-items: center;
  margin: 0 auto 22px;
}

.bw-go:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 14px 46px rgba(56, 225, 255, 0.5), inset 0 -6px 18px rgba(0, 0, 0, 0.18);
}

.bw-go:disabled { cursor: not-allowed; }

.bw-go.testing { animation: bwPulse 1.2s ease-in-out infinite; }

@keyframes bwPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.bw-go-text {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.bw-go-ring {
  position: absolute;
  inset: -10px;
  border: 2px solid rgba(56, 225, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.bw-go.testing .bw-go-ring { opacity: 1; animation: spin 1s linear infinite; }

.bw-current { margin-bottom: 6px; }

.bw-current-num {
  font-size: 56px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  background: linear-gradient(90deg, #fff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.bw-current-unit {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dim);
  margin-left: 6px;
}

.bw-current-label { font-size: 13px; color: var(--text-dim); margin-top: 6px; min-height: 18px; }

.bw-chart-wrap {
  background: #0a0f1e;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin: 20px 0 18px;
}

.bw-chart-wrap canvas { width: 100%; height: 180px; display: block; }

.bw-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.bw-controls label { font-size: 13px; color: var(--text-dim); }

.bw-controls select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}

.bw-results { margin-top: 20px; }

.bw-result-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.bw-history {
  margin-top: 22px;
  border-top: 1px dashed var(--line);
  padding-top: 18px;
}

.bw-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.bw-history-head h3 { font-size: 15px; font-weight: 800; }

.bw-history-note { margin-top: 10px; font-size: 12px; color: #5a6387; }

@media (max-width: 720px) {
  .bw-go { width: 158px; height: 158px; }
  .bw-current-num { font-size: 42px; }
  .bw-board { padding: 20px 14px 18px; }
}

/* ============ 友情链接 ============ */
.links-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-top: 26px;
}

.links-head { margin-bottom: 16px; }

.links-head h2 {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
}

.links-head p {
  font-size: 12px;
  color: var(--text-dim);
}

.links-head code {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--accent);
}

.links-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.links-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 14px;
  transition: all 0.18s;
}

.links-item::before {
  content: "🔗";
  font-size: 11px;
  opacity: 0.7;
}

.links-item:hover {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(56, 225, 255, 0.18);
  transform: translateY(-1px);
}

@media (max-width: 720px) {
  .links-panel { padding: 18px 14px; margin-top: 20px; }
  .links-item { font-size: 12px; padding: 6px 11px; }
}
