:root {
  --bg: #050509;
  --surface: rgba(255, 255, 255, 0.08);
  --surface-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4ff;
  --muted: #a6a6c3;
  --accent: #a78bfa;
  --accent-soft: rgba(167, 139, 250, 0.18);
  --accent-2: #7dd3fc;
  --accent-3: #f9a8d4;
  --shadow: 0 15px 45px rgba(0, 0, 0, 0.45), 0 0 50px rgba(167, 139, 250, 0.1);
  --radius: 20px;
  --glass-blur: 22px;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #facc15;
}

:root.light {
  --bg: #f7f7fb;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: rgba(0, 0, 0, 0.08);
  --text: #1f1f2b;
  --muted: #4b4b64;
  --shadow: 0 15px 45px rgba(15, 23, 42, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(1200px 700px at 10% -10%, rgba(167, 139, 250, 0.25), transparent),
    radial-gradient(900px 600px at 90% 0%, rgba(125, 211, 252, 0.18), transparent),
    radial-gradient(1000px 700px at 50% 110%, rgba(249, 168, 212, 0.18), transparent),
    var(--bg);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.4em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.8rem;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('https://www.transparenttextures.com/patterns/cubes.png');
  opacity: 0.04;
  pointer-events: none;
  mix-blend-mode: screen;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

.container {
  width: min(1200px, 92%);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 1.2rem 0;
  backdrop-filter: blur(16px) saturate(160%);
  background: rgba(5, 5, 11, 0.65);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

:root.light .site-header {
  background: rgba(247, 247, 251, 0.8);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo .emoji {
  font-size: 1.4rem;
  filter: drop-shadow(0 0 10px rgba(167, 139, 250, 0.8));
}

.header-actions {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.main {
  padding: 3.5rem 0 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.glass {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
}

.hero {
  padding: 2.2rem;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2.5rem;
}

.hero-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hero-text .hint {
  margin-top: 0.4rem;
}

.consent-block {
  margin-top: 0.8rem;
}

.consent {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.04), rgba(167, 139, 250, 0.08));
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.consent input[type='checkbox'] {
  appearance: none;
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.35rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.consent input[type='checkbox']::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 4px;
  background: transparent;
  transform: scale(0.6);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.consent input[type='checkbox']:checked {
  border-color: rgba(167, 139, 250, 0.8);
  background: linear-gradient(140deg, rgba(167, 139, 250, 0.8), rgba(125, 211, 252, 0.65));
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.5);
}

.consent input[type='checkbox']:checked::after {
  background: rgba(5, 5, 11, 0.9);
  opacity: 1;
  transform: scale(1);
}

.consent span a {
  color: var(--accent);
  text-decoration: none;
}

.consent span a:hover {
  text-decoration: underline;
}

.hero-metrics {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero-text .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.4em;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0 0 0.8rem;
}

.hero-text h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(2rem, 1.4rem + 2vw, 3rem);
}

.hero-text p {
  margin: 0 0 1.3rem;
  color: var(--muted);
}

.hero-cta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.hero-note {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.hero-note i {
  color: var(--accent-2);
}

.status-chip[data-state='idle'] {
  color: var(--muted);
}

.status-chip[data-state='active'] {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-chip[data-state='success'] {
  background: rgba(34, 197, 94, 0.18);
  color: var(--success);
}

.status-chip[data-state='error'] {
  background: rgba(239, 68, 68, 0.18);
  color: var(--error);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.metric-card {
  padding: 1.4rem;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.metric-card::after {
  content: '';
  position: absolute;
  inset: -30% auto auto -20%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  filter: blur(10px);
}

.metric-card h3 {
  margin: 0;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.metric-card .value {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: clamp(2rem, 1.5rem + 1vw, 3rem);
  margin: 0.7rem 0;
  font-weight: 600;
}

.metric-card .unit {
  font-size: 1rem;
  color: var(--muted);
}

.metric-card p {
  margin: 0;
  color: var(--muted);
}

.metric-card.download {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.3), rgba(5, 5, 11, 0.4));
}

.metric-card.upload {
  background: linear-gradient(135deg, rgba(125, 211, 252, 0.3), rgba(5, 5, 11, 0.4));
}

.metric-card.ping {
  background: linear-gradient(135deg, rgba(249, 168, 212, 0.35), rgba(5, 5, 11, 0.4));
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.4rem;
  border-radius: 14px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.btn.primary {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.4), rgba(125, 211, 252, 0.35));
  border-color: rgba(167, 139, 250, 0.5);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.35);
}

.btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.2);
}

.icon-button {
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.grid-two-col {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
}

.graph-card,
.insights-card {
  padding: 1.8rem;
}

.graph-card header,
.insights-card header,
.history header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.graph-card canvas {
  width: 100%;
  height: 280px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.graph-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.graph-meta .stat {
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.graph-meta .label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  display: block;
}

.graph-meta .value {
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 0.3rem;
  display: block;
  width: 100%;
}

.legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.legend .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend .download {
  background: var(--accent);
}

.legend .upload {
  background: var(--accent-2);
}

.insight-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.9rem;
}

.insight-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.insight-list .label {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.insight-list .value {
  font-weight: 600;
  font-size: 1rem;
}

.pill {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.75rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--muted);
}

.history {
  padding: 2rem;
}

.history-list {
  display: grid;
  gap: 0.9rem;
}

.history-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.8rem;
  background: rgba(255, 255, 255, 0.02);
}

.history-card .timestamp {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--muted);
}

.history-card strong {
  font-size: 1.1rem;
}

.history-card small {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  color: var(--muted);
}

#bestRecordValue {
  font-weight: 600;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 16px;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  padding: 2rem 0 3rem;
}

@media (max-width: 1024px) {
  .hero {
    grid-template-columns: 1fr;
  }

  .grid-two-col {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .hero,
  .graph-card,
  .insights-card,
  .history {
    padding: 1.5rem;
  }

  .hero-cta {
    flex-direction: column;
    align-items: stretch;
  }

  .status-chip {
    width: 100%;
    justify-content: center;
  }
}
