/* ---------- Design tokens ---------- */
:root {
  --bg: #eef3f8;
  --bg-grad-a: #dce9f7;
  --bg-grad-b: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f5f8fc;
  --text: #10192b;
  --text-dim: #5b6b84;
  --text-faint: #8b97a8;
  --border: #dfe6ef;
  --accent: #2e7dd6;
  --accent-2: #17a3c4;
  --rain-light: #6fd0ff;
  --rain-mod: #2e9bff;
  --rain-heavy: #6a5bff;
  --shadow: 0 1px 2px rgba(20,30,50,.05), 0 8px 24px rgba(20,30,50,.06);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --header-h: 60px;
  --tabs-h: 46px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-grad-a: #101b30;
    --bg-grad-b: #0b1220;
    --surface: #131d30;
    --surface-2: #182238;
    --text: #eef2f8;
    --text-dim: #a8b4c7;
    --text-faint: #6d7a90;
    --border: #223047;
    --accent: #5b9dee;
    --accent-2: #4fc3de;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg-grad-a), var(--bg-grad-b) 60%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button { font: inherit; color: inherit; }

/* ---------- Header ---------- */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
}
.location-block { min-width: 0; }
.location-name {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 19px;
  font-weight: 650;
  cursor: pointer;
  max-width: 100%;
}
#locationText {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.location-name .chev { color: var(--text-faint); flex-shrink: 0; }
.updated-text { font-size: 12px; color: var(--text-faint); margin-top: 1px; }

.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.text-btn { width: auto; padding: 0 12px; border-radius: 18px; font-weight: 700; font-size: 13px; }
.icon-btn:active { transform: scale(0.96); }

/* ---------- Search panel (inline, non-blocking) ---------- */
.search-panel {
  margin: 0 16px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 10px;
}
.search-box { display: flex; align-items: center; gap: 8px; }
.search-box input {
  flex: 1;
  border: none;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  color: var(--text);
}
.search-box input:focus { outline: 2px solid var(--accent); }
.link-btn {
  background: none; border: none; color: var(--accent);
  font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.search-results { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
.search-results li {
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
}
.search-results li:hover, .search-results li:focus { background: var(--surface-2); }
.search-results .result-sub { color: var(--text-faint); font-size: 12px; }

/* ---------- Status banner ---------- */
.status-banner {
  margin: 0 16px 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.status-banner button {
  background: none; border: none; color: var(--accent); font-weight: 700; cursor: pointer; font-size: 13px;
}
.status-banner[hidden] { display: none; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 16px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: var(--tabs-h);
}
.tab-btn {
  flex: 1;
  border: none;
  background: none;
  border-radius: 999px;
  font-weight: 650;
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
}
.tab-btn.active { background: var(--accent); color: #fff; }

/* ---------- Main / panels ---------- */
main { flex: 1; padding: 0 16px 24px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
#tab-radar.active { display: flex; flex-direction: column; height: calc(100vh - var(--header-h) - var(--tabs-h) - 20px); min-height: 420px; }

.skeleton-block {
  height: 220px;
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Now card ---------- */
.now-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px 20px;
  text-align: center;
}
.now-icon svg { width: 84px; height: 84px; }
.now-temp { font-size: 64px; font-weight: 300; line-height: 1; margin-top: 4px; }
.now-temp .deg { font-size: 34px; vertical-align: top; font-weight: 300; }
.now-desc { font-size: 17px; font-weight: 600; margin-top: 2px; }
.now-sub { margin-top: 10px; font-size: 14px; color: var(--text-dim); display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.now-sub .dot { color: var(--text-faint); }

/* ---------- Hourly strip ---------- */
.hourly-strip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin-top: 14px;
  padding: 16px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
}
.hour-item {
  flex: 0 0 auto;
  width: 58px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.hour-label { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.hour-icon svg { width: 28px; height: 28px; }
.hour-temp { font-size: 14px; font-weight: 700; }
.hour-pop { font-size: 11px; color: var(--accent); min-height: 14px; }

/* ---------- Detail grid ---------- */
.detail-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 12px;
}
.detail-card .dc-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  font-weight: 700;
}
.detail-card .dc-value { font-size: 18px; font-weight: 700; margin-top: 4px; }
.detail-card .dc-sub { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

/* ---------- Ad slot ---------- */
.ad-slot {
  margin-top: 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.ad-slot.placeholder {
  min-height: 100px;
  border: 1px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- Radar ---------- */
.radar-map { flex: 1; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); min-height: 320px; }
.radar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.radar-controls input[type="range"] { flex: 1; }
.radar-play svg { color: var(--accent); }
.radar-time { font-size: 13px; font-weight: 700; width: 56px; text-align: right; color: var(--text-dim); }
.radar-legend {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
  flex-wrap: wrap;
}
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.legend-swatch.light { background: var(--rain-light); }
.legend-swatch.mod { background: var(--rain-mod); }
.legend-swatch.heavy { background: var(--rain-heavy); }
.radar-attrib { margin-left: auto; }
.radar-attrib a { color: var(--text-faint); }

/* ---------- Daily list ---------- */
.daily-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.day-row {
  width: 100%;
  display: grid;
  grid-template-columns: 84px 34px 40px 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
}
.day-row:last-child { border-bottom: none; }
.day-label { font-size: 14px; font-weight: 650; }
.day-icon svg { width: 26px; height: 26px; }
.day-pop { font-size: 12px; color: var(--accent); font-weight: 650; }
.day-range { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.day-low { width: 26px; text-align: right; }
.day-high { width: 26px; font-weight: 700; color: var(--text); }
.range-bar { flex: 1; height: 4px; background: var(--surface-2); border-radius: 2px; position: relative; }
.range-fill { position: absolute; height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.day-detail {
  padding: 0 14px 14px;
  font-size: 13px;
  color: var(--text-dim);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 16px;
  border-bottom: 1px solid var(--border);
}
.day-detail div strong { color: var(--text); }
.day-detail[hidden] { display: none; }

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  padding: 16px 16px 28px;
}
.app-footer a { color: var(--text-faint); }
.app-footer .sep { margin: 0 6px; }

/* ---------- Leaflet tweaks ---------- */
.leaflet-control-attribution { font-size: 10px; }

@media (min-width: 700px) {
  .now-temp { font-size: 76px; }
  .day-detail { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Static legal/info pages ---------- */
.legal {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 60px;
  line-height: 1.6;
}
.legal a { color: var(--accent); }
.legal h1 { font-size: 26px; margin-bottom: 4px; }
.legal h2 { font-size: 17px; margin-top: 28px; }
.legal .back-link { display: inline-block; margin-bottom: 20px; font-size: 14px; color: var(--text-dim); }
.legal .updated { color: var(--text-faint); font-size: 13px; margin-bottom: 24px; }
.legal p, .legal li { color: var(--text-dim); font-size: 15px; }
.legal ul { padding-left: 20px; }
