:root {
  color-scheme: light;
  --page-plane: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page-plane: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page-plane: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
}

.app { display: flex; flex-direction: column; height: 100vh; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: #16202e;
  flex-shrink: 0;
}
.brand-mark svg { width: 26px; height: 26px; }
.brand h1 { font-size: 16px; margin: 0; line-height: 1.2; }
.brand .tagline { font-size: 12px; color: var(--text-secondary); margin: 2px 0 0; }
.date-pill {
  font-size: 12px; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px;
}

.toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; background: var(--surface-1);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.search-box { position: relative; flex: 1; min-width: 0; max-width: 420px; }
.search-box input {
  width: 100%; font-size: 13px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--page-plane); color: var(--text-primary);
}
.search-box input:focus { outline: 2px solid #2a78d6; outline-offset: -1px; }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); max-height: 320px; overflow-y: auto;
}
.search-result-row {
  display: flex; flex-direction: column; padding: 8px 12px; cursor: pointer;
}
.search-result-row:hover, .search-result-row.active { background: var(--gridline); }
.search-result-name { font-size: 13px; color: var(--text-primary); }
.search-result-city { font-size: 11px; color: var(--text-muted); }
.search-no-results { padding: 10px 12px; font-size: 12px; color: var(--text-muted); }

.main-nav {
  display: flex; gap: 4px; padding: 8px 20px;
  background: var(--surface-1); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.nav-link {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; padding: 7px 13px; border-radius: 999px;
  color: var(--text-secondary); text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--gridline); color: var(--text-primary); }
.nav-link.current { background: var(--gridline); color: var(--text-primary); font-weight: 600; }
.fav-count {
  font-size: 11px; color: var(--text-muted); background: var(--gridline);
  border-radius: 999px; padding: 1px 6px;
}

.view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.view[hidden] { display: none; }
.page-content { overflow-y: auto; padding: 24px 32px; max-width: 900px; width: 100%; margin: 0 auto; }
.back-link { display: inline-block; font-size: 13px; color: var(--text-secondary); text-decoration: none; margin-bottom: 16px; }
.back-link:hover { color: var(--text-primary); }

.layout { flex: 1; display: flex; min-height: 0; }
#map { flex: 1; min-width: 0; }

/* Recolor the OSM tiles for dark mode so the map doesn't clash with the dark
   chrome — same tiles, same OSM ToS, just a display-side CSS filter (the
   standard technique for this) rather than a different tile provider. Scoped
   to the tile pane only, so markers/popups keep their real colors. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) #map .leaflet-tile-pane {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
  }
}
:root[data-theme="dark"] #map .leaflet-tile-pane {
  filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.panel {
  width: 380px;
  flex-shrink: 0;
  background: var(--surface-1);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px;
}
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .panel { width: 100%; border-left: none; border-top: 1px solid var(--border); max-height: 50vh; }
}

.panel-empty { color: var(--text-secondary); font-size: 14px; padding-top: 40px; text-align: center; }

.panel-title-row { display: flex; align-items: center; gap: 8px; }
.panel-title h2 { margin: 0 0 2px; font-size: 20px; }
.loc-city { font-size: 13px; color: var(--text-muted); }
.fav-star {
  background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1;
  color: var(--gridline); padding: 0; margin-bottom: 2px; transition: color 0.15s ease;
}
.fav-star:hover { color: var(--text-muted); }
.fav-star.active { color: #eda100; }

.status-row { margin: 14px 0 20px; }
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border);
}
.status-badge .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-badge.good { color: var(--good); }
.status-badge.good .dot { background: var(--good); }
.status-badge.warning { color: #8a6200; }
.status-badge.warning .dot { background: var(--warning); }
.status-badge.serious { color: var(--serious); }
.status-badge.serious .dot { background: var(--serious); }
.status-badge.critical { color: var(--critical); }
.status-badge.critical .dot { background: var(--critical); }
.status-meta { font-size: 12px; color: var(--text-secondary); margin-top: 8px; line-height: 1.5; }

.report-card { margin-bottom: 22px; }
.report-card h3 { font-size: 13px; margin: 0 0 8px; color: var(--text-secondary); font-weight: 600; }
.report-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.report-btn {
  font-size: 12px; padding: 7px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--text-primary);
  cursor: pointer; transition: background 0.15s ease;
}
.report-btn:hover:not(:disabled) { background: var(--gridline); }
.report-btn:disabled { opacity: 0.5; cursor: default; }
.report-feedback { font-size: 12px; color: var(--text-secondary); margin-top: 8px; }

.chart-card { }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.chart-head h3 { font-size: 13px; margin: 0; color: var(--text-secondary); font-weight: 600; }
.legend-note { font-size: 11px; color: var(--text-muted); }

.chart-wrap { position: relative; }
.chart-wrap > .chart { width: 100%; height: auto; overflow: visible; }

.axis-label { font-size: 9px; fill: var(--text-muted); }
.event-dot { fill: var(--text-secondary); }
.crosshair { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2,2; }
.hover-dot { fill: var(--surface-1); stroke-width: 2; }
:root .hover-dot { stroke: #2a78d6; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .hover-dot { stroke: #3987e5; }
}
:root[data-theme="dark"] .hover-dot { stroke: #3987e5; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--page-plane);
  font-size: 11px;
  padding: 6px 9px;
  border-radius: 6px;
  transform: translate(-50%, -110%);
  white-space: nowrap;
  z-index: 5;
  line-height: 1.4;
}

.sr-table { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.leaflet-popup-content { font-family: system-ui, -apple-system, sans-serif; font-size: 13px; }

/* ─── Landmark deep-dive page ──────────────────────────────────────────────── */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.view-details-link { font-size: 12px; color: #2a78d6; text-decoration: none; }
.view-details-link:hover { text-decoration: underline; }

.section-heading { font-size: 15px; margin: 32px 0 10px; }
.section-heading:first-of-type { margin-top: 24px; }

.calendar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.calendar-month { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.calendar-month-title { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 0 0 8px; text-align: center; }
.calendar-dow-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 3px; }
.calendar-dow { font-size: 9px; color: var(--text-muted); text-align: center; }
.calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-day {
  aspect-ratio: 1; border-radius: 4px; display: grid; place-items: center;
  font-size: 9px; color: rgba(255,255,255,0.85); cursor: default;
}
.calendar-day.empty { visibility: hidden; }
.calendar-day.today { box-shadow: 0 0 0 2px #eda100 inset; }

.rank-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 640px) { .rank-lists { grid-template-columns: 1fr; } }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 0 0 8px; }
.rank-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.rank-row:last-child { border-bottom: none; }
.rank-date { color: var(--text-primary); }
.rank-dow { color: var(--text-muted); font-size: 11px; margin-left: 6px; }
.rank-tier { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.rank-tier .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ─── Favorites page ─────────────────────────────────────────────────────────── */
.favorites-empty { color: var(--text-secondary); font-size: 14px; text-align: center; padding: 60px 20px; }
.favorites-empty a { color: #2a78d6; }

.best-window-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.best-window-date { font-size: 14px; }
.best-window-dow { font-size: 12px; color: var(--text-muted); margin-left: 6px; }
.best-window-dots { display: flex; gap: 4px; }
.best-window-dots .dot { width: 10px; height: 10px; border-radius: 50%; }
.best-window-avg { font-size: 12px; color: var(--text-secondary); min-width: 90px; text-align: right; }

.fav-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 8px; }
.fav-card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; text-decoration: none; color: var(--text-primary); display: block;
  transition: border-color 0.15s ease;
}
.fav-card:hover { border-color: #2a78d6; }
.fav-card-name { font-size: 14px; font-weight: 600; margin: 0 0 2px; }
.fav-card-city { font-size: 12px; color: var(--text-muted); margin: 0 0 8px; }
