:root {
  color-scheme: dark;
  --bg: #07110f;
  --surface: rgba(15, 31, 27, 0.76);
  --surface-solid: #10211d;
  --surface-hover: #173029;
  --text: #eefaf4;
  --muted: #8fa59d;
  --line: rgba(179, 221, 204, 0.13);
  --accent: #7dffbd;
  --accent-strong: #35e692;
  --accent-soft: rgba(91, 255, 173, 0.12);
  --danger: #ff786f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f7f4;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-hover: #edf5f0;
  --text: #10231c;
  --muted: #64776f;
  --line: rgba(21, 70, 51, 0.13);
  --accent: #087c4a;
  --accent-strong: #0b9b60;
  --accent-soft: rgba(11, 155, 96, 0.1);
  --danger: #c9413a;
  --shadow: 0 24px 70px rgba(23, 63, 47, 0.11);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background .25s ease, color .25s ease;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
.ambient { position: fixed; z-index: -1; width: 34rem; height: 34rem; border-radius: 50%; filter: blur(110px); opacity: .13; pointer-events: none; }
.ambient-one { top: -15rem; left: -10rem; background: #2fff9c; }
.ambient-two { right: -17rem; top: 34rem; background: #3bbdff; }
.app-shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }

.topbar { height: 88px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 750; letter-spacing: .02em; }
.brand-mark { display: flex; align-items: end; justify-content: center; gap: 3px; width: 31px; height: 31px; padding: 7px; border: 1px solid var(--line); border-radius: 9px; background: var(--accent-soft); }
.brand-mark i { display: block; width: 3px; border-radius: 4px; background: var(--accent); }
.brand-mark i:nth-child(1) { height: 6px; }.brand-mark i:nth-child(2) { height: 11px; }.brand-mark i:nth-child(3) { height: 16px; }
.theme-toggle { display: flex; align-items: center; gap: 8px; border: 0; padding: 6px; color: var(--muted); background: transparent; }
.toggle-track { position: relative; width: 42px; height: 23px; border-radius: 20px; background: var(--surface-hover); border: 1px solid var(--line); }
.toggle-knob { position: absolute; top: 3px; right: 3px; width: 15px; height: 15px; border-radius: 50%; background: var(--accent); transition: transform .25s ease; }
html[data-theme="light"] .toggle-knob { transform: translateX(-19px); }

.hero { padding: 76px 0 58px; text-align: center; }
.eyebrow { margin: 0 0 15px; color: var(--accent); font-size: 11px; line-height: 1; font-weight: 800; letter-spacing: .19em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3rem, 7.3vw, 6rem); font-weight: 400; letter-spacing: -.055em; line-height: .96; }
h1 em { color: var(--accent); font-weight: 400; }
.lede { max-width: 520px; margin: 25px auto 0; color: var(--muted); line-height: 1.7; font-size: 15px; }

.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.stat-card { display: flex; gap: 14px; align-items: center; min-height: 96px; padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.stat-icon { display: grid; place-items: center; flex: 0 0 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.alert-stat .stat-icon { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }
.stat-card span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.stat-card strong { display: flex; align-items: baseline; gap: 5px; font-size: 22px; }
.stat-card b { font: inherit; }.stat-card small { color: var(--muted); font-size: 10px; font-weight: 600; }

.speed-panel { margin-top: 18px; padding: 50px 28px 35px; text-align: center; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(150deg, var(--surface), color-mix(in srgb, var(--surface-solid) 80%, transparent)); box-shadow: var(--shadow); }
.status-line { display: flex; justify-content: center; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px color-mix(in srgb, var(--muted) 10%, transparent); }
.status-dot.active { background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft), 0 0 18px var(--accent); }
.status-dot.offline { background: var(--danger); }
.speed-reading { display: flex; justify-content: center; align-items: flex-end; gap: 16px; margin: 16px 0 18px; }
.speed-reading > span { font-family: Georgia, "Times New Roman", serif; font-size: clamp(5rem, 14vw, 10rem); line-height: .85; letter-spacing: -.07em; }
.speed-reading div { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding-bottom: 4px; }
.speed-reading strong { color: var(--accent); font-size: 20px; }.speed-reading small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.speed-panel > p { color: var(--muted); font-size: 12px; }
.meter { max-width: 680px; height: 3px; margin: 28px auto 0; overflow: hidden; background: var(--line); border-radius: 4px; }
.meter span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); box-shadow: 0 0 12px var(--accent); transition: width .6s ease; }
.testing-message { margin-top: 16px !important; color: var(--accent) !important; }

.controls-panel { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; margin-top: 18px; padding: 24px 26px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.interval-control label { display: block; margin-bottom: 10px; font-size: 12px; font-weight: 750; }
.interval-control > small { display: block; margin-top: 8px; color: var(--muted); font-size: 10px; }
.input-group { display: flex; }
.input-group input, .input-group select { height: 42px; color: var(--text); border: 1px solid var(--line); outline: none; background: var(--bg); }
.input-group input:focus, .input-group select:focus { border-color: var(--accent); }
.input-group input { width: 82px; padding: 0 12px; border-radius: 9px 0 0 9px; }
.input-group select { padding: 0 34px 0 12px; border-left: 0; border-radius: 0 9px 9px 0; }
.action-buttons { display: flex; gap: 10px; }
.button { height: 44px; padding: 0 20px; border-radius: 10px; font-size: 12px; font-weight: 800; letter-spacing: .03em; transition: transform .15s ease, opacity .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-2px); }.button:disabled { cursor: not-allowed; opacity: .4; }
.button-primary { color: #062016; border: 1px solid var(--accent); background: var(--accent); }
.button-secondary { color: var(--text); border: 1px solid var(--line); background: var(--surface-hover); }
.button-danger { color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); background: transparent; }

.session-dialog[hidden] { display: none; }
.session-dialog { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; }
.session-dialog-backdrop { position: absolute; inset: 0; background: rgba(2, 10, 7, .76); backdrop-filter: blur(8px); }
.session-dialog-card { position: relative; width: min(470px, 100%); padding: 36px; text-align: center; border: 1px solid var(--line); border-radius: 20px; background: var(--surface-solid); box-shadow: 0 30px 100px rgba(0, 0, 0, .45); }
.session-dialog-card h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 34px; font-weight: 400; }
.session-dialog-card > p:not(.eyebrow) { margin: 14px auto 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.session-dialog-card > small { display: block; margin-top: 16px; color: var(--muted); font-size: 10px; }
.session-dialog-actions { display: flex; justify-content: center; gap: 10px; }

.history-section { margin: 60px 0 90px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 30px; font-weight: 400; }
.section-heading > span { color: var(--muted); font-size: 11px; }
.history-empty { padding: 40px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; font-size: 12px; }
.history-list { display: grid; gap: 8px; }
.history-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 30px; padding: 15px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.history-row time { color: var(--muted); font-size: 11px; }.history-row strong { font-size: 16px; }.history-row small { color: var(--muted); }
.history-bar { width: 150px; height: 3px; background: var(--line); border-radius: 4px; overflow: hidden; }.history-bar span { display: block; height: 100%; background: var(--accent); }
footer { display: flex; justify-content: center; gap: 10px; padding: 25px 0 40px; color: var(--muted); border-top: 1px solid var(--line); font-size: 10px; letter-spacing: .05em; }

@media (max-width: 800px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .controls-panel { align-items: stretch; flex-direction: column; }.action-buttons { width: 100%; }.button { flex: 1; }
}
@media (max-width: 1050px) and (min-width: 801px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 520px) {
  .app-shell { width: min(100% - 24px, 1120px); }.topbar { height: 70px; }.hero { padding: 52px 0 42px; }
  .stats-grid { grid-template-columns: 1fr; }.stat-card { min-height: 78px; }.speed-panel { padding: 40px 14px 28px; }
  .speed-reading div { padding-bottom: 6px; }.speed-reading strong { font-size: 15px; }
  .action-buttons { flex-direction: column; }.history-row { grid-template-columns: 1fr auto; }.history-bar { display: none; }
  .session-dialog-card { padding: 30px 20px; }.session-dialog-actions { flex-direction: column; }
  footer { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }

.countdown {
  margin: 0.5rem 0 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.best-site {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  opacity: 0.7;
}

.history-sites { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.history-sites .site-low { color: var(--danger, #ff6b6b); font-weight: 600; }
.history-row { row-gap: 8px; }

.site-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 0 12px; }
.site-chip { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.site-chip.testing { color: var(--accent); border-color: var(--accent); }
.site-chip.site-low { color: var(--danger, #ff6b6b); border-color: currentColor; }
