:root {
  color-scheme: light;
  --ink: #181a27;
  --muted: #8a8fae;
  --line: #e9eaf1;
  --surface: #ffffff;
  --soft: #f7f7fb;
  --purple: #7c5cff;
  --purple-dark: #632cff;
  --blue: #47b7f5;
  --blue-dark: #2d9cf0;
  --download-track: #d7cdff;
  --upload-track: #bee6ff;
  --download-result: #8667ff;
  --upload-result: #50beff;
  --shadow: 0 22px 60px rgba(75, 57, 176, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background-color: #642dfc;
  background-image: linear-gradient(
    to bottom,
    var(--surface) 0%,
    var(--surface) 50%,
    #642dfc 50%,
    #642dfc 100%
  );
  background-attachment: fixed;
  scroll-behavior: smooth;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  overflow-x: hidden;
  background-color: #642dfc;
  background-image: linear-gradient(
    to bottom,
    var(--surface) 0%,
    var(--surface) 50%,
    #642dfc 50%,
    #642dfc 100%
  );
  background-attachment: fixed;
  border-top: 3px solid #159ce8;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

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

button,
select {
  color: inherit;
}

a {
  color: inherit;
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 30000;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px 40px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(235, 236, 243, 0.75);
}

.navbar .brand {
  display: flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.navbar .brand svg {
  display: block;
  width: 144px;
  height: 36px;
}

.nav-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 42px;
}

.nav-center > a,
.product-menu-toggle {
  position: relative;
  padding: 10px 0;
  border: 0;
  background: none;
  color: #20212a;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.nav-center > a::after {
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--purple-dark), var(--blue));
  border-radius: 999px;
  content: "";
  opacity: 0;
  transform: scaleX(0.4);
  transition: opacity 180ms ease, transform 180ms ease;
}

.nav-center > a:hover::after {
  opacity: 1;
  transform: scaleX(1);
}

.product-menu {
  position: relative;
}

.product-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.product-menu-toggle svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms ease;
}

.product-menu:hover .product-menu-toggle svg,
.product-menu.open .product-menu-toggle svg {
  transform: rotate(180deg);
}

.product-menu-panel {
  position: fixed;
  z-index: 21;
  top: 81px;
  left: 50%;
  width: min(800px, calc(100vw - 32px));
  max-height: calc(100vh - 100px);
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #ffffff;
  border: 1px solid #eeeff1;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 200ms ease, visibility 200ms ease, transform 200ms ease;
}

.product-menu.open .product-menu-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.product-menu-panel::before {
  position: absolute;
  top: -24px;
  right: 0;
  left: 0;
  height: 24px;
  background: transparent;
  content: "";
  pointer-events: auto;
}

.product-menu-content {
  display: flex;
  flex-direction: column;
}

.product-menu-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 16px 4px;
  gap: 8px;
  border-bottom: 1px solid #e6e9ef;
}

.product-menu-group:last-child {
  border-bottom: 0;
}

.product-menu-group-title {
  grid-column: 1 / -1;
  margin-bottom: 8px;
  padding: 0 4px 14px;
  color: #6b7280;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: uppercase;
}

.product-menu-item {
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 8px;
  gap: 12px;
  border-radius: 10px;
  text-decoration: none;
  transition: background 200ms ease;
}

.product-menu-item:hover,
.product-menu-item:focus-visible {
  background: #f5f6fa;
  outline: none;
}

.product-menu-icon {
  display: flex;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.product-menu-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.product-menu-title {
  display: block;
  color: #111827;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
}

.nav-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  font-size: 14px; font-weight: 500; padding: 10px 20px; border-radius: 8px;
  cursor: pointer; border: none; text-decoration: none; display: inline-block; transition: all 0.2s;
}
.btn-contact { background: #f3f4f6; color: #374151; }
.btn-contact:hover { background: #e5e7eb; }
.btn-primary { background: linear-gradient(135deg, #642DFC 0%, #50C0FF 100%); color: #ffffff; }
.btn-primary:hover { opacity: 0.92; transform: translateY(-1px); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 19px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-secondary {
  background: #f5f5f8;
}

.button-secondary:hover {
  background: #eeeef4;
}

.button-primary {
  gap: 8px;
  color: #ffffff;
  background: linear-gradient(110deg, var(--purple-dark), var(--blue));
  box-shadow: 0 10px 24px rgba(92, 66, 235, 0.18);
}

.button-primary:hover {
  box-shadow: 0 13px 28px rgba(92, 66, 235, 0.26);
}

.speedtest-page {
  position: relative;
  width: 100%;
  margin: 0 0 -32px;
  padding: 130px 32px 104px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.04)),
    url("./assets/network-globe.webp") center bottom / cover no-repeat;
}

.node-section {
  width: min(100%, 760px);
  margin: 0 auto;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  background: transparent !important;
  color: var(--purple);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section-heading h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(24px, 2.5vw, 30px);
  line-height: 1.1;
}

.node-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.node-status i {
  width: 8px;
  height: 8px;
  background: #f0b429;
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(240, 180, 41, 0.11);
}

.node-status.online i {
  background: #38c776;
  box-shadow: 0 0 0 5px rgba(56, 199, 118, 0.12);
}

.node-status.offline i {
  background: #ef6d79;
  box-shadow: 0 0 0 5px rgba(239, 109, 121, 0.12);
}

.node-select-wrap {
  position: relative;
}

.node-select-wrap select {
  width: 100%;
  min-height: 72px;
  padding: 0 64px 0 28px;
  appearance: none;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: var(--purple);
  font-size: clamp(17px, 2vw, 21px);
  font-weight: 700;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.node-select-wrap select:hover,
.node-select-wrap select:focus {
  border-color: rgba(124, 92, 255, 0.45);
  box-shadow: 0 12px 36px rgba(94, 70, 199, 0.08);
}

.node-select-wrap select:disabled {
  cursor: wait;
  opacity: 0.75;
}

.node-select-wrap svg {
  position: absolute;
  top: 50%;
  right: 26px;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  transform: translateY(-50%);
}

[data-theme="dark"] .node-select-wrap svg {
  stroke: #ffffff;
}

.ip-address {
  margin: 32px 0 0;
  color: #979bb6;
  font-size: 12px;
  text-align: center;
}

.ip-address strong {
  color: #6c7194;
  font-weight: 600;
}

.node-detail {
  min-height: 18px;
  margin: 3px 0 0;
  color: #b0b3c7;
  font-size: 11px;
  text-align: center;
}

.test-section {
  width: min(100%, 1040px);
  margin: 28px auto 0;
}

.start-area {
  display: grid;
  justify-items: center;
}

.start-button {
  position: relative;
  display: grid;
  place-content: center;
  width: 154px;
  height: 154px;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
  color: #ffffff;
  background: linear-gradient(112deg, #6330ff 2%, #4cc5f7 100%);
  border: 7px solid #ffffff;
  border-radius: 50%;
  box-shadow:
    0 0 0 2px rgba(111, 77, 255, 0.1),
    0 13px 30px rgba(102, 65, 238, 0.22),
    0 0 30px rgba(112, 78, 255, 0.14);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.start-button::before {
  position: absolute;
  inset: -45%;
  z-index: -1;
  background: linear-gradient(
    100deg,
    transparent 25%,
    rgba(255, 255, 255, 0.34) 46%,
    transparent 64%
  );
  content: "";
  transform: translateX(-70%) rotate(15deg);
}

.start-button:hover:not(:disabled) {
  box-shadow:
    0 0 0 3px rgba(111, 77, 255, 0.13),
    0 18px 40px rgba(102, 65, 238, 0.28),
    0 0 36px rgba(112, 78, 255, 0.2);
  transform: translateY(-3px) scale(1.015);
}

.start-button:focus-visible {
  outline: 3px solid rgba(45, 156, 240, 0.42);
  outline-offset: 5px;
}

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

.start-button[data-state="running"]::before {
  animation: button-shine 1.6s linear infinite;
}

.start-label {
  font-size: 31px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
}

.start-progress {
  min-height: 14px;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.test-status {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.test-status.error {
  color: #d84f61;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(32px, 9vw, 140px);
  width: min(100%, 900px);
  margin: 24px auto 0;
}

.metric-card {
  --gauge-track: var(--download-track);
  --gauge-accent: var(--download-result);
  --gauge-glow: rgba(134, 103, 255, 0.48);
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 1;
  justify-self: center;
}

.metric-upload {
  --gauge-track: var(--upload-track);
  --gauge-accent: var(--upload-result);
  --gauge-glow: rgba(80, 190, 255, 0.48);
}

.gauge,
.gauge svg {
  width: 100%;
  height: 100%;
}

.gauge svg {
  display: block;
  overflow: visible;
  filter: drop-shadow(0 8px 16px rgba(71, 58, 150, 0.05));
}

.gauge circle {
  fill: none;
  stroke-dasharray: 75 25;
  stroke-linecap: butt;
  transform: rotate(135deg);
  transform-origin: 50% 50%;
}

.gauge-track,
.gauge-progress {
  stroke-width: 14.5;
}

.gauge-track {
  stroke: var(--gauge-track);
}

[data-theme="dark"][data-speedtest-status="idle"] .gauge-track {
  opacity: 0.5;
}

.gauge .gauge-result,
.gauge .gauge-progress {
  stroke: var(--gauge-accent);
  stroke-dasharray: 0 100;
}

.gauge .gauge-result {
  stroke-width: 40;
  transition:
    stroke-dasharray 720ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 220ms ease,
    filter 220ms ease;
}

.gauge .gauge-progress {
  opacity: 1;
  transition:
    stroke-dasharray 360ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 180ms ease,
    filter 180ms ease;
}

.metric-card.is-active .gauge-progress {
  filter: drop-shadow(0 0 4px var(--gauge-glow));
  opacity: 1;
}

.metric-card.is-complete .gauge-progress {
  opacity: 1;
}

.metric-copy {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 20px;
  text-align: center;
}

.metric-unit {
  color: #9599b3;
  font-size: clamp(15px, 1.7vw, 19px);
}

.metric-value {
  min-width: 4ch;
  margin-top: 5px;
  color: var(--download-result);
  font-size: clamp(42px, 5vw, 58px);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.055em;
  line-height: 1.05;
}

.metric-upload .metric-value {
  color: var(--upload-result);
}

.metric-copy h2 {
  margin: 7px 0 0;
  font-size: clamp(16px, 2vw, 21px);
  letter-spacing: -0.025em;
  text-transform: uppercase;
}

.metric-copy p {
  margin: 7px 0 0;
  color: #9a9eb6;
  font-size: 12px;
}

.metric-copy p b {
  color: var(--download-result);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.metric-upload .metric-copy p b {
  color: var(--upload-result);
}

.measurement-notes {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 820px);
  margin: 12px auto 0;
  padding: 10px 18px;
  gap: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(232, 232, 244, 0.72);
  border-radius: 12px;
  backdrop-filter: blur(3px);
  text-align: center;
}

.measurement-notes p {
  margin: 0;
  color: #9a9db2;
  font-size: 10px;
  line-height: 1.45;
}

.measurement-notes p + p::before {
  margin-right: 12px;
  content: "·";
}

.measurement-notes strong {
  color: #737793;
}

html[data-speedtest-status="idle"] .metric-copy p {
  visibility: hidden;
}

@keyframes button-shine {
  from {
    transform: translateX(-70%) rotate(15deg);
  }
  to {
    transform: translateX(90%) rotate(15deg);
  }
}

@media (max-width: 900px) {
  .speedtest-page {
    padding: 110px 22px 88px;
  }
}

@media (max-width: 680px) {
  .brand svg {
    width: 124px;
    height: auto;
  }

  .speedtest-page {
    margin-bottom: -24px;
    padding: 102px 18px 72px;
    background-position: center bottom;
    background-size: cover;
  }

  .section-heading {
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .eyebrow {
    font-size: 9px;
  }

  .section-heading h1 {
    font-size: 23px;
  }

  .node-status {
    padding-top: 4px;
    font-size: 10px;
  }

  .node-select-wrap select {
    min-height: 64px;
    padding-right: 50px;
    padding-left: 18px;
    font-size: 14px;
  }

  .node-select-wrap svg {
    right: 18px;
  }

  .ip-address {
    margin-top: 6px;
    font-size: 10px;
  }

  .node-detail {
    min-height: 14px;
    margin-top: 2px;
    font-size: 9px;
  }

  .test-section {
    margin-top: 24px;
  }

  .start-button {
    width: 130px;
    height: 130px;
    border-width: 6px;
  }

  .start-label {
    font-size: 27px;
  }

  .start-progress {
    min-height: 12px;
    margin-top: 6px;
    font-size: 9px;
  }

  .test-status {
    min-height: 18px;
    margin-top: 8px;
    font-size: 11px;
  }

  .metrics {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 18px;
  }

  .metric-card {
    width: min(100%, 300px);
  }

  .metric-copy {
    padding-top: 20px;
  }

  .metric-unit {
    font-size: 15px;
  }

  .metric-value {
    min-width: 4ch;
    margin-top: 4px;
    font-size: 48px;
  }

  .metric-copy h2 {
    margin-top: 6px;
    font-size: 18px;
  }

  .metric-copy p {
    margin-top: 6px;
    font-size: 11px;
  }

  .metric-copy p b {
    font-size: 12px;
  }

  .measurement-notes {
    display: grid;
    margin-top: 12px;
    padding: 12px 14px;
    gap: 4px;
  }

  .measurement-notes p {
    font-size: 10px;
  }

  .measurement-notes p + p::before {
    content: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
