:root {
  /* "Parking blue" on a pale blue-gray page with white cards. Green, red and yellow stay
     reserved for status. */
  --bg: #f2f5fa;
  --card: #ffffff;
  --text: #0f1b2d;
  --muted: #5e6b7e;
  --hair: #e4e9f1;
  --track: #e1e8f5;
  --accent: #1f5bd0;
  --accent-2: #3a74e6;
  --accent-text: #ffffff;
  --up: #23a05a;
  --down: #e0483e;
  --warn: #8a6300;
  --warn-dot: #d9a400;
  --warn-bg: #fbf1d3;
  --error: #b42318;
  --error-bg: #fdecea;
  --offline: #98a2b3;
  --shadow: 0 1px 2px rgba(16, 35, 70, 0.05), 0 10px 30px rgba(16, 35, 70, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1320;
    --card: #161f30;
    --text: #e9eef7;
    --muted: #97a3b6;
    --hair: #243049;
    --track: #24314b;
    --accent: #6d9bff;
    --accent-2: #8fb2ff;
    --accent-text: #0b1530;
    --up: #3fbf75;
    --down: #f2665d;
    --warn: #ecc04a;
    --warn-dot: #ecc04a;
    --warn-bg: #33290f;
    --error: #ff8a80;
    --error-bg: #3a1d1d;
    --offline: #6b778a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 440px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 22px 22px 20px;
}

/* ---------- Hero card ---------- */
.hero { text-align: center; padding: 26px 22px 24px; }

h1 {
  margin: 0 0 18px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.count p { margin: 0; }

.eyebrow { font-size: 14px; font-weight: 600; color: var(--muted); }

.last-known {
  display: inline-block;
  margin-top: 8px !important;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--track);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.number {
  margin-top: 2px !important;
  font-size: clamp(88px, 28vw, 116px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.05em;
}
.count.stale .number { color: var(--offline); }

/* Capacity bar: "53% full · of 775 spots" */
.meter {
  height: 12px;
  margin-top: 22px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.6s ease;
}
.count.stale .meter-fill { background: var(--offline); }
.meter-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 10px !important;
  font-size: 14px;
  color: var(--muted);
}
.meter-labels strong { color: var(--text); font-weight: 700; }

/* Status: a colored dot next to "Updated 12 seconds ago" */
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px !important;
  font-size: 13px;
  color: var(--muted);
}
.status strong { color: var(--text); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status[data-tone="live"] .dot { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 20%, transparent); }
.status[data-tone="warn"] .dot { background: var(--warn-dot); }
.status[data-tone="offline"] .dot { background: var(--down); }

.status-sub { margin-top: 8px !important; font-size: 13px; color: var(--muted); }

.notes {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  text-align: left;
  font-size: 13px;
  color: var(--muted);
}
.notes li { padding: 9px 12px; border-radius: 12px; background: var(--bg); }
.notes li + li { margin-top: 6px; }

/* Error / warning banner (inside the hero card) */
.banner {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  background: var(--error-bg);
  color: var(--error);
}
.banner[data-tone="warn"] { background: var(--warn-bg); color: var(--warn); }

/* ---------- Timeline card ---------- */
.timeline-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.timeline h2 { margin: 0; font-size: 15px; font-weight: 700; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.key { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 5px; }
.key.up { background: var(--up); }
.key.down { background: var(--down); }

.bar-wrap { position: relative; margin-top: 14px; }
.bar {
  position: relative;
  height: 12px;
  border-radius: 6px;
  background: var(--track);
  overflow: hidden;
}
.seg { position: absolute; top: 0; bottom: 0; }
.seg + .seg { border-left: 2px solid var(--card); }
.seg.up { background: var(--up); }
.seg.down { background: var(--down); min-width: 2px; }
.now-marker {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 20px;
  margin-left: -1.5px;
  border-radius: 2px;
  background: var(--text);
}

.ticks { position: relative; height: 16px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.ticks span:first-child { transform: none; }
.ticks span:last-child { transform: translateX(-100%); }

.t-foot { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.t-foot strong { color: var(--text); font-weight: 600; }

/* ---------- Passcode form (inside the hero card) ---------- */
.login { display: grid; gap: 10px; margin-top: 4px; }
.login label { font-weight: 500; color: var(--muted); }
.login input {
  font: inherit;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--hair);
  background: var(--bg);
  color: var(--text);
}
.login input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.login button {
  font: inherit;
  font-weight: 600;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
}
.login button:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.login button:disabled { opacity: 0.6; cursor: default; }
.login-msg { margin: 0; min-height: 1.4em; color: var(--error); font-size: 14px; }

/* ---------- "Add to home screen" modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(10, 18, 32, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: modal-fade 0.2s ease-out;
}
body.modal-open { overflow: hidden; }

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(10, 18, 32, 0.35);
  padding: 28px 22px 20px;
  text-align: center;
  animation: modal-rise 0.25s ease-out;
}
.modal-icon { display: block; margin: 0 auto 14px; border-radius: 15px; }
.modal-card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.25; }
.modal-body { font-size: 15px; color: var(--muted); }
.modal-body:empty { display: none; }
.modal-body p { margin: 0 0 10px; }
.modal-body strong { color: var(--text); }

.steps {
  list-style: none;
  counter-reset: step;
  margin: 14px 0 4px;
  padding: 0;
  text-align: left;
}
.steps li {
  counter-increment: step;
  position: relative;
  padding: 12px 12px 12px 48px;
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
}
.steps li + li { margin-top: 8px; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 12px;
  top: 11px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 700;
}
.steps .hint { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.inline-icon { width: 20px; height: 20px; vertical-align: -4px; margin-left: 2px; color: var(--accent); }

.modal-actions { display: grid; gap: 8px; margin-top: 18px; }
.btn-primary,
.btn-secondary {
  font: inherit;
  font-weight: 600;
  padding: 13px;
  border-radius: 14px;
  border: 0;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-secondary { background: transparent; color: var(--muted); }
.btn-primary:focus-visible,
.btn-secondary:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-rise { from { opacity: 0; transform: translateY(12px); } }
@media (prefers-reduced-motion: reduce) {
  .modal, .modal-card { animation: none; }
}

[hidden] { display: none !important; }
