:root {
  color-scheme: dark;
  --bg: #050816;
  --bg-2: #0b1024;
  --panel: rgba(12, 18, 40, 0.74);
  --panel-strong: rgba(10, 14, 32, 0.9);
  --text: #f8fbff;
  --muted: #9eabc8;
  --dim: #66708e;
  --border: rgba(168, 184, 255, 0.18);
  --border-strong: rgba(255, 255, 255, 0.28);
  --fastly: #ff2d55;
  --fastly-soft: rgba(255, 45, 85, 0.22);
  --cyan: #38e8ff;
  --cyan-soft: rgba(56, 232, 255, 0.2);
  --violet: #9b5cff;
  --green: #52ffa8;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
  --radius-xl: 1.65rem;
  --radius-lg: 1.2rem;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 8%, rgba(255, 45, 85, 0.2), transparent 30rem),
    radial-gradient(circle at 78% 4%, rgba(56, 232, 255, 0.18), transparent 34rem),
    radial-gradient(circle at 55% 95%, rgba(155, 92, 255, 0.14), transparent 34rem),
    linear-gradient(135deg, #030511 0%, #071126 48%, #140716 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
}

button, input, select { font: inherit; }
button, select { color: inherit; }
button {
  border: 0;
  border-radius: 999px;
  padding: 0.82rem 1.15rem;
  background: linear-gradient(135deg, var(--fastly), #ff7a59);
  color: #fff;
  font-weight: 800;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(255, 45, 85, 0.28);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 18px 44px rgba(255, 45, 85, 0.36); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { opacity: 0.42; cursor: not-allowed; box-shadow: none; }
button.ghost,
.secondary-actions button,
.segmented button {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}
button.ghost:hover:not(:disabled),
.secondary-actions button:hover:not(:disabled) { border-color: var(--cyan); box-shadow: 0 12px 30px rgba(56, 232, 255, 0.12); }

select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: rgba(255,255,255,0.055);
  padding: 0.55rem 0.7rem;
  outline: none;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 10ch;
  margin-bottom: 0.75rem;
  font-size: clamp(3.25rem, 10vw, 7.4rem);
  line-height: 0.82;
  letter-spacing: -0.08em;
}
h2 { margin-bottom: 0; font-size: clamp(1.2rem, 2vw, 1.7rem); letter-spacing: -0.04em; }
strong { font-weight: 850; }

.shell { width: min(1240px, calc(100% - 2rem)); margin: 0 auto; padding: 1.25rem 0 4rem; position: relative; z-index: 1; }
.card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(18, 25, 54, 0.86), rgba(10, 14, 32, 0.78));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,0.12), transparent 28%, transparent 72%, rgba(255,255,255,0.04));
  opacity: 0.45;
}
.card > * { position: relative; z-index: 1; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand-mark {
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 0.9rem;
  background: radial-gradient(circle at 30% 30%, #fff, var(--cyan) 24%, var(--fastly) 56%, #471143 100%);
  box-shadow: 0 0 34px rgba(255, 45, 85, 0.35), inset 0 0 18px rgba(255,255,255,0.3);
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 1.15rem; letter-spacing: -0.03em; }
.brand span { color: var(--muted); font-size: 0.88rem; }
.privacy-pill,
.live-pill,
.edge-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.55rem 0.75rem;
  color: var(--muted);
  background: rgba(255,255,255,0.055);
  font-size: 0.86rem;
}
.privacy-pill span,
.live-pill::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 18px rgba(82, 255, 168, 0.75);
}
.live-pill { color: var(--text); align-self: flex-start; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.76rem; }
body.is-live .live-pill::before { animation: pulse 1.2s infinite; }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(21rem, 0.65fr); gap: 1rem; }
.hero-card { min-height: 35rem; padding: clamp(1.2rem, 3vw, 2rem); display: flex; flex-direction: column; justify-content: space-between; }
.hero-card::before {
  content: "";
  position: absolute;
  right: -12rem;
  top: -13rem;
  width: 30rem;
  height: 30rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,45,85,0.34), rgba(56,232,255,0.13) 38%, transparent 67%);
  filter: blur(2px);
}
.eyebrow { margin-bottom: 0.6rem; color: var(--cyan); text-transform: uppercase; letter-spacing: 0.16em; font-size: 0.77rem; font-weight: 900; }
.subtle { color: var(--muted); line-height: 1.6; }
.small { font-size: 0.9rem; }
.center { text-align: center; }
.hero-copy { max-width: 52rem; font-size: 1.05rem; }
.step-panel { display: grid; gap: 0.1rem; margin: 1.5rem 0; }
.step-number { font-size: clamp(4.7rem, 16vw, 10.5rem); line-height: 0.86; letter-spacing: -0.08em; font-variant-numeric: tabular-nums; text-shadow: 0 0 30px rgba(56, 232, 255, 0.24); }
.step-label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 800; }
.metric-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-grid div,
.stats div {
  border: 1px solid var(--border);
  border-radius: 1.05rem;
  background: rgba(255,255,255,0.052);
  padding: 0.9rem;
  min-width: 0;
}
.metric-grid span,
dt { display: block; color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.11em; font-weight: 800; }
.metric-grid strong { display: block; margin-top: 0.4rem; font-size: 1.25rem; overflow-wrap: anywhere; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 1rem; }

.halo-card { min-height: 35rem; padding: 1.2rem; display: grid; place-items: center; align-content: center; gap: 1.3rem; }
.orb-wrap { position: relative; width: min(23rem, 78vw); aspect-ratio: 1; display: grid; place-items: center; }
.orb-ring, .orb-core { position: absolute; border-radius: 50%; }
.orb-ring { inset: 0; border: 1px solid rgba(56, 232, 255, 0.22); box-shadow: inset 0 0 50px rgba(56,232,255,0.08), 0 0 70px rgba(255,45,85,0.1); }
.ring-a { animation: breathe 4.4s ease-in-out infinite; }
.ring-b { inset: 12%; border-color: rgba(255,45,85,0.32); animation: breathe 5.2s ease-in-out infinite reverse; }
.ring-c { inset: 24%; border-color: rgba(155,92,255,0.42); animation: spin 18s linear infinite; border-style: dashed; }
.orb-core {
  inset: 33%;
  display: grid;
  place-items: center;
  align-content: center;
  background: radial-gradient(circle at 35% 25%, rgba(255,255,255,0.28), rgba(56,232,255,0.18), rgba(255,45,85,0.16));
  border: 1px solid rgba(255,255,255,0.22);
  box-shadow: 0 0 45px rgba(56,232,255,0.2), inset 0 0 44px rgba(255,255,255,0.08);
}
.orb-core span { font-size: clamp(1.55rem, 4vw, 2.35rem); font-weight: 900; letter-spacing: -0.06em; }
.orb-core small { color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-weight: 800; }
.milestone-toast {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  border: 1px solid rgba(82,255,168,0.38);
  border-radius: 1rem;
  padding: 0.75rem;
  text-align: center;
  background: rgba(82,255,168,0.1);
  box-shadow: 0 0 30px rgba(82,255,168,0.18);
  font-weight: 850;
}

.grid { display: grid; gap: 1rem; margin-top: 1rem; }
.main-grid { grid-template-columns: minmax(0, 1.08fr) minmax(24rem, 0.92fr); }
.lower-grid { grid-template-columns: minmax(0, 0.9fr) minmax(24rem, 1.1fr); }
.map-card,
.pop-card,
.chart-card,
.controls-card { padding: 1rem; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.section-heading.compact { align-items: flex-start; }
.segmented {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.24rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
}
.segmented button { padding: 0.55rem 0.82rem; border: 0; }
.segmented button[aria-pressed="true"] { background: rgba(255,45,85,0.24); color: #fff; }

#map { height: clamp(27rem, 55vh, 39rem); border-radius: 1.25rem; overflow: hidden; border: 1px solid var(--border); background: #0d1329; }
.map-footer { display: flex; justify-content: space-between; gap: 0.75rem; color: var(--muted); font-size: 0.9rem; margin-top: 0.75rem; }
.leaflet-container { background: #070b18; font: inherit; }
.leaflet-tile { filter: brightness(0.52) invert(1) contrast(1.22) saturate(0.55) hue-rotate(170deg); }
.leaflet-control-attribution { background: rgba(8,12,28,0.78) !important; color: #b9c4e4 !important; }
.leaflet-control-attribution a { color: var(--cyan) !important; }
.anchor-marker { width: 1rem; height: 1rem; border-radius: 50%; background: #fff; box-shadow: 0 0 0 0.5rem rgba(56,232,255,0.2), 0 0 28px rgba(56,232,255,0.85); }
.pop-marker { display: grid; place-items: center; }
.pop-marker span {
  display: grid;
  place-items: center;
  min-width: 2.35rem;
  height: 2rem;
  padding: 0 0.35rem;
  border: 1px solid rgba(255,255,255,0.42);
  border-radius: 999px;
  background: rgba(255,45,85,0.88);
  color: white;
  font-weight: 950;
  font-size: 0.72rem;
  box-shadow: 0 0 24px rgba(255,45,85,0.45);
}
.leaflet-interactive.halo-circle { stroke: #38e8ff; stroke-width: 2; stroke-opacity: 0.88; fill: #38e8ff; fill-opacity: 0.08; filter: drop-shadow(0 0 12px rgba(56,232,255,0.75)); }
.leaflet-interactive.week-circle { stroke: #ff2d55; stroke-width: 1.4; stroke-opacity: 0.42; fill: transparent; stroke-dasharray: 4 7; }
.leaflet-interactive.pop-line { stroke: #ffffff; stroke-width: 1.2; stroke-opacity: 0.34; stroke-dasharray: 5 8; }

.progress-hero { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; margin: 0.75rem 0 1rem; }
.progress-ring {
  --pct: 0;
  width: 7.5rem;
  height: 7.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(9,12,28,1) 0 58%, transparent 60%),
    conic-gradient(var(--green) calc(var(--pct) * 1%), rgba(255,255,255,0.12) 0);
  box-shadow: inset 0 0 24px rgba(255,255,255,0.08), 0 0 36px rgba(82,255,168,0.1);
}
.progress-ring span { font-weight: 950; font-size: 1.25rem; }
.big-line { margin-bottom: 0.35rem; font-weight: 850; font-size: 1.15rem; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 1rem; }
table { width: 100%; border-collapse: collapse; min-width: 31rem; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.08); }
th { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; }
td { color: #dde7ff; font-size: 0.92rem; }
tr:last-child td { border-bottom: 0; }
.pop-code { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 900; }
.pop-code span { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--fastly); box-shadow: 0 0 12px rgba(255,45,85,0.7); }
.mini-progress { height: 0.55rem; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,0.09); margin-top: 0.3rem; }
.mini-progress span { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--green)); }

.bars { height: 22rem; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); align-items: end; gap: 0.65rem; padding-top: 1rem; }
.day-button {
  display: grid;
  align-content: end;
  gap: 0.55rem;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 1rem;
  background: transparent;
  box-shadow: none;
  color: var(--text);
}
.day-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: none; }
.day-button[aria-pressed="true"] .bar-fill { box-shadow: 0 0 24px rgba(255,45,85,0.45); background: linear-gradient(180deg, #fff, var(--fastly)); }
.bar-track { position: relative; height: 15rem; border-radius: 999px; background: rgba(255,255,255,0.07); overflow: hidden; border: 1px solid rgba(255,255,255,0.08); }
.bar-fill { position: absolute; left: 0; right: 0; bottom: 0; min-height: 0.35rem; border-radius: inherit; background: linear-gradient(180deg, var(--cyan), var(--violet)); transition: height 400ms cubic-bezier(.2,.8,.2,1); }
.bar-count { color: var(--text); font-weight: 850; font-variant-numeric: tabular-nums; }
.bar-date { color: var(--muted); font-size: 0.8rem; }
#weekTotal { color: var(--muted); font-size: 0.98rem; }

.stats { display: grid; gap: 0.65rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
dd { margin: 0.32rem 0 0; color: #e6eeff; overflow-wrap: anywhere; }
.secondary-actions { margin-top: 1rem; }
.event-details { margin-top: 1rem; border: 1px solid var(--border); border-radius: 1rem; padding: 0.8rem; background: rgba(255,255,255,0.04); }
.event-details summary { cursor: pointer; color: var(--muted); font-weight: 800; }
.event-log { list-style-position: inside; padding: 0; margin: 0.75rem 0 0; display: grid; gap: 0.5rem; max-height: 17rem; overflow: auto; }
.event-log li { color: var(--muted); border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 0.5rem; }
.event-log strong { color: var(--text); }

.ambient { position: fixed; pointer-events: none; z-index: 0; border-radius: 50%; filter: blur(38px); opacity: 0.6; }
.ambient-one { width: 20rem; height: 20rem; left: -8rem; top: 18rem; background: rgba(255,45,85,0.16); }
.ambient-two { width: 26rem; height: 26rem; right: -10rem; bottom: 1rem; background: rgba(56,232,255,0.12); }

@keyframes breathe { 0%, 100% { transform: scale(0.96); opacity: 0.72; } 50% { transform: scale(1.04); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(82,255,168,0.8); } 100% { box-shadow: 0 0 0 0.72rem rgba(82,255,168,0); } }

@media (max-width: 980px) {
  .hero-grid, .main-grid, .lower-grid { grid-template-columns: 1fr; }
  .hero-card, .halo-card { min-height: auto; }
  .halo-card { padding: 2rem 1rem; }
  .metric-grid, .stats { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 1rem, 1240px); }
  .topbar, .section-heading, .map-footer { align-items: stretch; flex-direction: column; }
  .privacy-pill { justify-content: center; }
  .bars { gap: 0.4rem; }
  .bar-track { height: 12rem; }
  .bar-count { font-size: 0.78rem; }
  .progress-hero { grid-template-columns: 1fr; }
}
