/* Shared look for all three versions: warm, simple, a little playful. */
:root {
  --bg: #fffaf2;
  --card: #ffffff;
  --ink: #2b2a33;
  --muted: #8a8794;
  --line: #eee5d7;
  --grid: #f2ece2;
  --wash: #fbf3e6;
  --max: #f76707;
  --min: #4c6ef5;
  --rain: #15aabf;
  --good: #2f9e44;
  --shadow: 0 1px 2px rgba(80, 50, 10, 0.05), 0 10px 30px rgba(80, 50, 10, 0.07);
  --radius: 18px;
  --head: "Nunito", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a22;
    --card: #24232d;
    --ink: #f1eff7;
    --muted: #a19eae;
    --line: #363441;
    --grid: #2f2d39;
    --wash: #2a2934;
    --max: #e8590c;
    --min: #5c7cfa;
    --rain: #1098ad;
    --good: #51cf66;
    --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; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font: 800 1.35rem/1.1 var(--head);
  letter-spacing: -0.01em;
}

.brand svg { flex: none; }
.brand em { font-style: normal; color: var(--max); }

.city-select {
  appearance: none;
  border: 1.5px solid var(--line);
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238a8794' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center;
  color: var(--ink);
  font: 700 1rem var(--head);
  padding: 9px 38px 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* Date bar */
.datebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 14px;
}

.datebar .label {
  min-width: 11em;
  text-align: center;
  font: 700 1.05rem var(--head);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pill {
  display: inline-block;
  font: 800 0.72rem/1 var(--head);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--max);
  color: #fff;
}

.round-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: 700 1.2rem/1 var(--head);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease;
}

.round-btn:hover:not(:disabled) { transform: scale(1.08); }
.round-btn:disabled { opacity: 0.3; cursor: default; }

/* Cards and type */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
}

.card h2 {
  font: 800 1.05rem var(--head);
  margin: 0 0 4px;
}

.card .sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 12px; }

.headline {
  font: 800 clamp(1.5rem, 5vw, 2.1rem)/1.15 var(--head);
  letter-spacing: -0.015em;
  margin: 4px 0 8px;
  text-wrap: balance;
}

.muted { color: var(--muted); }

.empty {
  text-align: center;
  padding: 48px 20px;
}

.empty .big { font-size: 3rem; line-height: 1; margin-bottom: 12px; }
.empty p { font: 700 1.15rem var(--head); margin: 0 0 6px; }

main { transition: opacity 0.2s ease; }
main.loading { opacity: 0.45; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart text { fill: var(--muted); font: 12px var(--body); font-variant-numeric: tabular-nums; }
.chart .grid line { stroke: var(--grid); }
.chart .axis path { display: none; }
.chart .axis line { display: none; }

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 8px;
}

.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend .swatch.dashed { background: repeating-linear-gradient(90deg, var(--ink) 0 4px, transparent 4px 7px) !important; opacity: 0.6; }
.legend .swatch.bar { width: 8px; height: 12px; border-radius: 3px; }

.pulse { animation: pulse 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes pulse { 50% { transform: scale(1.8); opacity: 0.35; } }

/* Tooltip */
.tooltip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  background: var(--ink);
  color: var(--bg);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.85rem;
  line-height: 1.4;
  min-width: 150px;
  max-width: 240px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.tooltip.show { opacity: 1; transform: none; }
.tooltip .t-title { font: 800 0.9rem var(--head); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.tooltip .t-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.tooltip .t-label { opacity: 0.7; }
.tooltip .t-note { opacity: 0.7; font-style: italic; margin-top: 4px; }

/* Footer */
.foot {
  margin-top: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.foot nav { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.foot nav a {
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  font: 700 0.85rem var(--head);
}
.foot nav a[aria-current] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

:focus-visible { outline: 3px solid var(--min); outline-offset: 2px; border-radius: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
.chart [tabindex]:focus { outline: none; }
