* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { height: 100vh; position: relative; overflow: hidden; }

#map { position: absolute; inset: 0; }
.maplibregl-canvas-container { mix-blend-mode: normal; }

[x-cloak] { display: none !important; }

/* ── Inline nav legend ── */
.nav-legend { position: relative; flex-shrink: 0; }
.nl-btn {
  display: flex; align-items: center; gap: 4px;
  background: rgba(248,249,250,0.85); border: 1px solid #c8c4d5;
  cursor: pointer; padding: 5px 10px; border-radius: 8px;
  transition: background 0.15s; font: inherit;
}
.nl-btn:hover { background: #f3f4f5; }
.nl-icon {
  font-size: 18px; color: #554bbc;
  font-variation-settings: "FILL" 0, "wght" 400;
}
.nl-label {
  font-size: 12px; font-weight: 600; color: #474553;
  white-space: nowrap; letter-spacing: 0.02em; max-width: 120px;
  overflow: hidden; text-overflow: ellipsis;
}
.nl-arrow { font-size: 10px; color: #787584; margin-left: 2px; }
.nl-drop {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: #fff; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(85,75,188,0.12), 0 2px 6px rgba(0,0,0,0.08);
  border: 1px solid #e1e3e4;
  padding: 8px; min-width: 220px; z-index: 70;
}
.nl-drop-title {
  font-size: 10px; font-weight: 600; color: #787584;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 4px 6px 6px;
}
.nl-legend-grid {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 0 2px 4px;
}
.nl-lg-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: #474553; min-width: 60px;
}
.nl-lg-swatch {
  width: 12px; height: 12px; border-radius: 3px;
  flex-shrink: 0; border: 1px solid rgba(0,0,0,0.08);
}
.nl-lg-label { white-space: nowrap; }
.nl-divider { margin: 6px 0; border-top: 1px solid #e1e3e4; }
.nl-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 8px 10px; border: none; background: none;
  border-radius: 6px; cursor: pointer; font-size: 12px; color: #474553;
}
.nl-item:hover { background: #f3f4f5; }
.nl-item.active { background: rgba(85,75,188,0.08); color: #554bbc; font-weight: 600; }
.nl-swatch { flex: 1; height: 100%; }

/* ── Marker legend (in settings popover) ── */
.marker-legend { font-size: 11px; color: #474553; line-height: 1.9; }
.marker-legend .ml-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; margin-right: 6px; vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.1);
}
.marker-legend .ml-pin {
  display: inline-block; width: 16px; text-align: center;
  margin-right: 4px; vertical-align: middle; font-size: 12px;
}
#filterbar { position: relative; }
#filterbar .popover {
  position: absolute;
  top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(85, 75, 188, 0.12), 0 2px 6px rgba(0,0,0,0.08);
  padding: 12px;
  display: flex; flex-wrap: wrap; gap: 6px;
  min-width: 220px;
  z-index: 60;
  border: 1px solid #e1e3e4;
}
#filterbar .pop-row { display: block; width: 100%; }
#filterbar .pop-row input {
  width: 100%; padding: 8px 10px; border: 1px solid #c8c4d5; border-radius: 8px;
  font: inherit; font-size: 13px;
}
#filterbar .pop-row input:focus { outline: none; border-color: #554bbc; box-shadow: 0 0 0 3px rgba(85,75,188,0.15); }
#filterbar .pop-apply {
  width: 100%; padding: 8px 12px;
  background: #554bbc; color: #fff; border: none; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 13px;
}
#filterbar .pop-apply:hover { background: #4034a6; }
#filterbar .pop-pill {
  padding: 6px 14px; border-radius: 999px;
  background: #f3f4f5; border: 1px solid transparent;
  cursor: pointer; font: inherit; font-size: 13px; min-width: 40px;
}
#filterbar .pop-pill:hover { background: #e7e8e9; }
#filterbar .pop-pill.active {
  background: #c2e8d6; border-color: #436557; color: #2b4d40; font-weight: 600;
}
#filterbar .pop-pill.wide { width: 100%; text-align: left; padding: 8px 14px; }
#filterbar .popover.pop-vert { flex-direction: column; min-width: 180px; gap: 4px; }

.chip-scope { background: #436557 !important; color: #fff !important; border: 1px solid #436557 !important; }
.chip-scope:hover { background: #355043 !important; }
.chip-scope .val { color: #fff; }

/* ── Map popups (daycare) ── */
.daycare-popup .maplibregl-popup-content { padding: 8px 10px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.15); font-size: 12px; }
.dc-name { font-weight: 600; margin-bottom: 4px; }
.dc-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.dc-meta .tag { background: #f3f4f5; padding: 2px 8px; border-radius: 999px; font-size: 11px; color: #474553; }
.dc-notes { color: #555; font-style: italic; font-size: 11px; }

/* ── Unified hood panel (summary + detail merged) ── */
#hood-panel {
  display: none;
  position: fixed;
  top: 6rem;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 360px;
  background: #f8f9fa;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(124, 115, 230, 0.10), 0 2px 6px rgba(0,0,0,0.06);
  border: 1px solid rgba(200, 196, 213, 0.4);
  z-index: 40;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 12px;
}

.panel-header {
  display: flex; align-items: center; gap: 6px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #e1e3e4;
  position: sticky; top: 0; background: #f8f9fa; z-index: 2;
}
#hood-panel h3 { margin: 0; font-size: 16px; font-weight: 700; flex: 1; color: #191c1d; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-back {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 999px;
  cursor: pointer; color: #474553; padding: 0; flex-shrink: 0;
}
.panel-back:hover { background: #e1e3e4; color: #191c1d; }
.panel-back .material-symbols-outlined { font-size: 20px; }
#hs-collapse { background: rgba(248, 249, 250, 0.85); backdrop-filter: blur(8px); border: 1px solid #c8c4d5; border-radius: 8px; cursor: pointer; font-size: 14px; padding: 0 8px; line-height: 22px; color: #474553; }
#hs-close { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: rgba(248, 249, 250, 0.85); backdrop-filter: blur(8px); border: none; border-radius: 999px; cursor: pointer; color: #474553; padding: 0; }
#hs-close:hover { background: #e1e3e4; color: #191c1d; }

.panel-body { padding: 12px 16px 16px; }
.panel-drag-handle { display: none; }

/* ── Summary body ── */
.panel-summary { display: block; }
#hood-panel.mode-detail .panel-summary { display: none; }

#hs-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #e1e3e4; }
#hs-stats.compact { display: none; }
/* Sections (amenities, schools, agents) stay visible in compact mode —
   they contain interactive UI. Only the stats grid collapses. */
#hs-stats div { font-size: 11px; color: #787584; }
#hs-stats strong { font-size: 12px; color: #191c1d; display: block; margin-bottom: 2px; }
#hs-listings { margin-top: 6px; }
.hs-listing { padding: 6px 0; border-bottom: 1px solid #f0f0f0; cursor: pointer; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.hs-listing:hover { background: rgba(85, 75, 188, 0.06); }
.hs-listing strong { color: #554bbc; }
.hs-thumb { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: #eee; }
.hs-listing-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hs-section { margin: 8px 0; border: 1px solid #e1e3e4; border-radius: 10px; overflow: hidden; background: #fff; }
.hs-section-title { font-size: 12px; font-weight: 600; padding: 8px 12px; background: #f3f4f5; cursor: pointer; display: flex; justify-content: space-between; align-items: center; user-select: none; color: #191c1d; }
.hs-section-title:hover { background: #e7e8e9; }
.hs-arrow { font-size: 8px; transition: transform 0.2s; color: #787584; }
.hs-section.collapsed .hs-section-body { display: none; }
.hs-section.collapsed .hs-arrow { transform: rotate(-90deg); }
.hs-section-body { padding: 8px 12px; }
.hs-meta { color: #787584; font-weight: 400; margin-left: 2px; }
.hs-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; padding: 8px; }
.hs-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; background: #f3f4f5; border-radius: 10px; line-height: 1.2; color: #474553; cursor: pointer; border: 1px solid transparent; transition: background 0.15s, border-color 0.15s; }
.hs-tile:hover { background: #e7e8e9; }
.hs-tile.active { background: rgba(85, 75, 188, 0.12); border-color: #554bbc; }
.hs-tile-icon { font-size: 18px; font-variation-settings: "FILL" 0, "wght" 400; }
.hs-tile-count { font-weight: 700; font-size: 13px; color: #191c1d; }
.hs-tile-label { font-size: 9px; color: #787584; text-align: center; text-transform: uppercase; letter-spacing: 0.03em; }
.hs-school-row { display: flex; justify-content: space-between; align-items: center; font-size: 11px; padding: 4px 0; gap: 6px; }
.hs-school-row + .hs-school-row { border-top: 1px solid #f0f0f0; }
.hs-school-tag { background: rgba(85, 75, 188, 0.12); color: #554bbc; font-size: 9px; padding: 1px 6px; border-radius: 4px; margin-left: 4px; vertical-align: middle; font-weight: 600; }
.hs-school-link { color: #554bbc; text-decoration: none; font-size: 13px; padding: 0 4px; }
.hs-school-link:hover { color: #4034a6; }
.hs-agents-title { font-weight: 600; font-size: 11px; margin-bottom: 4px; }
#hs-agent-list { display: flex; gap: 6px; flex-wrap: wrap; }
.hs-agent { cursor: pointer; }
.hs-agent-pic {
  display: inline-block; width: 36px; height: 36px; line-height: 36px;
  font-size: 36px !important; color: #554bbc;
  border-radius: 50%; text-align: center;
  font-variation-settings: "FILL" 1, "wght" 400;
  transition: transform 0.15s;
  background: #fff;
}
.hs-agent-pic:hover { transform: scale(1.15); }
.hs-agent-pic-lg {
  display: inline-block; width: 60px; height: 60px; line-height: 60px;
  font-size: 60px !important; color: #554bbc;
  border-radius: 50%; text-align: center;
  font-variation-settings: "FILL" 1, "wght" 400;
  background: #fff;
}

/* ── Detail body (listing detail, inside merged panel) ── */
.panel-detail { display: none; font-size: 14px; }
#hood-panel.mode-detail .panel-detail { display: block; }
#hood-panel.mode-detail .panel-body { padding: 0 16px 16px; }
#hood-panel.mode-detail .panel-header { border-bottom: 1px solid #e1e3e4; }

.panel-detail h2 { margin: 0 0 4px; font-size: 18px; font-weight: 700; color: #191c1d; line-height: 1.3; }
.panel-detail .price { font-size: 26px; font-weight: 800; color: #554bbc; margin: 10px 0 12px; letter-spacing: -0.02em; }
.panel-detail .meta { color: #474553; font-size: 13px; line-height: 1.6; }
.panel-detail .meta dt { font-weight: 600; display: inline; color: #191c1d; }
.panel-detail .meta dd { display: inline; margin: 0 12px 0 4px; }
.panel-detail .remarks { margin-top: 14px; padding-top: 12px; border-top: 1px solid #e1e3e4; font-size: 13px; color: #474553; line-height: 1.55; }
.panel-detail .close { display: none; }
.panel-detail img { border-radius: 12px !important; margin: 0 0 12px !important; max-height: 200px !important; }

/* ── Photo strip (scrollable image carousel) ── */
.photo-strip-wrap {
  position: relative;
  margin: 0 0 12px;
}
.photo-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: #c8c4d5 transparent;
}
.photo-strip::-webkit-scrollbar { height: 4px; }
.photo-strip::-webkit-scrollbar-track { background: transparent; }
.photo-strip::-webkit-scrollbar-thumb { background: #c8c4d5; border-radius: 10px; }
.photo-slide {
  flex: 0 0 auto;
  scroll-snap-align: start;
  border-radius: 12px;
  overflow: hidden;
}
.photo-slide img {
  width: auto;
  height: 200px;
  max-height: 200px;
  min-height: 100px;
  border-radius: 12px !important;
  object-fit: cover;
  cursor: pointer;
  display: block;
  margin: 0 !important;
  transition: transform 0.15s;
  background: #eee;
}
.photo-slide img:hover { transform: scale(1.02); }
#hood-panel .photo-slide img { margin: 0 !important; max-height: 200px !important; }

.ps-prev, .ps-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background: rgba(255,255,255,0.85);
  border: 1px solid #c8c4d5;
  border-radius: 50%;
  width: 28px; height: 28px;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #474553;
  padding: 0;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s;
}
.photo-strip-wrap:hover .ps-prev,
.photo-strip-wrap:hover .ps-next { opacity: 1; }
.ps-prev:hover, .ps-next:hover { background: #fff; color: #191c1d; }
.ps-prev { left: 4px; }
.ps-next { right: 4px; }

/* Always show photo strip arrows on touch devices (no hover support) */
@media (hover: none) {
  .ps-prev, .ps-next { opacity: 0.7; }
  .ps-prev:active, .ps-next:active { opacity: 1; }
}

/* ── Lightbox (fullscreen image viewer) ── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lightbox.open { display: flex; }
.lb-close {
  position: absolute;
  top: 16px;
  right: 24px;
  color: #fff;
  font-size: 36px;
  font-weight: 300;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1002;
  padding: 8px;
  line-height: 1;
}
.lb-close:hover { color: #ccc; }
.lb-prev, .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 28px;
  font-weight: 300;
  background: rgba(255,255,255,0.12);
  border: none;
  cursor: pointer;
  z-index: 1002;
  padding: 16px 12px;
  border-radius: 8px;
  user-select: none;
  transition: background 0.15s;
}
.lb-prev:hover, .lb-next:hover { background: rgba(255,255,255,0.24); }
.lb-prev { left: 16px; }
.lb-next { right: 16px; }
.lb-img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  user-select: none;
  pointer-events: none;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.lb-counter {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* ── Transit block ── */
.transit { margin: 14px 0; padding: 12px 14px; background: rgba(85, 75, 188, 0.06); border-radius: 12px; border: 1px solid rgba(85, 75, 188, 0.15); font-size: 13px; }
.transit-title { margin-bottom: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: #554bbc; font-weight: 600; }
.transit-title strong { color: #191c1d; font-weight: 700; text-transform: none; letter-spacing: 0; font-size: 14px; }
.transit-meta { color: #787584; font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 400; display: block; margin-top: 2px; }
.transit-row { display: flex; align-items: center; gap: 6px; }
.tt-mode { padding: 3px 10px; border: 1px solid #c8c4d5; background: #fff; border-radius: 12px; cursor: pointer; font-size: 11px; font-weight: 600; color: #787584; }
.tt-mode.active { background: #554bbc; color: #fff; border-color: #554bbc; }
.tt-time { margin-left: auto; font-weight: 700; color: #554bbc; }
.transit-note { margin-top: 6px; font-size: 11px; color: #787584; font-style: italic; }

@media (max-width: 700px) {
  #hood-panel {
    left: 8px; right: 8px; width: auto;
    top: auto; bottom: 0;
    max-height: 50vh;
    border-radius: 16px 16px 0 0;
    transition: max-height 0.25s ease;
  }
  #hood-panel.mode-detail { max-height: 75vh; }
  .panel-header { padding: 12px 14px 10px; }
  #hood-panel h3 { font-size: 15px; }

  /* Drag handle */
  .panel-drag-handle {
    display: block; width: 32px; height: 4px;
    background: #ccc; border-radius: 2px;
    margin: 0 auto 6px; flex-shrink: 0;
  }

  /* Larger tap targets */
  #hs-collapse { min-width: 36px; min-height: 36px; font-size: 16px; padding: 0 10px; }
  #hs-close { width: 36px; height: 36px; }
  .panel-back { width: 36px; height: 36px; }

  /* Top nav */
  nav.fixed { padding: 6px 12px; width: calc(100% - 1rem); top: 8px; }
  nav .font-headline-lg { font-size: 18px; }

  /* Filter bar horizontal scroll */
  #filterbar {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; max-width: calc(100vw - 12rem);
  }
  #filterbar::-webkit-scrollbar { display: none; }
  #filterbar .chip { flex-shrink: 0; white-space: nowrap; font-size: 12px; padding: 6px 10px; }

  .bottom-safe-area .flex.flex-col { display: none; }
  .nl-label { font-size: 11px; max-width: 80px; }
  .photo-strip-wrap { width: 100%; }
  .photo-strip { gap: 6px; }
  .photo-slide { flex: 0 0 100%; max-width: 100%; aspect-ratio: 4 / 3; }
  .photo-slide img { width: 100%; height: 100%; object-fit: cover; max-height: none; border-radius: 10px !important; }
  #hood-panel .photo-slide img { max-height: none !important; }
  .ps-prev, .ps-next { width: 36px; height: 36px; font-size: 18px; }
  .hs-tile { padding: 10px 2px; }
  .hs-tile-icon { font-size: 20px; }
  .hs-tile-count { font-size: 14px; }
}

@media (max-width: 480px) {
  #hood-panel { max-height: 45vh; }
}

/* ── Mobile filter bottom sheet ── */
.mobile-filters { display: none; }
.mf-scrim { display: none; }

@media (max-width: 700px) {
  /* Hide the desktop chip filter row + the desktop "Map controls" popover on mobile */
  #filterbar > .chip,
  #filterbar > .popover { display: none !important; }
  #filters { display: none !important; }

  /* Scrim + bottom sheet */
  .mf-scrim {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,0.45); z-index: 60;
    animation: mfFade 0.15s ease;
  }
  .mobile-filters {
    display: flex; flex-direction: column;
    position: fixed; left: 0; right: 0; bottom: 0;
    max-height: 85vh; background: #f8f9fa;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.18);
    z-index: 61;
    animation: mfSlide 0.2s ease;
  }
  .mf-header {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #e1e3e4;
    position: relative;
  }
  .mf-drag {
    position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
    width: 36px; height: 4px; background: #ccc; border-radius: 2px;
  }
  .mf-header h3 { flex: 1; margin: 0; font-size: 16px; font-weight: 700; color: #191c1d; }
  .mf-close {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(248,249,250,0.85); border: none; border-radius: 999px;
    color: #474553; cursor: pointer; padding: 0;
  }
  .mf-body {
    flex: 1; overflow-y: auto;
    padding: 12px 16px 8px;
    -webkit-overflow-scrolling: touch;
  }
  .mf-section { margin-bottom: 14px; }
  .mf-label {
    display: block; font-size: 11px; font-weight: 600;
    color: #787584; text-transform: uppercase; letter-spacing: 0.04em;
    margin-bottom: 6px;
  }
  .mf-pills { display: flex; flex-wrap: wrap; gap: 6px; }
  .mf-pill {
    flex: 0 0 auto;
    padding: 8px 14px; min-height: 36px;
    background: #fff; border: 1px solid #e1e3e4; border-radius: 999px;
    color: #474553; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: background 0.15s, border-color 0.15s;
  }
  .mf-pill.active {
    background: rgba(85,75,188,0.12); border-color: #554bbc; color: #554bbc;
  }
  .mf-row { display: flex; gap: 6px; align-items: center; }
  .mf-row input {
    flex: 1; min-width: 0; padding: 8px 10px;
    border: 1px solid #c8c4d5; border-radius: 8px;
    background: #fff; font-size: 13px;
  }
  .mf-row input:focus { outline: none; border-color: #554bbc; box-shadow: 0 0 0 3px rgba(85,75,188,0.15); }
  .mf-apply {
    padding: 8px 14px; min-height: 36px;
    background: #554bbc; color: #fff; border: none; border-radius: 8px;
    font-size: 13px; font-weight: 600; cursor: pointer;
  }
  .mf-current { margin-top: 6px; font-size: 12px; color: #554bbc; font-weight: 600; }
  .mf-footer {
    display: flex; gap: 8px; padding: 12px 16px;
    border-top: 1px solid #e1e3e4; background: #f8f9fa;
  }
  .mf-clear {
    flex: 0 0 auto; padding: 10px 14px; background: transparent;
    border: 1px solid #c8c4d5; border-radius: 8px;
    color: #474553; font-size: 13px; cursor: pointer;
  }
  .mf-done {
    flex: 1; padding: 10px 14px; background: #554bbc; color: #fff;
    border: none; border-radius: 8px; font-size: 14px; font-weight: 600;
    cursor: pointer;
  }
}

@keyframes mfSlide { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes mfFade { from { opacity: 0; } to { opacity: 1; } }
