:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #f8f6f1;
  --text: #1d2a22;
  --muted: #5d6b62;
  --border: #e2ddd2;
  --brand: #1f5a3d;
  --brand-2: #2f7a53;
  --accent: #e0a526;
  --danger: #b3261e;
  --warn-bg: #fff4d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121714;
    --surface: #1b221e;
    --surface-2: #222b26;
    --text: #e6ece8;
    --muted: #9fb0a5;
    --border: #2e3a33;
    --brand: #3f9a6b;
    --brand-2: #57b383;
    --warn-bg: #3a3218;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--brand-2); }
h1, h2, h3 { margin: 0; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; font-weight: 400; }
.eyebrow { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  background: var(--brand);
  color: #fff;
  padding: 10px 16px calc(10px);
  padding-top: max(10px, env(safe-area-inset-top));
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
@media (prefers-color-scheme: dark) { .topbar { background: #173f2b; } }
.topbar-inner { max-width: 1280px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.brand { font-size: 1.25rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap; }
.search { flex: 1 1 420px; display: flex; gap: 6px; min-width: 0; }
.search input {
  flex: 1; min-width: 0;
  padding: 10px 12px; border-radius: 10px; border: 0;
  font-size: 16px; background: #fff; color: #1d2a22;
}

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 9px 14px; border-radius: 10px; font-size: .95rem;
  cursor: pointer; white-space: nowrap; font-weight: 600; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover:not(:disabled) { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1d2a22; }
.btn-ghost { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.35); color: #fff; }
.btn-block { width: 100%; margin-top: 12px; }
.btn-sm { padding: 6px 10px; font-size: .82rem; border-radius: 8px; }
.link-btn { background: none; border: 0; color: var(--brand-2); font-weight: 600; cursor: pointer; padding: 4px 6px; font-size: .88rem; }

/* Layout */
.wrap { max-width: 1280px; margin: 0 auto; padding: 12px 16px 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.layout {
  display: grid; gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "weather" "map" "filters" "list";
}
.area-weather { grid-area: weather; }
.area-map { grid-area: map; }
.area-filters { grid-area: filters; }
.area-list { grid-area: list; }
@media (min-width: 960px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-areas: "weather map" "filters map" "list map";
    grid-template-rows: auto auto 1fr;
    align-items: start;
  }
  .area-map { position: sticky; top: 84px; align-self: start; }
  #map { height: calc(100vh - 110px) !important; min-height: 480px; }
}

.location-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px; margin-bottom: 12px; }
.loc-actions { display: flex; gap: 8px; flex: none; }
.loc-text { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; }
.loc-text strong { font-size: 1.05rem; overflow-wrap: anywhere; }

.status {
  margin-bottom: 12px; padding: 10px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: .92rem;
  display: flex; align-items: center; gap: 10px;
}
.status.error { background: #fde8e6; border-color: #f2b8b3; color: #7a1c15; }
.status.warn { background: var(--warn-bg); border-color: #ecd38a; }
@media (prefers-color-scheme: dark) { .status.error { background: #3b1a18; border-color: #6b2b26; color: #ffb4ab; } }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--brand-2); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Recent */
.recent { margin-bottom: 12px; }
.recent-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.recent-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.recent-chip {
  flex: none; display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: .86rem;
}
.recent-chip.active { border-color: var(--brand-2); box-shadow: inset 0 0 0 1px var(--brand-2); }
.recent-chip button { background: none; border: 0; color: var(--text); cursor: pointer; padding: 6px 4px 6px 12px; font-size: .86rem; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-chip button.x { padding: 6px 10px 6px 4px; color: var(--muted); }

/* Weather */
.weather-now { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.weather-icon { font-size: 2.6rem; line-height: 1; }
.weather-temp { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.weather-meta { font-size: .88rem; color: var(--muted); }
.weather-meta strong { color: var(--text); font-size: 1rem; display: block; }
.forecast { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.fday { text-align: center; background: var(--surface-2); border-radius: 10px; padding: 6px 2px; font-size: .78rem; }
.fday .fi { font-size: 1.3rem; display: block; }
.fday b { font-size: .85rem; }
.alerts { margin-top: 10px; display: grid; gap: 6px; }
.alert { background: #fde8e6; color: #7a1c15; border-radius: 8px; padding: 6px 10px; font-size: .85rem; font-weight: 600; }
@media (prefers-color-scheme: dark) { .alert { background: #3b1a18; color: #ffb4ab; } }

/* Map */
.mapcard { padding: 0; overflow: hidden; }
#map { height: 52vh; min-height: 300px; width: 100%; background: var(--surface-2); }
.home-pin { line-height: 0; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); }
.poi-pin span {
  display: block; width: 16px; height: 16px; border-radius: 50%;
  background: var(--c); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.45);
}
.leaflet-popup-content { margin: 12px 14px; font-size: .88rem; line-height: 1.4; }
.leaflet-popup-content h3 { font-size: 1rem; margin: 2px 0 4px; }
.popup-type { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.popup-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.popup-actions a { color: #fff !important; background: #2f7a53; padding: 5px 9px; border-radius: 7px; text-decoration: none; font-weight: 600; font-size: .8rem; }

/* Filters */
.filters-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--c); background: transparent; color: var(--text);
  border-radius: 999px; padding: 5px 10px; font-size: .84rem; cursor: pointer; font-weight: 600;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.chip .n { color: var(--muted); font-weight: 500; }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 16%, transparent); }
.chip[aria-pressed="false"] { opacity: .45; border-style: dashed; }
.filter-row { display: flex; gap: 8px; margin-top: 12px; }
.filter-row input, .filter-row select {
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 16px;
}
.filter-row input { flex: 1; min-width: 0; }

/* List */
.listcard h2 { margin-bottom: 10px; }
.poi-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.poi-list .empty { color: var(--muted); padding: 10px 2px; }
.poi {
  border: 1px solid var(--border); border-left: 5px solid var(--c);
  border-radius: 12px; padding: 10px 12px; background: var(--surface);
}
.poi-head { display: flex; align-items: center; gap: 8px; font-size: .78rem; }
.poi-type { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--c); }
@media (prefers-color-scheme: dark) { .poi-type { filter: brightness(1.5); } }
.poi-type .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.poi-dist { margin-left: auto; font-weight: 700; background: var(--surface-2); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.poi h3 { font-size: 1.02rem; margin: 4px 0 2px; overflow-wrap: anywhere; }
.poi-desc { margin: 0; font-size: .88rem; color: var(--muted); }
.poi-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.footer { text-align: center; font-size: .78rem; color: var(--muted); padding: 8px 16px 28px; padding-bottom: max(28px, env(safe-area-inset-bottom)); }

@media (max-width: 520px) {
  .hide-xs { display: none; }
  .brand { font-size: 1.1rem; }
  .search { flex-basis: 100%; }
  .forecast { gap: 4px; }
  .fday { font-size: .72rem; }
}
