:root {
  --ground: #14171b;
  --card: #1c2025;
  --line: #2a2f36;
  --text: #e6e9ed;
  --muted: #8d96a1;
  --faint: #5d6671;
  --accent: #6fb3ff;
  --ok: #3fb27f;
  --warn: #e0b84f;
  --bad: #ef5350;
  --radar: #5aa2ff;
  --piaf: rgba(90, 162, 255, 0.55);
  --model: rgba(150, 170, 200, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

button, select, input { font: inherit; color: inherit; }

button {
  background: #262b32;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}

button:active { background: #30363e; }

/* ------------------------------------------------------------------ sign-in */

/* Near the top, so the phone keyboard does not cover the fields. */
.login {
  display: grid;
  justify-items: center;
  padding: calc(10vh + env(safe-area-inset-top)) 16px 24px;
}

.login form {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.login h1 { margin: 0 0 8px; font-size: 24px; font-weight: 600; }
.login img { margin: 0 auto; }

.login label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  color: var(--muted);
  font-size: 13px;
}

.login input {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
}

.login button[type=submit] {
  background: var(--accent);
  color: #08121e;
  border: 0;
  padding: 11px;
  font-weight: 600;
}

.login .error { color: var(--bad); min-height: 1.4em; margin: 0; }

/* ------------------------------------------------------------------ page */

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 0 calc(24px + env(safe-area-inset-bottom));
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(20, 23, 27, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.top h1 { margin: 0; font-size: 19px; font-weight: 600; }
.top select { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.spacer { flex: 1; }

.health {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.health.ok { background: var(--ok); }
.health.bad { background: var(--bad); box-shadow: 0 0 0 4px rgba(239, 83, 80, 0.25); }

.icon-button { border: 0; background: none; font-size: 22px; padding: 0 4px; line-height: 1; }

.menu-panel {
  position: absolute;
  right: 12px;
  top: calc(100% + 4px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.menu-panel span { color: var(--muted); font-size: 13px; }

.banner {
  margin: 10px 16px 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(239, 83, 80, 0.16);
  border: 1px solid rgba(239, 83, 80, 0.5);
  color: #ffb4b2;
  font-size: 14px;
}

main { display: flex; flex-direction: column; gap: 12px; padding: 12px 10px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 12px 14px;
  min-width: 0;
}

.card h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.card h2 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.stamp { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 13px; }
.stamp.forecast { color: var(--warn); }
.stamp.bad { color: var(--bad); }

canvas { display: block; width: 100%; touch-action: pan-y; }

/* ------------------------------------------------------------------ now */

.now { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; align-items: center; }
.now .temp { font-size: 46px; font-weight: 300; line-height: 1; letter-spacing: -1px; }
.now .temp small { font-size: 20px; color: var(--muted); }
.now .where { color: var(--muted); font-size: 12px; grid-column: 1; }
.now dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; grid-row: 1 / span 2; grid-column: 2; }
.now dt { color: var(--muted); font-size: 13px; }
.now dd { margin: 0; font-size: 14px; }
.now .age { grid-column: 1 / -1; margin-top: 8px; color: var(--faint); font-size: 12px; }
.now .age.bad, .bad-text { color: var(--bad); }

/* ------------------------------------------------------------------ rain */

.summary { margin: 0 0 8px; font-size: 16px; }
.summary.bad { color: var(--bad); }
.strip-wrap { position: relative; }
.strip-key { display: flex; gap: 14px; margin-top: 6px; color: var(--muted); font-size: 12px; }
.strip-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.key-radar { background: var(--radar); }
.key-piaf { background: var(--piaf); }
.key-model { background: var(--model); }

/* ------------------------------------------------------------------ map */

.map-wrap { border-radius: 8px; overflow: hidden; background: #1a1d21; }
.map-controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.map-controls input[type=range] { flex: 1; accent-color: var(--accent); }
#play { width: 40px; padding: 6px 0; }

.ramp { display: flex; align-items: center; gap: 6px; margin-top: 8px; color: var(--muted); font-size: 11px; }
.ramp i { flex: 1; height: 6px; border-radius: 3px; }
.ramp em { font-style: normal; }

/* ------------------------------------------------------------------ ribbon */

.ribbon { display: grid; grid-template-columns: repeat(12, 1fr); text-align: center; }
.ribbon .cell svg { width: 26px; height: 26px; display: block; margin: 0 auto; }
.ribbon .cell span { display: block; color: var(--faint); font-size: 11px; margin-top: 2px; }

/* ------------------------------------------------------------------ charts */

.tabs { margin-left: auto; display: flex; gap: 4px; }
.tabs button { padding: 2px 10px; font-size: 13px; border-radius: 14px; background: none; }
.tabs button.on { background: #2f3640; border-color: #46505c; }

.chart { margin-top: 10px; }
.chart header { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.chart header b { color: var(--text); font-weight: 600; }
.chart .legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }
.chart .legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: 3px; }

/* ------------------------------------------------------------------ status */

.source { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.source:first-child { border-top: 0; }
.source .what::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; background: var(--ok); vertical-align: 1px; }
.source.bad .what::before { background: var(--bad); }
.source.warn .what::before { background: var(--warn); }
.source .when { color: var(--muted); text-align: right; }
.source.bad .when { color: var(--bad); }
.source .err { display: block; color: var(--bad); font-size: 12px; }

footer { color: var(--faint); font-size: 11px; text-align: center; padding: 8px 16px 0; }
