:root{
  --bg: #0A0E13;
  --surface: #121821;
  --surface-2: #1A222D;
  --track: #232E3B;
  --border: #253141;
  --text: #EAF1F7;
  --text-muted: #7E8FA0;
  --text-faint: #4C5A6B;

  --accent-down: #33D6A8;
  --accent-down-soft: rgba(51,214,168,.14);
  --accent-up: #7C9CFF;
  --accent-up-soft: rgba(124,156,255,.14);
  --accent-ping: #FFB454;
  --accent-ping-soft: rgba(255,180,84,.14);
  --danger: #FF6B6B;

  --accent-current: var(--accent-down);
  --accent-current-soft: var(--accent-down-soft);

  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-body: 'Inter', sans-serif;

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;

  color-scheme: dark;
}

html[data-theme="light"]{
  --bg: #F1F5F8;
  --surface: #FFFFFF;
  --surface-2: #EAF0F5;
  --track: #DCE6EE;
  --border: #DCE4EC;
  --text: #10171F;
  --text-muted: #5B6B7A;
  --text-faint: #9AA8B4;

  --accent-down: #0FA680;
  --accent-down-soft: rgba(15,166,128,.12);
  --accent-up: #4C6FEF;
  --accent-up-soft: rgba(76,111,239,.12);
  --accent-ping: #DB7F14;
  --accent-ping-soft: rgba(219,127,20,.12);

  color-scheme: light;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background .35s ease, color .35s ease;
  overflow-x: hidden;
}

.update-notice{
  position: fixed;
  z-index: 10;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0,0,0,.24);
  font: 500 .82rem var(--font-body);
}

.update-notice[hidden]{ display:none; }
.update-notice button{
  appearance: none;
  border: 0;
  border-radius: 7px;
  padding: 7px 10px;
  background: var(--accent-down);
  color: #07110e;
  font: 700 .78rem var(--font-display);
  cursor: pointer;
}
.cute-footer {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.08);
    padding: 10px 18px;
    border-radius: 999px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.cute-footer p {
    margin: 0;
    color: teal;
    font-size: 0.82rem;
    font-weight: 800;
    text-align: center;
}
.noise-layer{
  position: fixed; inset:0; pointer-events:none; z-index:0;
  background-image: radial-gradient(circle at 20% 15%, var(--accent-current-soft), transparent 45%),
                     radial-gradient(circle at 85% 80%, var(--accent-up-soft), transparent 40%);
  opacity:.7;
  transition: background .5s ease;
}
.topbar{
  position: relative; z-index: 2;
  display:flex; align-items:center; justify-content:space-between;
  padding: 22px clamp(20px, 5vw, 56px);
}
.wordmark{
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .32em;
  display:flex; align-items:center; gap:10px;
}
.wordmark-dot{
  width:8px; height:8px; border-radius:50%;
  background: var(--accent-down);
  box-shadow: 0 0 12px var(--accent-down);
}
.theme-toggle{
  width:40px; height:40px; border-radius:50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  color: var(--text-muted);
  transition: background .25s ease, transform .15s ease, color .25s ease;
}
.theme-toggle:hover{ color: var(--text); transform: translateY(-1px); }
.theme-toggle:focus-visible{ outline: 2px solid var(--accent-down); outline-offset: 2px; }
.theme-toggle .icon{ width:18px; height:18px; }
.icon-moon{ display:none; }
html[data-theme="light"] .icon-sun{ display:none; }
html[data-theme="light"] .icon-moon{ display:block; }
.stage{
  position: relative; z-index:1;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 56px) 80px;
  display:flex; flex-direction:column; align-items:center;
  gap: 56px;
}
.gauge-section{
  display:flex; flex-direction:column; align-items:center;
  gap: 22px;
  padding-top: 8px;
  width:100%;
}
.gauge-wrap{
  position:relative;
  width: min(340px, 84vw);
  aspect-ratio: 1/1;
}
.gauge-svg{ width:100%; height:100%; overflow: visible; }

.tick-major{ stroke: var(--text-faint); stroke-width:2; }
.tick-minor{ stroke: var(--text-faint); stroke-width:1; opacity:.5; }
.tick-label{
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--text-muted);
  text-anchor: middle;
}
.track-arc{
  stroke: var(--track);
  stroke-width: 14;
  stroke-linecap: round;
}
.progress-arc{
  stroke: var(--accent-current);
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke .4s ease, stroke-dashoffset .5s cubic-bezier(.22,.9,.3,1);
}
.needle-group{ transition: transform .55s cubic-bezier(.22,.9,.3,1); transform-origin: 160px 160px; }
.needle-line{
  stroke: var(--text);
  stroke-width: 3;
  stroke-linecap: round;
  opacity: .85;
}
.needle-hub{ fill: var(--surface); stroke: var(--text-faint); stroke-width: 2; }

.sweep-group{ transition: opacity .3s ease; transform-origin: 160px 160px; }
.sweep-group.active{ animation: sweepRotate 1.6s linear infinite; opacity: 1; }
@keyframes sweepRotate{
  from{ transform: rotate(-135deg); }
  to{ transform: rotate(135deg); }
}

.gauge-readout{
  position:absolute; inset:0;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:8px;
  padding-top: 26px;
}
.readout-value{
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(38px, 9vw, 52px);
  line-height:1;
  display:flex; align-items:baseline; gap:6px;
  font-variant-numeric: tabular-nums;
}
.readout-unit{
  font-size: 14px; font-weight:500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em;
}
.readout-status{
  display:flex; align-items:center; gap:8px;
  font-size: 12.5px; color: var(--text-muted);
  letter-spacing: .02em;
}
.status-dot{
  width:6px; height:6px; border-radius:50%;
  background: var(--text-faint);
  transition: background .3s ease, box-shadow .3s ease;
}
.status-dot.live{
  background: var(--accent-current);
  box-shadow: 0 0 8px var(--accent-current);
  animation: pulseDot 1.1s ease-in-out infinite;
}
@keyframes pulseDot{
  0%,100%{ opacity:1; } 50%{ opacity:.35; }
}
.cta-btn{
  display:flex; align-items:center; gap:10px;
  padding: 14px 30px;
  background: var(--text);
  color: var(--bg);
  border:none; border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: .01em;
  cursor:pointer;
  transition: transform .18s ease, background .25s ease, opacity .2s ease;
}
.cta-btn:hover{ transform: translateY(-2px); }
.cta-btn:active{ transform: translateY(0); }
.cta-btn:focus-visible{ outline: 2px solid var(--accent-down); outline-offset: 3px; }
.cta-btn:disabled{ opacity:.55; cursor: progress; transform:none; }
.cta-icon{ width:16px; height:16px; }
.cta-btn.running .cta-icon{ animation: spin 1s linear infinite; }
@keyframes spin{ to{ transform: rotate(360deg); } }
.cta-hint{ margin:0; font-size:13px; color: var(--text-muted); text-align:center; }
.metrics{
  width:100%;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.metric-card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 18px 16px;
  display:flex; flex-direction:column; gap:12px;
  transition: border-color .3s ease, background .3s ease;
}
.metric-card[data-metric="download"]{ --card-accent: var(--accent-down); }
.metric-card[data-metric="upload"]{ --card-accent: var(--accent-up); }
.metric-card[data-metric="ping"]{ --card-accent: var(--accent-ping); }
.metric-card.active{ border-color: var(--card-accent); }

.metric-head{
  display:flex; align-items:center; gap:8px;
  font-size: 12.5px; font-weight:600;
  text-transform: uppercase; letter-spacing:.08em;
  color: var(--text-muted);
}
.metric-icon{ width:15px; height:15px; color: var(--card-accent); }
.metric-value{
  font-family: var(--font-mono);
  font-size: 26px; font-weight:600;
  display:flex; align-items:baseline; gap:5px;
  font-variant-numeric: tabular-nums;
}
.metric-value small{ font-size:12px; font-weight:500; color: var(--text-muted); }
.metric-sub{ font-family: var(--font-mono); font-size:12px; color: var(--text-muted); margin-top:-6px; }
.sparkline{ width:100%; height:28px; }
.sparkline path{ fill:none; stroke: var(--card-accent); stroke-width:1.6; }
.sparkline .fill{ stroke:none; fill: var(--card-accent); opacity:.12; }
.history{ width:100%; }
.history-head{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom: 14px;
}
.history-head h2{
  font-family: var(--font-display);
  font-size: 16px; margin:0; font-weight:600;
  letter-spacing:.01em;
}
.ghost-btn{
  background:none; border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-body); font-size: 12.5px; font-weight:600;
  padding: 7px 14px; border-radius: 999px; cursor:pointer;
  transition: all .2s ease;
}
.ghost-btn:hover{ color: var(--danger); border-color: var(--danger); }
.ghost-btn:focus-visible{ outline: 2px solid var(--accent-down); outline-offset:2px; }

.history-table-wrap{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  overflow-x: auto;
}
.history-table{ width:100%; border-collapse: collapse; min-width: 480px; }
.history-table th{
  text-align:left;
  font-size: 11px; font-weight:600; text-transform:uppercase; letter-spacing:.07em;
  color: var(--text-faint);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.history-table td{
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.history-table tr:last-child td{ border-bottom:none; }
.history-empty-row td{
  font-family: var(--font-body);
  color: var(--text-muted);
  white-space: normal;
}

.footnote{
  font-size: 12px; color: var(--text-faint);
  text-align:center; max-width: 480px; margin: 0 auto;
}

@media (max-width: 640px){
  .metrics{ grid-template-columns: 1fr; }
  .stage{ gap: 44px; }
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
