:root {
  --bg: #0A0908;
  --panel: #EAE0D5;
  --panel-soft: #F4EDE5;
  --line: #C6AC8F;
  --text: #0A0908;
  --ink: #0A0908;
  --muted: #5E503F;
  --brand: #22333B;
  --brand-soft: #C6AC8F;
  --ok: #22333B;
  --shadow: rgba(10, 9, 8, 0.38);
  --danger: #8B2635;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--panel);
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(198, 172, 143, 0.16), transparent 36%),
    linear-gradient(135deg, #0A0908 0%, #15252C 52%, #0A0908 100%);
  min-height: 100vh;
  line-height: 1.55;
  letter-spacing: 0.01em;
}

.speedtest-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 16px 44px;
}

.topbar { margin-bottom: 18px; }

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  letter-spacing: 0.2px;
}

.brand p {
  margin: 4px 0 0;
  color: rgba(234, 224, 213, 0.82);
  font-size: 0.95rem;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--brand-soft), var(--panel));
  box-shadow: 0 0 0 8px rgba(198, 172, 143, 0.18), 0 0 24px rgba(198, 172, 143, 0.42);
}

.card {
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
  border: 1px solid rgba(198, 172, 143, 0.74);
  color: var(--text);
  box-shadow:
    0 18px 40px var(--shadow),
    0 7px 16px rgba(10, 9, 8, 0.24),
    0 0 0 1px rgba(255, 255, 255, 0.30) inset;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  display: grid;
  gap: 14px;
  justify-items: center;
  margin-bottom: 16px;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: -150px auto auto -150px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(198, 172, 143, 0.42), transparent 68%);
  pointer-events: none;
}

.speed-dials {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.dial-wrap { display: grid; justify-items: center; }

.dial {
  width: 162px;
  height: 162px;
  border-radius: 50%;
  border: 8px solid rgba(234, 224, 213, 0.42);
  background: conic-gradient(from 210deg, #C6AC8F, #22333B, #0A0908, #EAE0D5, #C6AC8F);
  color: var(--panel);
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  font-weight: 800;
  text-shadow: 0 4px 16px rgba(0,0,0,0.35);
  box-shadow: 0 0 0 8px rgba(234,224,213,0.10), 0 22px 45px rgba(10,9,8,0.34);
  transition: transform 0.25s ease;
}

.dial-down {
  border-color: rgba(198, 172, 143, 0.72);
}

.dial-up {
  border-color: rgba(34, 51, 59, 0.62);
  background: conic-gradient(from 210deg, #EAE0D5, #5E503F, #22333B, #C6AC8F, #EAE0D5);
}

body.is-testing .dial {
  animation: dial-pulse 1.2s ease-in-out infinite;
}

@keyframes dial-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 8px rgba(234,224,213,0.10), 0 22px 45px rgba(10,9,8,0.34); }
  50% { transform: scale(1.03); box-shadow: 0 0 0 11px rgba(198,172,143,0.28), 0 28px 55px rgba(10,9,8,0.40); }
}

.dial-sub {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.95rem;
}

.hero-controls,
.profile-picker,
.path-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.picker-label {
  color: var(--muted);
  font-size: 0.83rem;
  margin-right: 2px;
}

button {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  color: #1b2444;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0,0,0,0.2);
}

.profile-btn,
.path-btn,
.btn-secondary,
.page-btn {
  background: rgba(255, 255, 255, 0.34);
  border-color: var(--line);
  color: var(--brand);
}

.profile-btn.is-active,
.path-btn.is-active,
.page-btn.is-active {
  background: var(--brand-soft);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 0 0 2px rgba(198, 172, 143, 0.35), 0 12px 26px rgba(10, 9, 8, 0.28);
}

.profile-btn:not(.is-active),
.path-btn:not(.is-active) {
  opacity: 0.78;
}

.profile-btn.is-active::before,
.path-btn.is-active::before {
  content: "✓ ";
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: var(--brand);
  color: var(--panel);
  border-color: #0A0908;
}

.btn-secondary { color: var(--brand); }

.btn-link {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 14px;
  font-weight: 700;
  line-height: 1;
}

.status {
  margin: 0;
  min-height: 1.2em;
  color: var(--brand);
  font-weight: 600;
}

.test-progress {
  width: min(560px, 100%);
  display: grid;
  gap: 7px;
}

.test-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.test-progress-track,
.results-load-track {
  height: 10px;
  width: 100%;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid var(--line);
}

.test-progress-fill,
.results-load-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #C6AC8F, #5E503F, #22333B);
  box-shadow: 0 0 15px rgba(94, 80, 63, 0.42);
  transition: width 0.28s ease;
}

.stage-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.stage-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.34);
  transition: all .2s ease;
}

.stage-pill.is-active {
  background: var(--brand-soft);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 7px 22px rgba(10, 9, 8, 0.22);
}

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

.metric { padding: 18px; }
.metric h2 { margin: 0; color: var(--muted); font-size: 0.92rem; }
.metric p { margin: 8px 0 0; font-size: 1.7rem; font-weight: 800; letter-spacing: 0.2px; }
.metric-wide { grid-column: 1 / -1; }

.quality-note {
  margin: 8px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.detail-card,
.diagnostics-card,
.history-card,
.results-card {
  padding: 16px;
}

.detail-card h2,
.diagnostics-card h2,
.history-head h2 {
  margin: 0 0 10px;
  font-size: 1.03rem;
}

.detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.detail-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.detail-list li:first-child { border-top: 0; }
.detail-list strong { color: var(--text); }

.share-block {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 8px;
}

.share-note,
.disclaimer,
.diag-sub,
.stream-head span,
.results-meta,
.page-ellipsis {
  color: var(--muted);
}

.disclaimer { margin: 10px 0 0; font-size: 0.86rem; }

.chart-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.34);
}

#throughputChart {
  width: 100%;
  height: 220px;
  display: block;
}

.stream-head {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stream-head h3 { margin: 0; font-size: 0.95rem; }

.stream-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.stream-item,
.history-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.34);
}

.stream-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.86rem;
}

.stream-right { font-weight: 700; }

.stream-empty,
.history-empty,
.results-empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.history-head-actions,
.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.history-item { display: grid; gap: 6px; }

.history-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.86rem;
}

.results-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.results-table th,
.results-table td {
  border-top: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  white-space: nowrap;
}

.location-badges {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.loc-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.loc-country {
  background: rgba(198, 172, 143, 0.72);
  border: 1px solid var(--line);
  color: var(--ink);
}

.loc-city {
  background: rgba(255, 255, 255, 0.34);
  border: 1px solid var(--line);
  color: var(--brand);
}

.loc-empty {
  background: rgba(255, 255, 255, 0.34);
  border: 1px dashed var(--line);
  color: var(--muted);
}

.results-table th {
  color: var(--muted);
  font-weight: 700;
  background: rgba(198, 172, 143, 0.28);
}

.quality-grade {
  font-weight: 700;
}

.quality-hint {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: help;
}

.results-controls {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.results-pagination,
.results-page-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-btn {
  min-width: 34px;
  padding: 7px 10px;
  border-radius: 8px;
}

@media (max-width: 760px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .hero-controls { width: 100%; }
  .hero-controls > * { flex: 1 1 160px; text-align: center; }
  .speed-dials { gap: 10px; }
  .dial { width: 146px; height: 146px; font-size: 1.7rem; }
}
