/* Speed test page (templates/speedtest*.tpl, js/speedtest_page.js). The dial speaks the same language as the
   onboarding wizard's speedometer (css/onboarding.css .rt-onb-dial: 3/4 ring, log scale to 1000 Mb/s, accent arc)
   without sharing its classes. Tokens from DESIGN.md. */

.rt-st {
  --st-ink: #101828;
  --st-ink-2: #475467;
  --st-ink-3: #5D6B82;
  --st-line: #E4E7EC;
  --st-soft: #F5F7FB;
  --st-link: #1F5FBF;
  --st-accent: #2D6FE3;
  --st-blue-50: #F1F5FF;
  --st-action: #2E7D32;
  --st-action-hover: #246428;
  --st-action-tint: #E7F4E8;
  --st-danger: #B42318;
  --st-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --st-shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.08);

  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(24px, 3vw, 40px);
  align-items: start;
  padding-top: clamp(32px, 5vw, 64px);
  padding-bottom: clamp(64px, 8vw, 104px);
  color: var(--st-ink);
}
.rt-st *, .rt-st *::before, .rt-st *::after { box-sizing: border-box; }
.rt-st__sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- meter card ---------- */
.rt-st__meter {
  display: flex; flex-direction: column; align-items: center;
  padding: clamp(24px, 4vw, 40px) clamp(16px, 3vw, 32px);
  background: #fff; border-radius: 20px; box-shadow: var(--st-shadow);
  text-align: center;
}
.rt-st__gauge { position: relative; width: min(100%, 300px); aspect-ratio: 1; }
svg.rt-st-dial { display: block; width: 100%; height: 100%; overflow: visible; }
.rt-st-dial circle { fill: none; }
.rt-st-dial__track { stroke: #E3E8F0; stroke-width: 12; stroke-linecap: round; }
.rt-st-dial__value { stroke: var(--st-accent); stroke-width: 12; stroke-linecap: round; transition: stroke 0.4s ease; }
.rt-st[data-stage="ul"] .rt-st-dial__value { stroke: #18335E; }
.rt-st[data-state="done"] .rt-st-dial__value { stroke: var(--st-action); }
.rt-st-dial.is-empty .rt-st-dial__value { stroke-opacity: 0; }
.rt-st-dial__scale line { stroke: #AEB7C5; stroke-width: 1.5; stroke-linecap: round; }
.rt-st-dial__scale line.is-major { stroke: var(--st-ink-3); stroke-width: 2; }
.rt-st-dial__scale text { fill: var(--st-ink-3); font-family: inherit; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

.rt-st__readout {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-top: 8px; pointer-events: none;
}
.rt-st__stage { font-size: 14px; font-weight: 700; color: var(--st-ink-3); letter-spacing: 0; }
.rt-st[data-state="running"] .rt-st__stage { color: var(--st-accent); }
.rt-st__num {
  font-size: clamp(44px, 9vw, 60px); font-weight: 800; line-height: 1.05; letter-spacing: -0.04em;
  color: var(--st-ink); font-variant-numeric: tabular-nums;
}
.rt-st__unit { font-size: 15px; font-weight: 700; color: var(--st-ink-3); }

#contentWrapper .rt-st button.rt-st__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 220px; min-height: 52px; margin: 12px 0 0; padding: 0 26px;
  border: 1.5px solid var(--st-action); border-radius: 999px !important;
  background: var(--st-action); color: #fff;
  font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 6px 16px rgba(46, 125, 50, 0.22);
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s var(--st-ease);
}
#contentWrapper .rt-st button.rt-st__btn:hover { background: var(--st-action-hover); border-color: var(--st-action-hover); transform: translateY(-1px); }
#contentWrapper .rt-st button.rt-st__btn:focus-visible { outline: 3px solid var(--st-accent); outline-offset: 2px; }
#contentWrapper .rt-st[data-state="running"] button.rt-st__btn {
  background: #fff; color: var(--st-ink); border-color: var(--st-ink); box-shadow: none;
}
#contentWrapper .rt-st[data-state="running"] button.rt-st__btn:hover { background: var(--st-ink); color: #fff; }
.rt-st__btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.rt-st__status { min-height: 3em; max-width: 44ch; margin: 16px auto 0 !important; color: var(--st-ink-2) !important; font-size: 15px; line-height: 1.5; }
.rt-st[data-state="error"] .rt-st__status { color: var(--st-danger) !important; font-weight: 600; }

.rt-st__nums {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%; margin: 20px 0 0; padding: 18px 0 0;
  border-top: 1px solid var(--st-line);
}
.rt-st__nums > div { padding: 0 8px; }
.rt-st__nums > div + div { border-left: 1px solid var(--st-line); }
.rt-st__nums dt { font-size: 14px; font-weight: 600; color: var(--st-ink-3); }
.rt-st__nums dd { margin: 4px 0 0; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; color: var(--st-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rt-st__nums small { font-size: 13px; font-weight: 700; letter-spacing: 0; color: var(--st-ink-3); }

/* ---------- plans ---------- */
.rt-st__plans { padding-top: 8px; }
#contentWrapper .rt-st h2.rt-st__h { margin: 0 0 8px; color: var(--st-ink); font-size: clamp(24px, 2.4vw, 30px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.15; }
.rt-st__lead { margin: 0 0 20px !important; max-width: 52ch; color: var(--st-ink-2) !important; font-size: 16px; }
.rt-st[data-state="done"] .rt-st__lead { color: var(--st-ink) !important; font-weight: 600; }

.rt-st-plans { list-style: none; margin: 0; padding: 0; border: 1px solid var(--st-line); border-radius: 20px; background: #fff; overflow: hidden; }
.rt-st-plan {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px 20px;
  margin: 0; padding: 18px 20px;
  transition: background-color 0.3s ease;
}
.rt-st-plan::before { content: none !important; }
.rt-st-plan + .rt-st-plan { border-top: 1px solid var(--st-line); }
.rt-st-plan__info { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; }
.rt-st-plan__name { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; color: var(--st-ink); }
.rt-st-plan__speed { flex-basis: 100%; font-size: 14px; color: var(--st-ink-2); }
.rt-st-plan__chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px;
  background: var(--st-accent); color: #fff; font-size: 12.5px; font-weight: 700;
}
.rt-st-plan__chip[hidden] { display: none; }
.rt-st-plan__price { font-size: 14px; color: var(--st-ink-2); white-space: nowrap; }
.rt-st-plan__price b { font-size: 18px; font-weight: 800; color: var(--st-ink); font-variant-numeric: tabular-nums; }
.rt-st-plan__go {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border: 1.5px solid var(--st-ink); border-radius: 999px; color: var(--st-ink) !important;
  font-size: 15px; font-weight: 700; white-space: nowrap; text-decoration: none !important;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.rt-st-plan__go:hover { background: var(--st-ink); color: #fff !important; }
.rt-st-plan__go:focus-visible { outline: 3px solid var(--st-accent); outline-offset: 2px; }
.rt-st-plan.is-rec { background: var(--st-blue-50); }
.rt-st-plan.is-rec .rt-st-plan__go { background: var(--st-action); border-color: var(--st-action); color: #fff !important; }
.rt-st-plan.is-rec .rt-st-plan__go:hover { background: var(--st-action-hover); border-color: var(--st-action-hover); }

.rt-st__fine { margin: 16px 0 0 !important; color: var(--st-ink-3) !important; font-size: 14px; line-height: 1.5; }
.rt-st__fine a, .rt-st__lead a { color: var(--st-link); font-weight: 600; text-underline-offset: 3px; }

@media (max-width: 900px) {
  .rt-st { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .rt-st__nums { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 14px; }
  .rt-st__nums > div:nth-child(3) { border-left: 0; }
  .rt-st-plan { grid-template-columns: minmax(0, 1fr) auto; padding: 16px; }
  .rt-st-plan__go { grid-column: 1 / -1; width: 100%; }
  #contentWrapper .rt-st button.rt-st__btn { width: 100%; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .rt-st-dial__value, .rt-st-plan, #contentWrapper .rt-st button.rt-st__btn { transition: none; }
  #contentWrapper .rt-st button.rt-st__btn:hover { transform: none; }
}
