:root {
  --ink: #16231f;
  --muted: #66736e;
  --line: #dde5e1;
  --surface: rgba(255, 255, 255, 0.9);
  --page: #f4f7f6;
  --accent: #1d8b69;
  --accent-deep: #116a50;
  --lime: #c9ee59;
  --blue: #4b78ee;
  --shadow: 0 24px 70px rgba(25, 55, 45, 0.1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 92% 5%, rgba(201, 238, 89, 0.23), transparent 31%),
    radial-gradient(circle at -10% 52%, rgba(75, 120, 238, 0.08), transparent 26%),
    var(--page);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 540px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 20px max(22px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
}

.brand-mark {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  width: 24px;
  height: 24px;
  padding: 5px;
  border-radius: 8px;
  background: var(--ink);
}

.brand-mark i {
  display: block;
  width: 3px;
  border-radius: 3px;
  background: var(--lime);
}

.brand-mark i:nth-child(1) { height: 6px; }
.brand-mark i:nth-child(2) { height: 11px; }
.brand-mark i:nth-child(3) { height: 8px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(22, 35, 31, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(29, 139, 105, 0.12);
}

.status-pill.is-running .status-dot {
  animation: breathe 1s ease-in-out infinite;
}

.status-pill.is-error .status-dot {
  background: #d85454;
  box-shadow: 0 0 0 4px rgba(216, 84, 84, 0.12);
}

.hero {
  padding: 54px 6px 27px;
}

.eyebrow {
  margin: 0 0 13px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.2em;
}

h1 {
  margin: 0;
  font-size: clamp(38px, 11vw, 58px);
  line-height: 1.05;
  letter-spacing: -0.055em;
}

.intro {
  max-width: 390px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.test-card {
  position: relative;
  overflow: hidden;
  padding: 26px 20px 20px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.test-card::before {
  position: absolute;
  top: -58px;
  right: -55px;
  width: 150px;
  height: 150px;
  border: 26px solid rgba(201, 238, 89, 0.14);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.visitor-strip {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(247, 249, 248, 0.75);
}

.visitor-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.visitor-label i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(75, 120, 238, 0.1);
}

.visitor-strip strong {
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-result {
  padding: 0 4px 24px;
}

.metric-heading,
.metric-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric-heading b {
  color: var(--accent-deep);
  font-weight: 850;
}

.metric-icon {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 900;
}

.download-icon {
  background: rgba(29, 139, 105, 0.11);
  color: var(--accent-deep);
}

.speed-reading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 8px;
}

.speed-reading strong {
  min-width: 80px;
  font-size: clamp(58px, 17vw, 82px);
  font-variant-numeric: tabular-nums;
  font-weight: 780;
  line-height: 1;
  letter-spacing: -0.065em;
}

.speed-reading span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(247, 249, 248, 0.75);
}

.latency-icon,
.jitter-icon,
.loss-icon,
.time-icon {
  position: relative;
  width: 20px;
  height: 20px;
  border-radius: 0;
}

.loss-icon::before {
  width: 15px;
  height: 11px;
  border-bottom: 2px solid #d36a55;
  content: "";
  clip-path: polygon(0 60%, 24% 20%, 47% 72%, 72% 28%, 100% 82%, 100% 100%, 0 100%);
  background: rgba(211, 106, 85, 0.18);
}

.time-icon::before {
  width: 13px;
  height: 13px;
  border: 2px solid #c68a25;
  border-radius: 50%;
  content: "";
}

.time-icon::after {
  position: absolute;
  width: 1.5px;
  height: 5px;
  border-radius: 2px;
  background: #c68a25;
  content: "";
  transform: translate(2px, -2px) rotate(-42deg);
}

.latency-icon::before {
  width: 10px;
  height: 10px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  content: "";
}

.latency-icon::after {
  position: absolute;
  width: 2px;
  height: 7px;
  border-radius: 2px;
  background: var(--blue);
  content: "";
  transform: translate(3px, -3px) rotate(-42deg);
}

.jitter-icon::before {
  width: 17px;
  height: 7px;
  border-top: 2px solid #9a62d6;
  border-bottom: 2px solid #9a62d6;
  content: "";
  transform: skewY(-26deg);
}

.small-reading {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 12px;
}

.small-reading strong {
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  font-weight: 780;
  letter-spacing: -0.045em;
}

.small-reading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chart-panel {
  margin-top: 12px;
  padding: 17px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(247, 249, 248, 0.75);
}

.chart-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}

.chart-eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.chart-heading h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -0.02em;
}

.chart-heading > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.chart-wrap {
  width: 100%;
  height: 168px;
  margin-top: 12px;
}

#bandwidthChart {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  padding-left: 37px;
  color: #929c98;
  font-size: 8px;
}

.progress-panel {
  padding: 23px 4px 17px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.progress-track {
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eeec;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--lime));
  transition: width 120ms linear;
}

.sample-note {
  min-height: 18px;
  margin: 9px 0 0;
  color: #87918d;
  font-size: 11px;
}

.start-button {
  display: flex;
  width: 100%;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px 0 22px;
  border: 0;
  border-radius: 17px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.start-button:hover:not(:disabled) {
  background: #243a33;
  transform: translateY(-1px);
}

.start-button:active:not(:disabled) {
  transform: translateY(1px);
}

.start-button:focus-visible {
  outline: 3px solid rgba(29, 139, 105, 0.28);
  outline-offset: 3px;
}

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

.button-arrow {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--lime);
  color: var(--ink);
  font-size: 19px;
}

.start-button:disabled .button-arrow {
  animation: spin 1.2s linear infinite;
}

.error-message {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(216, 84, 84, 0.18);
  border-radius: 12px;
  background: rgba(216, 84, 84, 0.07);
  color: #a83c3c;
  font-size: 12px;
  line-height: 1.55;
}

footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 20px 0 0;
  color: #8a9591;
  font-size: 10px;
}

noscript {
  display: block;
  padding: 16px;
  text-align: center;
}

@keyframes breathe {
  50% { opacity: 0.45; transform: scale(0.8); }
}

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

@media (min-width: 700px) {
  .app-shell {
    padding-top: 34px;
    padding-bottom: 34px;
  }

  .hero {
    padding-top: 66px;
  }

  .test-card {
    padding: 30px 26px 24px;
  }
}

@media (max-width: 360px) {
  .app-shell { padding-inline: 14px; }
  .hero { padding-top: 42px; }
  .test-card { padding-inline: 15px; }
  .metric-card { padding: 13px; }
  .metric-label { font-size: 12px; }
}

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