:root {
  --ink: #10271d;
  --muted: #58665f;
  --paper: rgba(255, 253, 247, 0.95);
  --line: rgba(16, 39, 29, 0.14);
  --green: #087a56;
  --green-dark: #04553e;
  --aqua: #39c4c7;
  --amber: #f2c56b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body, main, #map { width: 100%; height: 100%; margin: 0; }
body { min-width: 280px; overflow: hidden; background: #dfe7e1; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.skip-link:focus { transform: none; }

#map { position: fixed; inset: 0; }
.maplibregl-map { font: inherit; }
.maplibregl-ctrl-bottom-left { left: 12px; bottom: 52px; }
.maplibregl-ctrl-bottom-right { right: 390px; bottom: 48px; }
.maplibregl-ctrl-attrib { border-radius: 9px 0 0; }

.topbar {
  position: fixed;
  z-index: 10;
  top: 16px;
  left: 18px;
  right: 18px;
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 12px 8px 16px;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 18px;
  background: rgba(255,253,247,.88);
  box-shadow: 0 18px 45px rgba(10,32,23,.14);
  backdrop-filter: blur(18px) saturate(1.2);
}
.brand { display: inline-flex; align-items: center; }
.brand img { display: block; width: 166px; height: auto; }
.mode-switch {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(16,39,29,.08);
}
.mode-switch a, .mode-switch span {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}
.mode-switch [aria-current="page"] { background: var(--green); color: white; box-shadow: 0 7px 18px rgba(8,122,86,.22); }
.preview-badge {
  padding: 9px 13px;
  border-radius: 999px;
  background: #f8dfaa;
  color: #684613;
  font-size: .78rem;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.control-card, .story-deck, .context-drawer, .place-panel, .provider-note {
  position: fixed;
  z-index: 8;
  border: 1px solid rgba(255,255,255,.7);
  background: var(--paper);
  box-shadow: 0 20px 54px rgba(10,32,23,.18);
  backdrop-filter: blur(18px) saturate(1.15);
}
.control-card {
  top: 100px;
  left: 18px;
  width: min(430px, calc(100vw - 436px));
  padding: 22px;
  border-radius: 22px;
}
.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}
h1, h2, h3 { margin: 0; font-family: "Space Grotesk", Inter, system-ui, sans-serif; line-height: 1.06; }
h1 { font-size: clamp(1.65rem, 3vw, 2.55rem); letter-spacing: -.045em; }
h2 { margin-top: 12px; font-size: 1.65rem; letter-spacing: -.035em; }
h3 { font-size: 1.08rem; }
.intro { margin: 10px 0 18px; color: var(--muted); line-height: 1.45; }
label { display: block; margin-bottom: 7px; font-size: .86rem; font-weight: 800; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.search-row input {
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: white;
  color: var(--ink);
}
.search-row button, .quick-actions button {
  min-height: 48px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 800;
}
.search-row button { padding: 0 18px; background: var(--green); color: white; }
.quick-actions { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 10px; }
.quick-actions button { padding: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.8); color: var(--ink); }
.search-row button:hover, .search-row button:focus-visible { background: var(--green-dark); }
.quick-actions button:hover, .quick-actions button:focus-visible { border-color: var(--green); color: var(--green); }
.map-status { margin: 14px 0 0; color: var(--muted); font-size: .84rem; line-height: 1.35; }

.context-drawer {
  top: 100px;
  left: 466px;
  width: 360px;
  max-height: calc(100vh - 266px);
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0,1fr) auto;
  padding: 20px;
  border-radius: 22px;
}
.context-drawer[hidden] { display: none; }
.context-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.context-heading h2 { margin: 0; font-size: 1.28rem; }
.icon-button {
  width: 42px;
  height: 42px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}
.context-intro { margin: 10px 0 14px; color: var(--muted); font-size: .82rem; line-height: 1.4; }
.context-filters { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.context-filters button {
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.88);
  color: var(--ink);
  cursor: pointer;
  font-size: .78rem;
  font-weight: 800;
}
.context-filters button strong { margin-left: auto; font-size: .7rem; }
.context-filters button[aria-pressed="true"] { border-color: var(--green); background: #e7f4ed; box-shadow: inset 0 0 0 1px rgba(8,122,86,.18); }
.category-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(16,39,29,.12); }
.category-dot.school, .category-label.school { --category-color: #7a58a6; }
.category-dot.hospital, .category-label.hospital { --category-color: #c54848; }
.category-dot.museum, .category-label.museum { --category-color: #c77922; }
.category-dot.library, .category-label.library { --category-color: #2469a8; }
.category-dot { background: var(--category-color); }
.context-toolbar { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 7px; margin-top: 12px; }
.context-toolbar p { margin: 0; color: var(--muted); font-size: .73rem; line-height: 1.25; }
.context-toolbar button {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: .72rem;
  font-weight: 800;
}
.context-results { min-height: 0; overflow: auto; margin: 12px -5px 0; padding: 0 5px; list-style: none; }
.context-results:empty::before { content: "Select a category to add contextual pins and results."; display: block; padding: 18px 10px; border-radius: 12px; background: rgba(16,39,29,.04); color: var(--muted); font-size: .8rem; line-height: 1.4; }
.context-results li + li { margin-top: 6px; }
.context-results button {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.86);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.context-results button:hover, .context-results button:focus-visible { border-color: var(--green); }
.context-results button strong { font-size: .82rem; line-height: 1.25; }
.category-label { color: var(--category-color); font-size: .66rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.context-source { margin: 12px 0 0; padding-top: 11px; border-top: 1px solid var(--line); color: var(--muted); font-size: .66rem; line-height: 1.35; }
.context-popup-label { display: block; margin-bottom: 5px; color: #2469a8; font-size: .68rem; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.maplibregl-popup-content > div { display: grid; gap: 6px; }
.maplibregl-popup-content p { margin: 0; max-width: 240px; color: var(--muted); font-size: .76rem; line-height: 1.35; }
.maplibregl-popup-content a { color: var(--green-dark); font-size: .76rem; font-weight: 800; }

.story-deck {
  left: 470px;
  right: 390px;
  bottom: 74px;
  padding: 16px;
  border-radius: 20px;
  transition: transform .28s ease, box-shadow .28s ease;
}
.tour-playing .story-deck { box-shadow: 0 24px 70px rgba(5,52,37,.28), 0 0 0 1px rgba(57,196,199,.3); }
.context-open .story-deck { display: none; }
.story-heading { display: flex; align-items: center; gap: 18px; }
.story-copy { min-width: 0; flex: 1; }
.story-copy .eyebrow { margin-bottom: 4px; }
.story-copy h2 { margin: 0; font-size: 1.12rem; letter-spacing: -.02em; }
.story-copy > p:last-child { margin: 5px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.3; }
.tour-controls { display: grid; grid-template-columns: 42px auto 42px; gap: 6px; flex: none; }
.tour-controls button, .story-chapters button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.86);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}
.tour-controls button { min-height: 42px; border-radius: 12px; padding: 0 11px; }
.tour-controls #tour-play { min-width: 96px; border-color: transparent; background: var(--green); color: #fff; }
.tour-controls #tour-play[aria-pressed="true"] { background: #0c5d47; }
.story-chapters { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 7px; margin: 13px 0 0; padding: 0; list-style: none; }
.story-chapters li { position: relative; }
.story-chapters li::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: -2px;
  left: 9px;
  right: 9px;
  height: 3px;
  border-radius: 999px;
  background: transparent;
}
.story-chapters li.is-active::before { background: var(--aqua); }
.story-chapters button { width: 100%; min-height: 39px; padding: 5px 7px; border-radius: 10px; font-size: .7rem; }
.story-chapters button span { margin-right: 5px; color: var(--green); font-size: .63rem; letter-spacing: .05em; }
.story-chapters button[aria-pressed="true"] { border-color: rgba(8,122,86,.45); background: #e8f5ef; }

.place-panel {
  top: 100px;
  right: 18px;
  width: 354px;
  max-height: calc(100vh - 166px);
  overflow: auto;
  padding: 22px;
  border-radius: 22px;
  transition: box-shadow .35s ease, transform .35s ease;
}
.place-panel-toggle { display: none; }
.place-panel.evidence-spotlight { transform: translateY(-4px); box-shadow: 0 26px 72px rgba(8,122,86,.28), 0 0 0 2px rgba(57,196,199,.45); }
.panel-topline { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.state-badge, .freshness, .chips span, .services span {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 800;
}
.state-badge { padding: 7px 10px; background: #dff1e8; color: #07563e; }
.freshness { color: var(--muted); }
.address { margin: 8px 0 14px; color: var(--muted); line-height: 1.45; }
.chips, .services { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { padding: 6px 9px; background: #edf1ed; }
.services { margin-top: 14px; }
.services span { padding: 6px 9px; background: #e7f6f4; color: #075b5f; }
.facts { display: grid; grid-template-columns: 112px 1fr; gap: 8px 12px; margin: 17px 0 0; font-size: .86rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 750; }
.place-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 17px; }
.place-links a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(8,122,86,.28);
  border-radius: 11px;
  color: var(--green-dark);
  font-size: .84rem;
  font-weight: 800;
  text-decoration: none;
}
.route-gate { margin-top: 18px; padding: 16px; border-radius: 15px; background: #fff3d8; }
.route-gate .eyebrow { color: #8b5d12; }
.route-gate p:last-child { margin: 7px 0 0; color: #6d5b39; font-size: .86rem; line-height: 1.4; }

.provider-note {
  left: 18px;
  bottom: 16px;
  max-width: min(720px, calc(100vw - 420px));
  padding: 10px 13px;
  border-radius: 12px;
  color: #3e4c45;
  font-size: .72rem;
  line-height: 1.35;
}
.noscript { position: fixed; z-index: 20; inset: 120px 20px auto; padding: 20px; background: white; }

.reviewed-marker {
  width: 32px;
  height: 40px;
  border: 2px solid white;
  border-radius: 17px 17px 17px 4px;
  transform: rotate(-45deg);
  background: var(--green);
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
  cursor: pointer;
}
.reviewed-marker::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  top: 9px;
  left: 9px;
  background: white;
}
.reviewed-marker[aria-pressed="true"] { background: #ef8b37; transform: rotate(-45deg) scale(1.14); }

.context-map-marker {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  background: #52605a;
  box-shadow: 0 5px 14px rgba(0,0,0,.3);
  cursor: pointer;
}
.context-map-marker.school { background: #7a58a6; }
.context-map-marker.hospital { background: #c54848; }
.context-map-marker.museum { background: #c77922; }
.context-map-marker.library { background: #2469a8; }
.context-map-marker:hover, .context-map-marker:focus-visible { transform: scale(1.28); }

:focus-visible { outline: 3px solid var(--aqua); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media (min-width: 761px) and (max-width: 1200px) {
  .story-deck { left: 18px; right: 390px; bottom: 74px; }
  .context-drawer { left: 18px; width: 430px; }
  .story-copy > p:last-child { display: none; }
  .story-chapters button { font-size: 0; }
  .story-chapters button span { margin: 0; font-size: .72rem; }
}

@media (max-width: 760px) {
  .topbar { top: 8px; left: 8px; right: 8px; min-height: 58px; gap: 8px; padding: 7px 9px; border-radius: 15px; }
  .brand img { width: 116px; }
  .mode-switch { gap: 2px; padding: 3px; }
  .mode-switch a, .mode-switch span { min-height: 38px; padding: 0 11px; font-size: .82rem; }
  .preview-badge { display: none; }
  .control-card { top: 76px; left: 8px; right: 8px; width: auto; padding: 14px; border-radius: 16px; }
  .control-card .intro { display: none; }
  .control-card h1 { font-size: 1.2rem; }
  .control-card .eyebrow { margin-bottom: 4px; }
  .control-card label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .search-row { margin-top: 8px; }
  .quick-actions { display: none; }
  .quick-actions button { min-width: 0; min-height: 42px; font-size: .78rem; }
  .map-status { margin: 7px 0 0; font-size: .68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .context-drawer { top: 76px; left: 8px; right: 8px; bottom: calc(39vh + 8px); width: auto; max-height: none; padding: 15px; border-radius: 16px; }
  .context-heading h2 { font-size: 1.1rem; }
  .context-intro { margin: 7px 0 10px; }
  .context-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .context-results { margin-top: 9px; }
  .context-source { margin-top: 8px; }
  .story-deck { left: 8px; right: 8px; bottom: calc(39vh + 8px); padding: 8px 10px; border-radius: 15px; }
  .story-heading { gap: 8px; }
  .story-copy .eyebrow { font-size: .62rem; }
  .story-copy h2 { font-size: .96rem; }
  .story-copy > p:last-child { display: none; }
  .tour-controls { grid-template-columns: 36px auto 36px; gap: 4px; }
  .tour-controls button { min-height: 38px; padding: 0 8px; }
  .tour-controls #tour-play { min-width: 78px; font-size: .75rem; }
  .story-chapters { display: none; }
  .story-chapters button { min-height: 32px; padding: 4px; font-size: 0; }
  .story-chapters button span { margin: 0; font-size: .66rem; }
  .place-panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 42vh; padding: 0; border-radius: 17px; }
  .place-panel-toggle { display: flex; width: 100%; min-height: 52px; align-items: center; justify-content: space-between; padding: 0 17px; border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 850; cursor: pointer; }
  .place-panel-toggle span { transition: transform .2s ease; }
  .place-panel-toggle[aria-expanded="true"] span { transform: rotate(180deg); }
  .place-panel-body { display: none; padding: 0 16px 18px; overflow: auto; }
  .place-panel:has(.place-panel-toggle[aria-expanded="true"]) .place-panel-body { display: block; }
  .place-panel h2 { font-size: 1.35rem; }
  .address { margin-bottom: 10px; }
  .facts { grid-template-columns: 100px 1fr; }
  .provider-note { display: none; }
  .maplibregl-ctrl-bottom-left { bottom: 70px; }
  .maplibregl-ctrl-bottom-right { right: 8px; bottom: 70px; }
}

@media (max-width: 400px) {
  .brand img { width: 104px; }
  .mode-switch a, .mode-switch span { padding: 0 8px; }
  .search-row input { width: 100%; }
  .search-row button { padding: 0 13px; }
  .control-card h1 { font-size: 1.08rem; }
  .control-card { padding: 11px; }
  .search-row input, .search-row button { min-height: 40px; }
  .story-copy { display: none; }
  .story-heading { justify-content: center; }
  .tour-controls { width: 100%; grid-template-columns: 42px 1fr 42px; }
  .provider-note { display: none; }
  .story-deck { bottom: 68px; }
  .context-drawer { bottom: 68px; }
  .maplibregl-ctrl-bottom-left { bottom: 70px; }
  .maplibregl-ctrl-bottom-right { bottom: 70px; }
}
