:root {
  color-scheme: light;
  --bg: #f2f6f8;
  --surface: #ffffff;
  --surface-soft: #e8eef2;
  --text: #132027;
  --muted: #63737f;
  --line: #d6e0e6;
  --accent: #00a884;
  --accent-strong: #0077b6;
  --warning: #ffb703;
  --shadow: 0 24px 70px rgba(19, 32, 39, 0.14);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1418;
  --surface: #172128;
  --surface-soft: #21303a;
  --text: #edf7fb;
  --muted: #a5b7c2;
  --line: #2d414d;
  --accent: #23d3a5;
  --accent-strong: #5bbcff;
  --warning: #ffd166;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 18%, transparent), transparent 32rem),
    linear-gradient(135deg, var(--bg), color-mix(in srgb, var(--bg) 82%, var(--accent-strong)));
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 42px;
}

.topbar,
.hero,
.results {
  width: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.theme-toggle input {
  position: absolute;
  opacity: 0;
}

.toggle-track {
  position: relative;
  width: 58px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--line) 60%, transparent);
}

.toggle-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--warning), var(--accent));
  transition: transform 180ms ease;
}

.theme-toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(26px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: 42px;
  align-items: center;
}

.hero-copy {
  max-width: 660px;
}

.eyebrow {
  margin: 0 0 16px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.8rem, 8vw, 5.8rem);
  line-height: 0.92;
}

.hero-copy p:last-child {
  max-width: 560px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.7;
}

.speed-panel {
  display: grid;
  gap: 22px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.meter {
  display: grid;
  gap: 6px;
  min-height: 250px;
}

.meter svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.meter-track,
.meter-progress {
  fill: none;
  stroke-linecap: round;
  stroke-width: 18;
}

.meter-track {
  stroke: var(--surface-soft);
}

.meter-progress {
  stroke: var(--accent);
  stroke-dasharray: 251;
  stroke-dashoffset: 251;
  transition: stroke-dashoffset 240ms ease;
}

.needle {
  stroke: var(--text);
  stroke-linecap: round;
  stroke-width: 4;
  transition:
    x2 240ms ease,
    y2 240ms ease;
}

.needle-hub {
  fill: var(--accent);
}

.meter-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.meter-value span {
  font-size: clamp(2.7rem, 10vw, 4.8rem);
  font-weight: 850;
  line-height: 1;
}

.meter-value small,
.client-ip,
.result-card small,
.status {
  color: var(--muted);
}

.client-ip {
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
}

.client-ip strong {
  color: var(--text);
  font-weight: 800;
}

.start-button {
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 16px 32px color-mix(in srgb, var(--accent) 24%, transparent);
}

.start-button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.status {
  min-height: 1.5em;
  margin: 0;
  text-align: center;
}

.results {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 34px;
}

.result-card {
  min-height: 142px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

.result-card span,
.result-card small {
  display: block;
}

.result-card span {
  color: var(--muted);
  font-weight: 700;
}

.result-card strong {
  display: block;
  margin: 14px 0 2px;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 24px, 680px);
    padding-top: 20px;
  }

  .topbar {
    margin-bottom: 34px;
  }

  .theme-label {
    display: none;
  }

  .hero,
  .results {
    grid-template-columns: 1fr;
  }

  .hero {
    gap: 30px;
  }

  .speed-panel {
    padding: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
