:root {
  --bg: #ffffff;
  --fg: #16202c;
  --muted: #5d6b7a;
  --line: #e2e8ef;
  --accent: #1f5fbf;
  --shadow: 0 6px 24px rgba(16, 28, 44, .18);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overscroll-behavior: none;
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: #4bb04b;
  -webkit-text-size-adjust: 100%;
}

#map {
  position: fixed;
  inset: 0;
  background: #4bb04b;
}

/* Leaflet's default image smoothing turns the plan to mush when zoomed in.
   Keep it crisp — the source is a raster of a printed map. */
.leaflet-image-layer { image-rendering: -webkit-optimize-contrast; }
.leaflet-container { background: #4bb04b; font: inherit; }
.leaflet-control-attribution { display: none; }

/* ---------- top bar ---------- */

#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 800;
  padding: calc(var(--safe-t) + 10px) 10px 0;
  pointer-events: none;
}

.searchwrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.searchwrap .ic {
  width: 20px; height: 20px;
  margin: 0 2px 0 12px;
  fill: var(--muted);
  flex: none;
}

#search {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  font-size: 16px; /* < 16px makes iOS Safari zoom on focus */
  padding: 13px 10px;
  color: var(--fg);
}

#search::-webkit-search-cancel-button { display: none; }

.clear {
  border: 0;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  padding: 0 14px 3px;
  cursor: pointer;
}

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 2px 2px;
  pointer-events: auto;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  border: 0;
  border-radius: 999px;
  padding: 7px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--chip, var(--accent)); color: #fff; }

/* ---------- results ---------- */

.results {
  position: fixed;
  z-index: 810;
  top: calc(var(--safe-t) + 58px);
  left: 10px; right: 10px;
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.results li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.results li:last-child { border-bottom: 0; }
.results li:active { background: #f2f6fb; }
.results .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.results .nm { font-weight: 600; }
.results .sub { margin-left: auto; color: var(--muted); font-size: 13px; }
.results .empty { color: var(--muted); justify-content: center; cursor: default; }

/* ---------- FAB ---------- */

.fab {
  position: fixed;
  z-index: 800;
  right: 12px;
  bottom: calc(var(--safe-b) + 20px);
  width: 50px; height: 50px;
  border: 0; border-radius: 50%;
  background: var(--bg);
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  cursor: pointer;
  transition: bottom .2s ease;
}
.fab svg { width: 24px; height: 24px; fill: var(--muted); }
.fab.on svg { fill: var(--accent); }
.fab.pending svg { fill: var(--muted); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
body.sheet-open .fab { bottom: calc(var(--safe-b) + 176px); }

/* ---------- bottom sheet ---------- */

.sheet {
  position: fixed;
  z-index: 820;
  left: 0; right: 0; bottom: 0;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -6px 24px rgba(16, 28, 44, .18);
  padding: 8px 18px calc(var(--safe-b) + 20px);
  animation: rise .18s ease-out;
}
@keyframes rise { from { transform: translateY(100%); } }

.grab {
  width: 38px; height: 4px;
  margin: 0 auto 10px;
  border-radius: 2px;
  background: var(--line);
}
.sheetClose {
  position: absolute;
  top: 10px; right: 10px;
  width: 34px; height: 34px;
  border: 0; border-radius: 50%;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 22px; line-height: 1;
  cursor: pointer;
}
.sheetCat {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 3px 9px;
}
.sheet h2 { margin: 8px 0 4px; font-size: 22px; }
.meta { margin: 0; color: var(--muted); }
.todo {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff6e0;
  color: #7a5600;
  font-size: 13px;
}

/* ---------- map overlays ---------- */

.poi-label {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  white-space: nowrap;
  pointer-events: none;
}

.me {
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .2);
}

.toast {
  position: fixed;
  z-index: 900;
  left: 50%;
  bottom: calc(var(--safe-b) + 84px);
  transform: translateX(-50%);
  max-width: 88vw;
  background: #16202c;
  color: #fff;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  text-align: center;
}
