:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #000000;
  --text: #000000;
  --muted: #555555;
  --accent: #000000;
  --accent-light: #f0f0f0;
  --govt: #000000;
  --ngo: #ffffff;
  --religious: #6b6b6b;
  --radius: 0;
  --tap: 44px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; color: inherit; border-radius: var(--radius); }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---- /locate layout ---- */
body.locate { overflow: hidden; }
.app { position: fixed; inset: 0; display: flex; }
#map { flex: 1; min-width: 0; background: #e8e8e8; }

.panel {
  width: 400px; max-width: 100%; height: 100%; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 500; overflow: hidden;
}
.handle { display: none; }

.search { display: flex; gap: 8px; padding: 12px 12px 8px; }
.search input {
  flex: 1; min-width: 0; height: var(--tap); padding: 0 12px;
  border: 1px solid var(--border); background: var(--bg); font-size: 16px; /* >=16px stops iOS zoom */
}
.btn {
  height: var(--tap); padding: 0 14px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 0.9rem; font-weight: 600; white-space: nowrap;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn:disabled { opacity: 0.6; cursor: wait; }

.chips { display: flex; gap: 6px; padding: 0 12px 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 12px; border: 1px solid var(--border);
  background: var(--bg); color: var(--muted); font-size: 0.8rem; display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"] { background: var(--accent); color: #fff; }
.sw { width: 10px; height: 10px; border: 1px solid var(--border); display: inline-block; }
.sw.Government { background: var(--govt); }
.chip[aria-pressed="true"] .sw.Government { border-color: #fff; }
.sw.NGO { background: var(--ngo); }
.sw.Religious { background: var(--religious); }

.status { padding: 4px 12px 8px; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--border); min-height: 30px; }
.status.error { color: var(--text); font-weight: 600; }

.list { list-style: none; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.card { padding: 12px; border-bottom: 1px solid #d0d0d0; cursor: pointer; }
.card:hover { background: var(--accent-light); }
.card.selected { background: var(--accent-light); box-shadow: inset 3px 0 0 var(--border); }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card h2 { font-size: 0.92rem; font-weight: 600; line-height: 1.3; }
.badge { font-size: 0.68rem; font-weight: 600; padding: 1px 7px; border: 1px solid var(--border); background: var(--accent-light); flex: none; }
.meta { font-size: 0.78rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.meta .dist { color: var(--text); font-weight: 600; }
.card-actions { margin-top: 8px; display: flex; gap: 8px; }
.card-actions a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--border); color: var(--text); font-size: 0.8rem; font-weight: 600; text-decoration: none;
}
.nopin { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.foot { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); font-size: 0.72rem; color: var(--muted); border-top: 1px solid var(--border); }

/* ---- map markers ---- */
.pin-wrap { background: none; border: 0; }
.pin { display: block; overflow: visible; transform-origin: 50% 96%; transition: transform 0.12s; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }
.pin-body { stroke: #000; stroke-width: 2; stroke-linejoin: round; }
.pin-label { font: 700 13px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; letter-spacing: -0.2px; }
.pin.Government .pin-body { fill: var(--govt); }
.pin.Government .pin-label { fill: #fff; }
.pin.NGO .pin-body { fill: var(--ngo); }
.pin.NGO .pin-label { fill: #000; }
.pin.Religious .pin-body { fill: var(--religious); }
.pin.Religious .pin-label { fill: #fff; }
.pin.sel { transform: scale(1.25); }
.leaflet-marker-icon:focus-visible .pin-body { stroke-width: 3; }
.me { width: 16px; height: 16px; border-radius: 50%; background: #000; border: 3px solid #fff; box-shadow: 0 0 0 1px #000; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { border-radius: 0; box-shadow: none; border: 1px solid #000; }
.leaflet-popup-content { margin: 10px 12px; font-size: 0.82rem; line-height: 1.4; }
.leaflet-popup-content strong { display: block; margin-bottom: 2px; }
.leaflet-container { font-family: inherit; }

/* ---- phones: map fills the screen, results live in a bottom sheet ---- */
@media (max-width: 720px) {
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; width: 100%; height: 88dvh;
    border-right: 0; border-top: 1px solid var(--border);
    transform: translateY(calc(100% - 214px)); transition: transform 0.25s ease; will-change: transform;
  }
  .panel[data-state="half"] { transform: translateY(48%); }
  .panel[data-state="full"] { transform: translateY(0); }
  .panel.dragging { transition: none; }
  .handle { display: flex; justify-content: center; align-items: center; height: 24px; flex: none; touch-action: none; cursor: grab; }
  .handle span { width: 40px; height: 4px; background: var(--border); display: block; }
  .status { border-bottom: 1px solid var(--border); }
  .leaflet-bottom { bottom: 222px; } /* keep attribution above the peeking sheet */
}
@media (prefers-reduced-motion: reduce) { .panel { transition: none; } }

/* keep the basemap in the black/white/grey palette */
.leaflet-tile-pane { filter: grayscale(1) contrast(1.05) brightness(1.03); }
