:root {
  --ink: #222222;
  --muted: #6a6a6a;
  --line: #dddddd;
  --paper: #ffffff;
  --wash: #f7f7f7;
  --green: #2f6b4f;
  --green-soft: #e7f2eb;
  --glass: rgba(255, 255, 255, 0.86);
  --shadow: 0 8px 28px rgba(34, 34, 34, 0.12);
  --radius: 16px;
  --side: 260px;
  --foot: calc(36px + env(safe-area-inset-bottom, 0px));
  --font: "Plus Jakarta Sans", Circular, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #e8ebe4;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); }

.app {
  display: flex;
  min-height: 100%;
  height: 100%;
  padding-bottom: var(--foot);
}

.side {
  width: var(--side);
  flex: 0 0 var(--side);
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 4;
  overflow: auto;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.side-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex: 0 0 44px;
}
.side-brand strong {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.side-brand span {
  color: var(--muted);
  font-size: 0.78rem;
}
.side-label {
  margin: 18px 4px 6px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.side-list { display: grid; gap: 2px; }
.side-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
}
.side-item:hover,
.side-item.is-on { background: var(--green-soft); }
.side-foot {
  margin-top: auto;
  padding-top: 16px;
  font-size: 0.75rem;
  color: var(--muted);
}
.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
}
.legal-nav a {
  color: var(--muted);
  text-decoration: none;
}
.legal-nav a:hover { color: var(--ink); }
.legal h2 { font-size: 1.05rem; margin: 1.35rem 0 0.4rem; }
.legal h3 { font-size: 0.92rem; margin: 1rem 0 0.35rem; }
.legal p, .legal li { font-size: 0.92rem; line-height: 1.45; }

.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.stage-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.28) 0%, rgba(255,255,255,0.08) 36%, rgba(247,247,242,0.55) 100%),
    url("/media/assets/region.png") center 42% / cover no-repeat;
  pointer-events: none;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 0;
  flex-wrap: wrap;
}
.topbar-logo {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  flex: 0 0 32px;
}
.topbar span#place-label {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--glass);
  box-shadow: var(--shadow);
}
.menu, .map-toggle, .about-link {
  border: 0;
  background: var(--glass);
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.menu {
  display: none;
  width: 44px;
  height: 44px;
  place-items: center;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.about-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  min-height: 40px;
  font-size: 0.85rem;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}
.map-toggle {
  display: none;
  align-items: center;
  padding: 8px 14px;
  min-height: 40px;
  font-size: 0.85rem;
  font-weight: 600;
}

.stage-grid {
  position: relative;
  z-index: 1;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 32%);
  gap: 20px;
  padding: 20px 20px 12px;
  min-height: 0;
  align-items: stretch;
}
.primary {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.catalog {
  background: var(--glass);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.catalog-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.catalog-head h1 {
  width: 100%;
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.catalog-head span { font-size: 0.78rem; color: var(--muted); }
.badge {
  display: inline-block;
  margin: 0 0 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.catalog-list {
  overflow: auto;
  min-height: 8rem;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  background: #fff;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin: 12px 0 8px;
}
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; flex: 1 1 140px; }
.filters input, .filters select, .filters button {
  font: inherit;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  width: 100%;
}
.filters button {
  background: var(--green);
  color: #fff;
  border: 0;
  cursor: pointer;
  flex: 0 0 auto;
  width: auto;
  padding-inline: 18px;
}

.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.card {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: stretch;
  background: var(--paper);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  min-height: 112px;
}
.card-media { display: block; min-width: 0; }
.card-media img, .hero { width: 100%; height: 112px; object-fit: cover; display: block; }
.card-body {
  padding: 8px 12px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.card h2 { margin: 0; font-size: 0.98rem; line-height: 1.2; }
.card h2 a { color: inherit; text-decoration: none; }
.hero { height: 240px; border-radius: 12px; }
.detail { background: var(--paper); padding: 20px; border-radius: 12px; overflow: auto; }
.kicker { text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.75rem; color: var(--muted); }
.empty { background: var(--paper); padding: 20px; border-radius: 12px; }
.count, .meta, .src, .org, .credit, .why { color: var(--muted); font-size: 0.8rem; margin: 0; }
.why {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.credit { margin: 6px 0 12px; font-size: 0.75rem; }
.card .src, .card .org { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aside { margin: 16px 0 8px; padding: 12px 14px; background: var(--wash); border-radius: 10px; }
.aside h2 { margin: 0 0 6px; font-size: 0.95rem; }
.aside-note, .aside-facts, .aside-gaps { margin: 0; font-size: 0.85rem; color: var(--muted); }
.aside-note { margin-bottom: 8px; }
.aside-facts, .aside-gaps { padding-left: 1.1em; display: grid; gap: 6px; }
.aside-facts { color: var(--ink); }
.aside-facts a { margin-left: 0.35em; font-size: 0.8rem; }
.aside-gaps { margin-top: 8px; }

.rail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - var(--foot) - 72px);
  align-self: stretch;
  overflow: auto;
}
.map-card {
  background: var(--glass);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: none;
}
.map-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 12px 14px 8px;
}
.map-head span { color: var(--muted); font-size: 0.75rem; }
#map {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  min-height: 220px;
  max-height: 320px;
  flex: none;
  background: #dce6d8;
}
.map-note {
  margin: 0;
  padding: 8px 14px 12px;
  font-size: 0.75rem;
  color: var(--muted);
}
.leaflet-container {
  font-family: var(--font);
  background: #dce6d8;
  height: 100% !important;
}
.pin-label {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  white-space: nowrap;
}
.pin-label.is-on { background: var(--green); color: #fff; border-color: var(--green); }
.pin-label--hub { font-size: 11px; font-weight: 700; }
.pin-label--place { font-size: 9px; padding: 2px 6px; background: rgba(255,255,255,0.92); }
.event-pin {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  background: var(--green);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.28);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}
.map-evs { display: grid; gap: 4px; min-width: 12rem; }
.map-ev {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 6px 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  color: var(--green);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(34, 34, 34, 0.28);
  z-index: 8;
}

.site-foot {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 8;
  min-height: var(--foot);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 8px 16px max(8px, env(safe-area-inset-bottom, 0px));
  font-size: 0.7rem;
  line-height: 1.2;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.site-foot-brand {
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45em;
  min-width: 0;
}
.site-foot-brand strong { color: var(--ink); font-weight: 700; }
.site-foot-sep { opacity: 0.45; }
.site-foot-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-left: auto;
}
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--ink); }

@media (max-width: 1100px) {
  .stage-grid { grid-template-columns: minmax(0, 1fr) minmax(240px, 30%); }
}

@media (max-width: 980px) {
  .stage-grid { grid-template-columns: 1fr; }
  .rail {
    display: none;
    position: static;
    max-height: none;
  }
  .rail.is-open { display: flex; }
  .map-toggle { display: inline-flex; }
  #map { min-height: 220px; max-height: 280px; height: auto; flex: none; }
  .catalog { overflow: auto; }
}

@media (max-width: 820px) {
  .side {
    position: fixed;
    inset: 0 auto var(--foot) 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
    z-index: 9;
    height: auto;
  }
  .side.is-open { transform: none; }
  .menu { display: grid; }
  .topbar-logo { display: block; }
  .topbar { padding: 12px 12px 0; }
  .stage-grid { padding: 14px 12px 12px; }
  .catalog { padding: 14px 14px 12px; }
}

@media (max-width: 720px) {
  :root { --foot: calc(58px + env(safe-area-inset-bottom, 0px)); }
  .site-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 12px max(8px, env(safe-area-inset-bottom, 0px));
  }
  .site-foot-links { margin-left: 0; }
}

@media (max-width: 640px) {
  .card { grid-template-columns: 1fr; min-height: 0; }
  .card-media img { height: 112px; }
  .hero { height: 180px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters button { width: 100%; }
  .detail { padding: 14px; }
  .topbar span#place-label { font-size: 0.82rem; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-cards .card { grid-template-columns: 1fr; }
}

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

.side-list-more { max-height: none; }

.profile-card {
  background: var(--glass);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.profile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.profile-card p { margin: 6px 0 0; font-size: 0.82rem; color: var(--muted); }
.profile-open {
  margin-top: 10px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--green-soft);
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 40px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.llm-dot {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat {
  background: var(--glass);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: none;
}
#chat-thread {
  max-height: 200px;
  overflow: auto;
}
.chat-lede, .explain { margin: 0; font-size: 0.85rem; color: var(--muted); }
.explain { color: var(--ink); }
.starters, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { border-color: var(--ink); }
.ask {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 6px 6px 12px;
}
.ask textarea {
  flex: 1;
  border: 0;
  resize: none;
  min-height: 36px;
  max-height: 88px;
  padding: 8px 0;
  background: transparent;
  outline: none;
}
.send {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #222;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: 0 0 40px;
}
.send:hover { background: var(--green); }
.hint { margin: 0; font-size: 0.72rem; color: var(--muted); }
.chat-orgs { margin: 8px 0; padding-left: 1.1rem; }
.chat-cards { margin-top: 8px; }
.chat-cards .card { grid-template-columns: 72px 1fr; }
.chat-cards .card-media img { height: 72px; }

.profile-dialog {
  width: min(28rem, calc(100vw - 1.5rem));
  max-height: min(90vh, 40rem);
  overflow: auto;
  border: 0;
  border-radius: 18px;
  padding: 18px 18px 14px;
  box-shadow: var(--shadow);
  background: var(--paper);
}
.profile-dialog::backdrop { background: rgba(34,34,34,0.38); }
.profile-dialog h2 { margin: 0 0 6px; font-size: 1.35rem; letter-spacing: -0.03em; }
.profile-dialog-lede { margin: 0 0 14px; font-size: 0.85rem; color: var(--muted); }
.profile-dialog fieldset { border: 0; margin: 0 0 12px; padding: 0; }
.profile-dialog legend {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.profile-picks, .profile-checks { display: flex; flex-wrap: wrap; gap: 6px; }
.profile-picks label, .profile-checks label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.profile-picks label:has(input:checked),
.profile-checks label:has(input:checked) {
  background: #222;
  color: #fff;
  border-color: #222;
}
.profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.profile-skip, .profile-save {
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  font-weight: 600;
  cursor: pointer;
}
.profile-skip { border: 1px solid var(--line); background: transparent; }
.profile-save { border: 0; background: #222; color: #fff; }
.cov {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 600;
  vertical-align: middle;
}
.cov-on { background: var(--green-soft); color: var(--green); }
.cov-mid { background: #f3efe2; color: #7a5c12; }
.cov-off { background: #eee; color: var(--muted); }
.place-combo { position: relative; display: grid; gap: 8px; }
.place-combo input[type="search"] {
  width: 100%;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}
.geo-btn {
  justify-self: start;
  border: 1px solid var(--line);
  background: var(--green-soft);
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 40px;
  font-weight: 600;
  cursor: pointer;
}
.geo-hint { margin: 0; font-size: 0.78rem; color: var(--muted); }
.center-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  max-height: 11rem;
  overflow: auto;
  position: absolute;
  left: 0;
  right: 0;
  top: 48px;
  z-index: 4;
  box-shadow: var(--shadow);
}
.center-list button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.center-list button:hover { background: var(--green-soft); }
.radius-row {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}
.radius-row input[type="range"] { width: 100%; accent-color: var(--green); }
.sbh-line { color: var(--green); }
