/* Speedtest24 – modern UI */

:root {
  --font: 'Figtree', system-ui, -apple-system, sans-serif;

  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-subtle: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --accent: #059669;
  --accent-hover: #047857;
  --accent-soft: rgba(5, 150, 105, 0.12);
  --ping: #ea580c;
  --download: #10b981;
  --upload: #14b8a6;
  --success: #059669;
  --warn: #d97706;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 12px 28px -8px rgba(15, 23, 42, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --meter-track: #e2e8f0;
}

[data-theme='dark'] {
  --bg: #020617;
  --bg-elevated: #0f172a;
  --bg-subtle: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --accent: #34d399;
  --accent-hover: #6ee7b7;
  --accent-soft: rgba(52, 211, 153, 0.18);
  --ping: #fb923c;
  --download: #34d399;
  --upload: #2dd4bf;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --meter-track: #1e293b;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body { margin: 0; min-height: 100vh; line-height: 1.5; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.shell {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0 1.25rem;
  margin-bottom: 2rem;
}

.brand {
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.03em;
}

.brand-mark {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: middle;
}

.nav { display: none; gap: 1.25rem; }
@media (min-width: 640px) { .nav { display: flex; } }
.nav a {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}
.nav a:hover { color: var(--text); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.theme-toggle {
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-faint); }
.theme-toggle svg { width: 1.125rem; height: 1.125rem; }
.theme-toggle .icon-sun { display: none; }
[data-theme='dark'] .theme-toggle .icon-sun { display: block; }
[data-theme='dark'] .theme-toggle .icon-moon { display: none; }

/* Language selector */
.lang-select {
  position: relative;
}

.lang-current {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.lang-current:hover {
  border-color: var(--text-faint);
}

.lang-flag {
  font-size: 1.125rem;
  line-height: 1;
}

.lang-code {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 100;
  min-width: 11rem;
  padding: 0.35rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

.lang-menu a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
}

.lang-menu a:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.lang-menu a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Intro */
.intro { margin-bottom: 1.75rem; }
.intro h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.875rem, 5vw, 2.375rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.1;
}
.intro p {
  margin: 0;
  font-size: 1.0625rem;
  color: var(--text-muted);
}

/* Test panel */
.test-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 1.5rem 1.25rem;
  margin-bottom: 1.25rem;
}

.test-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.status-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.status-text {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.status-text.is-active { color: var(--accent); }

.status-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--border);
}
.status-dot.live {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulse 1.5s ease infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }

.meters { display: flex; flex-direction: column; gap: 1.375rem; }

.meter { transition: opacity 0.2s; }
.meter.is-idle { opacity: 0.5; }
.meter.is-active,
.meter.is-done { opacity: 1; }

.meter-head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.625rem;
}

.meter-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}
.meter.is-active .meter-name { color: var(--text); }

.meter-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  min-width: 4.5ch;
  text-align: right;
}

.meter-unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-faint);
  width: 2.75rem;
}

.meter-track {
  height: 12px;
  background: var(--meter-track);
  border-radius: 999px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: none;
}

.test-panel.is-testing .meter.is-active .meter-fill {
  transition: none;
}

.meter.is-active .meter-fill {
  transition: width 0.15s linear;
}

.meter[data-metric='ping'] .meter-fill { background: var(--ping); }
.meter[data-metric='download'] .meter-fill { background: var(--download); }
.meter[data-metric='upload'] .meter-fill { background: var(--upload); }

.meter-foot {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  min-height: 1.125rem;
}

.test-actions {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.875rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.75rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(5, 150, 105, 0.45);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-primary svg { width: 1.125rem; height: 1.125rem; }

.test-hint { font-size: 0.8125rem; color: var(--text-faint); }

/* Cards */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.card-head {
  padding: 0.875rem 1.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

.hidden { display: none !important; }
.fade-in { animation: fadeUp 0.4s ease forwards; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.results-grid > div {
  padding: 1.125rem 0.75rem;
  text-align: center;
  border-right: 1px solid var(--border);
}
.results-grid > div:last-child { border-right: none; }

.results-grid .val {
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.results-grid .lbl {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-top: 0.2rem;
}
.quality { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.35rem; }
.quality-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* IP */
.ip-grid { display: grid; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .ip-grid { grid-template-columns: repeat(4, 1fr); } }

.ip-cell {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.ip-cell:nth-child(2n) { border-right: none; }
@media (min-width: 640px) {
  .ip-cell:nth-child(2n) { border-right: 1px solid var(--border); }
  .ip-cell:nth-child(4n) { border-right: none; }
}
.ip-cell:nth-last-child(-n+2) { border-bottom: none; }
@media (min-width: 640px) {
  .ip-cell:nth-last-child(-n+4) { border-bottom: none; }
}

.ip-label {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 0.3rem;
}
.ip-value { font-size: 0.875rem; font-weight: 600; word-break: break-word; }
.ip-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }

.skeleton .ip-value {
  height: 0.875rem;
  width: 65%;
  background: var(--bg-subtle);
  border-radius: 4px;
  animation: shimmer 1s ease-in-out infinite;
}
@keyframes shimmer { 50% { opacity: 0.45; } }

/* Usage */
.usage-grid {
  display: flex;
  flex-direction: column;
}

.usage-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 1rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.usage-item:last-child {
  border-bottom: none;
}

.usage-item .u-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0;
}

.usage-item .u-val {
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.3;
}

.usage-item .u-sub {
  font-size: 0.8125rem;
  color: var(--text-faint);
  margin: 0;
}

@media (min-width: 640px) {
  .usage-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1px;
    background: var(--border);
  }

  .usage-item {
    align-items: center;
    text-align: center;
    padding: 1.125rem 0.75rem;
    border-bottom: none;
    gap: 0.35rem;
  }

  .usage-item .u-title {
    font-size: 0.625rem;
    color: var(--text-faint);
  }

  .usage-item .u-val {
    font-size: 1rem;
  }

  .usage-item .u-sub {
    font-size: 0.6875rem;
  }
}

.text-ok { color: var(--success); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--danger); }

/* Conversion banner */
.conversion-banner {
  position: relative;
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(125deg, #047857 0%, #059669 45%, #10b981 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12) inset,
    0 20px 50px -12px rgba(5, 150, 105, 0.5);
}

[data-theme='dark'] .conversion-banner {
  background: linear-gradient(125deg, #064e3b 0%, #047857 50%, #10b981 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 24px 48px -12px rgba(0, 0, 0, 0.55);
}

.conversion-inner {
  position: relative;
  padding: 1.75rem 1.5rem;
  color: #fff;
}

.conversion-inner::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -15%;
  width: 55%;
  aspect-ratio: 1;
  background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.conversion-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  margin-bottom: 0.875rem;
}

.conversion-title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.375rem, 4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.conversion-speed {
  display: block;
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.conversion-text {
  margin: 0 0 1rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.88);
  max-width: 36ch;
}

.conversion-list {
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.9);
}
.conversion-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.conversion-list li::before {
  content: '✓';
  font-weight: 700;
  color: #bbf7d0;
}

.conversion-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.0625rem;
  font-weight: 700;
  color: #065f46;
  background: #fff;
  border: none;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s, box-shadow 0.12s;
}

.conversion-cta:hover {
  color: #047857;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

@media (min-width: 480px) {
  .conversion-cta { width: auto; min-width: 16rem; }
}

.conversion-note {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
}

/* SEO */
.seo-block .card-body { padding: 1.25rem; }
.seo-block h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.seo-block p {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.65;
}
.seo-block p:last-child { margin-bottom: 0; }

.site-footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-faint);
}
.site-footer strong { color: var(--text-muted); }

/* ── Mobile ───────────────────────────────────── */
@media (max-width: 639px) {
  .shell {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .site-header {
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
  }

  .test-panel {
    padding: 1.25rem 1rem;
  }

  .meter-value {
    font-size: 1.5rem;
  }

  .test-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary {
    justify-content: center;
    width: 100%;
  }

  .test-hint {
    text-align: center;
  }

  .results-grid .val {
    font-size: 1.125rem;
  }

  .conversion-inner {
    padding: 1.5rem 1.25rem;
  }

  #usage-section .card-head {
    padding: 0.875rem 1rem;
  }
}
