/* ===== Reset & Variables ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);

  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55556a;

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --cyan: #22d3ee;
  --green: #34d399;
  --orange: #fb923c;
  --red: #f87171;

  --gradient: linear-gradient(135deg, #6366f1 0%, #22d3ee 50%, #34d399 100%);
  --gradient-text: linear-gradient(135deg, #818cf8, #22d3ee);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 60px var(--accent-glow);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== Background Effects ===== */
.bg-gradient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(99, 102, 241, 0.15), transparent),
    radial-gradient(ellipse 60% 50% at 80% 50%, rgba(34, 211, 238, 0.08), transparent),
    radial-gradient(ellipse 50% 40% at 20% 80%, rgba(52, 211, 153, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  background: rgba(10, 10, 15, 0.8);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.25rem;
}

.logo__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--gradient);
  border-radius: var(--radius-sm);
  color: white;
}

.logo__icon svg {
  width: 20px;
  height: 20px;
}

.nav {
  display: flex;
  gap: 8px;
}

.nav__link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}

.nav__link:hover,
.nav__link.active {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

/* ===== Hero ===== */
.section {
  position: relative;
  z-index: 1;
  padding: 80px 0;
}

.hero {
  padding-top: 60px;
  padding-bottom: 40px;
}

.hero__content {
  text-align: center;
  margin-bottom: 48px;
}

.badge {
  display: inline-block;
  padding: 6px 16px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent-light);
  margin-bottom: 20px;
}

.hero__title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
}

/* ===== Speed Card ===== */
.speed-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

/* ===== Gauge ===== */
.speed-gauge {
  position: relative;
  width: 260px;
  height: 260px;
  margin: 0 auto 40px;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 8;
}

.gauge-progress {
  fill: none;
  stroke: url(#gaugeGradient);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 534;
  stroke-dashoffset: 534;
  transition: stroke-dashoffset 0.6s ease, stroke 0.3s ease;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-value {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.gauge-unit {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
}

.gauge-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ===== Metrics ===== */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.metric {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.metric:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.metric__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.metric__icon svg {
  width: 20px;
  height: 20px;
}

.metric__icon--download {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-light);
}

.metric__icon--upload {
  background: rgba(34, 211, 238, 0.15);
  color: var(--cyan);
}

.metric__icon--ping {
  background: rgba(52, 211, 153, 0.15);
  color: var(--green);
}

.metric__icon--jitter {
  background: rgba(251, 146, 60, 0.15);
  color: var(--orange);
}

.metric__label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.metric__value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ===== Buttons ===== */
.speed-actions {
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.btn--lg {
  padding: 16px 48px;
  font-size: 1.0625rem;
  border-radius: var(--radius-lg);
}

.btn--primary {
  background: var(--gradient);
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn--primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--accent-glow);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn--primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn--secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.hidden {
  display: none !important;
}

.speed-status {
  margin-top: 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ===== Progress Bar ===== */
.progress-bar {
  margin-top: 24px;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 100px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  background: var(--gradient);
  border-radius: 100px;
  transition: width 0.3s ease;
}

/* ===== Network Info ===== */
.network-info {
  padding-top: 0;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.info-card {
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
}

.info-card:hover {
  border-color: var(--border-hover);
}

.info-card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.info-card__header svg {
  width: 20px;
  height: 20px;
  color: var(--accent-light);
}

.info-card__header h3 {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.info-card__value {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  word-break: break-all;
}

.info-card__detail {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ===== Tools ===== */
.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 1.0625rem;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.tool-card {
  padding: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
}

.tool-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.tool-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: rgba(99, 102, 241, 0.12);
  border-radius: var(--radius-md);
  color: var(--accent-light);
  margin-bottom: 16px;
}

.tool-card__icon svg {
  width: 24px;
  height: 24px;
}

.tool-card__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.tool-card__desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.tool-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input::placeholder {
  color: var(--text-muted);
}

.tool-result {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-height: 200px;
  overflow-y: auto;
}

.tool-result .latency-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.tool-result .latency-item:last-child {
  border-bottom: none;
}

.tool-result .latency-ms {
  font-weight: 600;
  color: var(--text-primary);
}

.tool-result .latency-ms.good { color: var(--green); }
.tool-result .latency-ms.medium { color: var(--orange); }
.tool-result .latency-ms.bad { color: var(--red); }

/* ===== Quality Meter ===== */
.quality-meter {
  margin-top: 4px;
}

.quality-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 12px;
}

.quality-fill {
  height: 100%;
  width: 0%;
  border-radius: 100px;
  background: var(--gradient);
  transition: width 0.8s ease;
}

.quality-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ===== About ===== */
.about-card {
  padding: 48px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  text-align: center;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin-top: 40px;
  text-align: left;
}

.about-number {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--accent-light);
  background: rgba(99, 102, 241, 0.12);
  padding: 4px 10px;
  border-radius: 100px;
  margin-bottom: 12px;
}

.about-item h4 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.about-item p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== Footer ===== */
.footer {
  position: relative;
  z-index: 1;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer__inner p {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer__note {
  margin-top: 4px;
  font-size: 0.75rem !important;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .tools-grid {
    grid-template-columns: 1fr;
  }

  .about-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 600px) {
  .header__inner {
    flex-direction: column;
    height: auto;
    padding: 12px 0;
    gap: 12px;
  }

  .speed-card {
    padding: 28px 20px;
  }

  .speed-gauge {
    width: 220px;
    height: 220px;
  }

  .gauge-value {
    font-size: 2.75rem;
  }

  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .metric {
    padding: 12px;
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }

  .about-card {
    padding: 28px 20px;
  }

  .tool-input-group {
    flex-direction: column;
  }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero__content,
.speed-card,
.info-card,
.tool-card {
  animation: fadeInUp 0.6s ease backwards;
}

.speed-card { animation-delay: 0.1s; }
.info-card:nth-child(1) { animation-delay: 0.15s; }
.info-card:nth-child(2) { animation-delay: 0.2s; }
.info-card:nth-child(3) { animation-delay: 0.25s; }

/* Testing state */
.speed-card.testing {
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: var(--shadow), var(--shadow-glow);
}

.gauge-progress.active {
  stroke: url(#gaugeGradient);
}
