/* ================================
   网速测试工具 - 自定义样式
   配色与 Leowh 主页统一
   ================================ */

:root {
  --bg: #FAFAF9;
  --bg-alt: #F5F5F4;
  --surface: #FFFFFF;
  --border: #E7E5E4;
  --border-strong: #D6D3D1;
  --text: #1E293B;
  --text-secondary: #52525B;
  --text-muted: #71717A;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: rgba(79, 70, 229, 0.08);
  --secondary: #F97316;
  --accent: #EC4899;
  --success: #059669;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Toast ── */
.toast {
  position: fixed; top: 24px; right: 24px;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 100px;
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  z-index: 1000;
  transform: translateX(calc(100% + 40px));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.toast.show { transform: translateX(0); }
.toast-dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; }

/* ── Page ── */
.page { max-width: 960px; margin: 0 auto; padding: 0 32px; }

/* ── Header scroll effect ── */
#header.scrolled {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 20px rgba(0,0,0,0.06);
}

/* ══════════════════════════════════════════
   Speed Test Section
   ══════════════════════════════════════════ */
.speed-section { padding: 32px 0 24px; display: flex; flex-direction: column; align-items: center; }

/* ── Gauge Card ── */
.gauge-card {
  width: 100%; max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px 24px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center;
  gap: 20px;
}

.gauge-ring {
  position: relative;
  width: 180px; height: 180px;
}

.gauge-svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.gauge-bg {
  fill: none; stroke: var(--bg-alt);
  stroke-width: 10;
}
.gauge-fill {
  fill: none; stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 565.49; /* 2*PI*90 = 565.49 */
  stroke-dashoffset: 565.49;
  transition: stroke-dashoffset 0.4s ease, stroke 0.4s ease;
}

.gauge-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center;
}
.gauge-speed {
  font-size: 36px; font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}
.gauge-unit {
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.gauge-status {
  display: flex; align-items: center; gap: 12px;
}
.status-badge {
  padding: 5px 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
}
.status-badge.testing {
  background: rgba(79,70,229,0.08);
  border-color: rgba(79,70,229,0.25);
  color: var(--primary);
}
.status-badge.fast {
  background: rgba(5,150,105,0.08);
  border-color: rgba(5,150,105,0.25);
  color: var(--success);
}
.status-badge.slow {
  background: rgba(249,115,22,0.08);
  border-color: rgba(249,115,22,0.25);
  color: var(--secondary);
}

.status-rating {
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
}

/* ── Progress Bar ── */
.progress-wrap {
  width: 100%; display: flex; align-items: center; gap: 12px;
}
.progress-bar {
  flex: 1; height: 6px;
  background: var(--bg-alt);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}
.progress-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; height: 100%;
  width: var(--progress);
  background: var(--primary);
  border-radius: 100px;
  transition: width 0.2s ease;
}
.progress-text {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  min-width: 36px; text-align: right;
}

/* ── Test Actions ── */
.test-actions {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-top: 24px;
}

.btn-start {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 36px;
  background: linear-gradient(135deg, #0D9488, #0891B2);
  border: none; border-radius: 100px;
  font-family: inherit; font-size: 16px; font-weight: 700;
  color: white; cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 16px rgba(13,148,136,0.3);
}
.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(13,148,136,0.4);
}
.btn-start:active { transform: translateY(0); }
.btn-start:disabled {
  opacity: 0.5; cursor: not-allowed;
  transform: none; box-shadow: 0 2px 8px rgba(13,148,136,0.2);
}

.test-hint {
  font-size: 12px; color: var(--text-muted);
}

/* ── Results Grid ── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%; max-width: 700px;
  margin-top: 28px;
}

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.result-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.1);
}

.result-card-label {
  display: block;
  font-size: 10px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.result-card-value {
  display: block;
  font-size: 22px; font-weight: 700;
  color: var(--text);
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}
.result-card-sub {
  display: block;
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}

/* ── Details Box ── */
.details-box {
  width: 100%; max-width: 700px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.details-title {
  font-size: 13px; font-weight: 700;
  color: var(--text);
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}
.details-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.details-item:last-child { border-bottom: none; }
.details-item span:first-child {
  color: var(--text-muted);
  font-weight: 500;
}
.details-item span:last-child {
  color: var(--text);
  font-weight: 600;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}

/* ── History Section ── */
.history-section {
  width: 100%; max-width: 700px;
  margin-top: 28px;
}
.history-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.history-title {
  font-size: 15px; font-weight: 700;
  color: var(--text);
}

.btn-clear-history {
  padding: 6px 14px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 100px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  transition: all 0.15s ease;
}
.btn-clear-history:hover { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.2); color: #EF4444; }

.history-list {
  display: flex; flex-direction: column; gap: 8px;
}
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}
.history-item:hover { border-color: var(--primary); }
.history-time { color: var(--text-muted); font-size: 12px; }
.history-speed { font-weight: 700; color: var(--text); font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace; }
.history-rating { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 100px; }
.history-rating.fast { background: rgba(5,150,105,0.1); color: var(--success); }
.history-rating.medium { background: rgba(249,115,22,0.1); color: var(--secondary); }
.history-rating.slow { background: rgba(239,68,68,0.1); color: #EF4444; }

/* ══════════════════════════════════════════
   Custom scrollbar
   ══════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #A5B4FC; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4F46E5; }

::selection { background: rgba(79, 70, 229, 0.2); color: #1E293B; }

/* ══════════════════════════════════════════
   Guide Section (accordion)
   ══════════════════════════════════════════ */
.guide-section {
  margin-top: 32px;
  margin-bottom: 64px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.guide-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.guide-toggle:hover {
  background: var(--bg-alt);
}
.guide-toggle-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
}
.guide-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}
.toggle-arrow {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}
.guide-list {
  padding: 0 20px 20px;
}
.guide-list.hidden {
  display: none;
}
.guide-item {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.guide-item:first-child {
  border-top: 1px solid var(--border);
}
.guide-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
  margin-bottom: 6px;
}
.guide-item-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}

/* ══════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .page { padding: 0 16px; }

  .gauge-card { padding: 24px 16px 20px; }
  .gauge-ring { width: 140px; height: 140px; }
  .gauge-speed { font-size: 28px; }

  .results-grid { grid-template-columns: repeat(2, 1fr); }

  .details-box { max-width: 100%; }
  .history-section { max-width: 100%; }
}
