:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #75839c;
  background: #fff;
  font-synthesis: none;
  --blue: #2f67ef;
  --ink: #131b29;
  --muted: #8a97ae;
  --line: #e7ebf2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #fff;
}

button, select { font: inherit; }

.page {
  min-height: 100vh;
  padding: 34px 24px 30px;
}

.speed-card {
  width: min(820px, 100%);
  min-height: calc(100vh - 64px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-wrap {
  position: relative;
  width: min(420px, 92vw);
  height: 370px;
  margin-top: 18px;
}

.gauge-wrap svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gauge-arc,
.gauge-progress {
  fill: none;
  stroke-linecap: round;
}

.gauge-arc {
  stroke: #edf0f5;
  stroke-width: 8;
}

.gauge-progress {
  stroke: var(--blue);
  stroke-width: 9;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset .24s ease;
}

.gauge-tick {
  stroke: #dce3ee;
  stroke-width: 1;
}

.gauge-tick.major {
  stroke: #ccd6e5;
  stroke-width: 1.8;
}

.gauge-label {
  fill: #8794ac;
  font-size: 11px;
  text-anchor: middle;
  dominant-baseline: middle;
}

.gauge-center {
  position: absolute;
  top: 128px;
  left: 50%;
  width: 250px;
  transform: translateX(-50%);
  text-align: center;
}

.phase-label {
  color: #6e7b94;
  font-size: 14px;
}

.speed-value {
  height: 87px;
  margin-top: 5px;
  color: var(--ink);
  font-size: 82px;
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -4px;
  white-space: nowrap;
}

.speed-unit {
  color: #72809a;
  font-size: 16px;
}

.status-message {
  min-height: 20px;
  margin-top: 13px;
  color: var(--blue);
  font-size: 12px;
  text-align: center;
}

.status-message.error { color: #d45261; }

.status-indicator {
  display: block;
  width: 20px;
  height: 2px;
  margin: 6px auto 0;
  border-radius: 2px;
  background: #cdd6e5;
}

.status-indicator.running {
  background: var(--blue);
  animation: status-pulse 1s ease-in-out infinite alternate;
}

@keyframes status-pulse {
  from { width: 20px; opacity: .55; }
  to { width: 42px; opacity: 1; }
}

.primary-btn {
  width: 220px;
  height: 56px;
  margin-top: 3px;
  border: 2px solid transparent;
  border-radius: 30px;
  color: #fff;
  background: var(--blue);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: color .18s, background .18s, border-color .18s, box-shadow .18s;
}

.primary-btn:hover {
  background: #255adb;
}

.primary-btn.testing {
  color: #40506a;
  border-color: #9fbdff;
  background: #fff;
  box-shadow: 0 0 0 6px #eef4ff inset, 0 0 0 2px #bad0ff;
}

.network-meta {
  margin-top: 17px;
  color: #687892;
  text-align: center;
  font-size: 12px;
  line-height: 1.9;
}

.network-meta p { margin: 0; }

.node-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 21px;
  color: #8d99ad;
}

.node-icon {
  margin-right: 5px;
  font-size: 17px;
  line-height: 1;
}

.node-select-wrap::after {
  content: "⌄";
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-58%);
  color: #8d99ad;
  pointer-events: none;
}

.node-select {
  max-width: 245px;
  height: 34px;
  padding: 0 24px 0 4px;
  border: 0;
  outline: none;
  color: #8d99ad;
  background: transparent;
  font-size: 13px;
  appearance: none;
  cursor: pointer;
}

.node-select:focus { color: #586982; }

.results {
  width: min(720px, 100%);
  margin-top: 39px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.result-item {
  min-width: 0;
  padding: 0 18px 2px;
  text-align: left;
}

.result-item + .result-item {
  border-left: 1px solid var(--line);
}

.result-label {
  color: #8794aa;
  font-size: 13px;
}

.result-label span {
  display: inline-block;
  min-width: 18px;
  color: #91a0b7;
  text-align: center;
}

.result-item.download .result-label,
.result-item.download .result-label span {
  color: var(--blue);
}

.result-number {
  margin-top: 14px;
  color: #111827;
  font-size: 29px;
  font-weight: 400;
  white-space: nowrap;
}

.result-number small {
  margin-left: 4px;
  color: #8c99ad;
  font-size: 10px;
  font-weight: 400;
}

.history-panel {
  width: min(820px, 100%);
  margin-top: 42px;
  border-top: 1px solid var(--line);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 5px 12px;
  color: #526179;
  font-size: 14px;
  font-weight: 600;
}

.history-header button {
  padding: 5px 10px;
  border: 1px solid #dce3ee;
  border-radius: 14px;
  color: #7d8aa0;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
}

.history-header button:hover {
  color: var(--blue);
  border-color: #aac1fa;
}

.history-list {
  width: 100%;
  overflow-x: auto;
}

.history-list table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  color: #5e6d84;
  font-size: 12px;
}

.history-list th,
.history-list td {
  padding: 10px 8px;
  border-bottom: 1px solid #eef1f5;
  text-align: center;
  white-space: nowrap;
}

.history-list th {
  color: #97a2b4;
  font-weight: 500;
}

.history-list th:first-child,
.history-list td:first-child {
  width: 155px;
  text-align: left;
}

.history-list th:nth-child(2),
.history-list td:nth-child(2) {
  width: 185px;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
}

.history-empty {
  padding: 22px 0 28px;
  color: #a1abba;
  font-size: 13px;
  text-align: center;
}

.debug-panel {
  width: min(820px, 100%);
  margin-top: 28px;
  overflow: hidden;
  border: 1px solid #d7dfeb;
  border-radius: 10px;
  background: #152033;
  box-shadow: 0 8px 24px rgba(24, 40, 67, .08);
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  color: #dce9f8;
  border-bottom: 1px solid #2b3b52;
  font-size: 12px;
  font-weight: 600;
}

.debug-header button {
  padding: 2px 9px;
  border: 1px solid #52647d;
  border-radius: 5px;
  color: #bed0e8;
  background: transparent;
  cursor: pointer;
}

.debug-log {
  height: 150px;
  padding: 7px 0;
  overflow: auto;
  color: #cbd8ea;
  font: 12px/1.7 Consolas, "Cascadia Mono", monospace;
}

.debug-line {
  display: grid;
  grid-template-columns: 70px 78px minmax(0, 1fr);
  gap: 8px;
  padding: 2px 12px;
}

.debug-line:hover { background: rgba(255, 255, 255, .045); }
.debug-time { color: #788ba7; }
.debug-type { color: #51c7ef; font-weight: 700; }
.debug-line code { color: #d8e5f4; overflow-wrap: anywhere; white-space: normal; }

@media (max-height: 760px) and (min-width: 641px) {
  .page { padding-top: 14px; }
  .gauge-wrap { width: 380px; height: 335px; margin-top: 0; }
  .gauge-center { top: 114px; }
  .speed-value { height: 77px; font-size: 72px; }
  .primary-btn { margin-top: -5px; }
  .node-select-wrap { margin-top: 12px; }
  .results { margin-top: 24px; }
}

@media (max-width: 640px) {
  .page { padding: 16px 15px 24px; }
  .speed-card { min-height: calc(100vh - 40px); }
  .gauge-wrap { width: min(370px, 96vw); height: 326px; margin-top: 4px; }
  .gauge-center { top: 111px; }
  .speed-value { height: 74px; font-size: 66px; }
  .primary-btn { width: 204px; height: 52px; margin-top: 0; }
  .network-meta { margin-top: 14px; }
  .node-select-wrap { margin-top: 14px; }
  .results { margin-top: 28px; grid-template-columns: repeat(2, 1fr); row-gap: 25px; }
  .result-item:nth-child(3) { border-left: 0; }
  .result-number { margin-top: 9px; font-size: 25px; }
  .history-panel { margin-top: 32px; }
  .history-list table { min-width: 720px; }
  .debug-line { grid-template-columns: 58px 68px minmax(0, 1fr); gap: 5px; padding-inline: 8px; }
}

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