/* IMPORTANT: propertyMap positioning is controlled by the main stylesheet. Do not override #propertyMap position/inset here. */
.map-tool-controls{position:absolute;left:12px;top:12px;z-index:60;display:flex;gap:6px;flex-wrap:wrap;max-width:calc(100% - 120px)}.map-tool-controls button{display:flex;align-items:center;gap:6px;border:1px solid rgba(17,24,39,.15);background:rgba(255,255,255,.97);color:#111827;border-radius:9px;padding:8px 10px;font:700 12px/1 system-ui,-apple-system,"Segoe UI",sans-serif;box-shadow:0 2px 10px rgba(15,23,42,.12);cursor:pointer}.map-tool-controls button.active{background:#111827;color:#fff;border-color:#111827}.map-tool-result{position:absolute;left:12px;top:58px;z-index:59;width:min(340px,calc(100% - 24px));background:rgba(255,255,255,.98);color:#1f2937;border:1px solid rgba(17,24,39,.12);border-radius:11px;padding:11px 12px;box-shadow:0 8px 24px rgba(15,23,42,.16);font:13px/1.35 system-ui,-apple-system,"Segoe UI",sans-serif}.map-tool-result.hidden{display:none}.map-tool-result strong{display:block;margin-bottom:7px}.map-tool-result>div{display:grid;grid-template-columns:88px 1fr;gap:7px;margin-top:5px}.map-tool-result>div>span{color:#667085}.map-tool-result>div>b{font-weight:700;overflow-wrap:anywhere}.map-tool-result small{display:block;color:#667085;margin-top:5px}.map-tool-result a{color:#175cd3;font-weight:700;text-decoration:none}.map-tool-result .map-measure-big{display:block;font-size:22px;font-weight:800}.map-measure-overlay{position:absolute;inset:0;z-index:45;width:100%;height:100%;pointer-events:none;overflow:visible}.map-ruler-line{fill:none;stroke:#111827;stroke-width:3;stroke-linecap:round;stroke-dasharray:8 5}.map-area-shape{fill:rgba(17,24,39,.16);stroke:#111827;stroke-width:3;stroke-linejoin:round}.map-measure-point{fill:#fff;stroke:#111827;stroke-width:3}.map-info-point{fill:#2563eb;stroke:#fff;stroke-width:3}.map-measure-label rect{fill:#111827;stroke:#fff;stroke-width:1}.map-measure-label text{fill:#fff;font:700 12px system-ui,-apple-system,"Segoe UI",sans-serif}#propertyMap.map-tool-active{cursor:crosshair}@media(max-width:720px){.map-tool-controls{left:8px;top:8px;gap:4px;max-width:calc(100% - 86px)}.map-tool-controls button{padding:8px}.map-tool-controls button span:last-child{display:none}.map-tool-result{left:8px;top:52px;width:min(320px,calc(100% - 16px));font-size:12px}}

/* Mobile map-tool responsiveness */
@media (max-width: 760px) {
  .map-tool-controls {
    left: 8px;
    right: 8px;
    top: 8px;
    z-index: 70;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    max-width: none;
    width: auto;
    pointer-events: auto;
  }

  .map-tool-controls button {
    min-width: 0;
    min-height: 44px;
    width: 100%;
    padding: 8px 6px;
    justify-content: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  .map-tool-controls button span:first-child {
    font-size: 18px;
    line-height: 1;
  }

  .map-tool-controls button span:last-child {
    display: inline;
    font-size: 11px;
    white-space: nowrap;
  }

  .map-tool-result {
    left: 8px;
    right: 8px;
    top: 62px;
    width: auto;
    max-width: none;
    box-sizing: border-box;
    z-index: 69;
    max-height: 42vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
  }

  .map-tool-result > div {
    grid-template-columns: 78px minmax(0,1fr);
  }

  .map-measure-overlay {
    pointer-events: none;
  }
}

/* Very narrow phones */
@media (max-width: 430px) {
  .map-tool-controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .map-tool-controls button {
    min-height: 42px;
    padding: 7px 4px;
    border-radius: 8px;
  }

  .map-tool-controls button span:last-child {
    font-size: 10px;
  }

  .map-tool-result {
    top: 58px;
    font-size: 12px;
  }
}


/* Keep map tool controls tappable after pinch/zoom on mobile browsers */
.map-tool-controls{
  pointer-events:auto!important;
  isolation:isolate;
}
.map-tool-controls button{
  pointer-events:auto!important;
  touch-action:manipulation!important;
  position:relative;
  z-index:1;
}
@media (max-width:760px){
  .map-tool-controls{
    z-index:80!important;
  }
  .map-tool-result{
    z-index:79!important;
  }
}


/* Two-finger pinch recovery: map controls must own their next tap independently
   of the map canvas gesture state. */
#propertyMap .map-tool-controls,
#propertyMap .map-tool-controls *,
#propertyMap .map-tool-result,
#propertyMap .map-tool-result *{
  touch-action:manipulation!important;
  -webkit-user-select:none;
  user-select:none;
}


/* Listing markers must not break two-finger map gestures on touch devices. */
@media (pointer:coarse) {
  #propertyMap .osm-price-marker {
    touch-action:none!important;
  }
}


/* Mobile interaction contract:
   - tap listing marker => listing details
   - drag anywhere (including over marker) => pan map
   - two-finger gesture anywhere (including over marker) => pinch zoom
   The JS map handler performs marker hit-testing for taps. */
@media (pointer:coarse) {
  #propertyMap .osm-price-marker {
    pointer-events:none!important;
    touch-action:none!important;
  }
}


/* Native map controls must remain independently tappable on mobile,
   including while Info/Ruler/Area is active and immediately after pinch zoom. */
#propertyMap .osm-controls,
#propertyMap .napr-layer-toggle,
#propertyMap .basemap-control{
  pointer-events:auto!important;
  z-index:95!important;
}
#propertyMap .osm-controls *,
#propertyMap .napr-layer-toggle *,
#propertyMap .basemap-control *{
  pointer-events:auto!important;
  touch-action:manipulation!important;
}


/* Mobile map-layer selector:
   preserve the browser's native select picker while isolating it from map gestures. */
#propertyMap .basemap-control,
#propertyMap .basemap-control select{
  pointer-events:auto!important;
  touch-action:manipulation!important;
}
#propertyMap .basemap-control select{
  position:relative;
  z-index:2;
}


/* Reliable touch-first map layer selector for phones/tablets. */
.mobile-layer-picker{display:none}
@media (pointer:coarse), (max-width:760px){
  #propertyMap .basemap-control select{display:none!important}
  #propertyMap .basemap-control{
    overflow:visible!important;
    z-index:110!important;
  }
  #propertyMap .mobile-layer-picker{
    display:block;
    position:relative;
    pointer-events:auto!important;
    touch-action:manipulation!important;
  }
  #propertyMap .mobile-layer-current{
    min-width:92px;
    min-height:36px;
    padding:6px 28px 6px 10px;
    border:1px solid #aeb4bc;
    border-radius:6px;
    background:#fff;
    color:#111827;
    font-size:12px;
    font-weight:800;
    text-align:left;
    position:relative;
    pointer-events:auto!important;
    touch-action:manipulation!important;
  }
  #propertyMap .mobile-layer-current::after{
    content:"▾";
    position:absolute;
    right:9px;
    top:50%;
    transform:translateY(-50%);
  }
  #propertyMap .mobile-layer-menu{
    position:absolute;
    right:0;
    top:calc(100% + 5px);
    min-width:132px;
    padding:5px;
    background:#fff;
    border:1px solid #c8cdd4;
    border-radius:8px;
    box-shadow:0 7px 22px rgba(0,0,0,.22);
    z-index:130;
    pointer-events:auto!important;
    touch-action:manipulation!important;
  }
  #propertyMap .mobile-layer-menu[hidden]{display:none!important}
  #propertyMap .mobile-layer-option{
    display:block;
    width:100%;
    min-height:38px;
    padding:7px 10px;
    border:0;
    border-radius:5px;
    background:#fff;
    color:#111827;
    text-align:left;
    font-size:13px;
    font-weight:700;
    pointer-events:auto!important;
    touch-action:manipulation!important;
  }
  #propertyMap .mobile-layer-option.active{
    background:#eef2f7;
    font-weight:900;
  }
}


/* Keep the custom layer dropdown visible and above the map when open. */
@media (pointer:coarse), (max-width:760px){
  #propertyMap .basemap-control,
  #propertyMap .mobile-layer-picker{
    overflow:visible!important;
  }
  #propertyMap .mobile-layer-menu:not([hidden]){
    display:block!important;
    visibility:visible!important;
    opacity:1!important;
    pointer-events:auto!important;
  }
}


/* Mobile map layer selector: standalone sibling, not nested inside LABEL. */
.mobile-basemap-control{display:none}
@media (pointer:coarse), (max-width:760px){
  #propertyMap .basemap-control{display:none!important}
  #propertyMap .mobile-basemap-control{
    display:block!important;
    position:absolute;
    right:12px;
    top:142px;
    z-index:180!important;
    overflow:visible!important;
    pointer-events:auto!important;
    touch-action:manipulation!important;
  }
  #propertyMap .mobile-basemap-current{
    display:block;
    min-width:108px;
    min-height:40px;
    padding:8px 30px 8px 11px;
    border:1px solid #aeb4bc;
    border-radius:7px;
    background:#fff;
    color:#111827;
    box-shadow:0 2px 8px rgba(0,0,0,.18);
    font-size:12px;
    font-weight:800;
    text-align:left;
    position:relative;
    pointer-events:auto!important;
    touch-action:manipulation!important;
  }
  #propertyMap .mobile-basemap-current::after{
    content:"▾";
    position:absolute;
    right:10px;
    top:50%;
    transform:translateY(-50%);
  }
  #propertyMap .mobile-basemap-menu{
    position:absolute;
    right:0;
    top:calc(100% + 6px);
    width:148px;
    padding:6px;
    border:1px solid #c8cdd4;
    border-radius:9px;
    background:#fff;
    box-shadow:0 10px 28px rgba(0,0,0,.25);
    z-index:190!important;
    pointer-events:auto!important;
    touch-action:manipulation!important;
  }
  #propertyMap .mobile-basemap-menu[hidden]{display:none!important}
  #propertyMap .mobile-basemap-control.open .mobile-basemap-menu{
    display:block!important;
    visibility:visible!important;
    opacity:1!important;
  }
  #propertyMap .mobile-basemap-option{
    display:block;
    width:100%;
    min-height:42px;
    padding:8px 10px;
    border:0;
    border-radius:6px;
    background:#fff;
    color:#111827;
    font-size:13px;
    font-weight:700;
    text-align:left;
    pointer-events:auto!important;
    touch-action:manipulation!important;
  }
  #propertyMap .mobile-basemap-option.active{
    background:#eef2f7;
    font-weight:900;
  }
}

/* Sponsored video mobile playback */
.sponsored-video{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
  background:#000;
}
.sponsored-video.autoplay-blocked{
  pointer-events:auto;
}


/* Compact mobile Map selector with Parcel folded into the same menu.
   Desktop map selector / parcel checkbox remain unchanged. */
@media (pointer:coarse), (max-width:760px){
  /* Parcel is now inside the layer menu on mobile. */
  #propertyMap .napr-layer-toggle{
    display:none!important;
  }

  /* Keep selector visible inside the short mobile map. */
  #propertyMap .mobile-basemap-control{
    display:block!important;
    right:10px!important;
    top:auto!important;
    bottom:10px!important;
    z-index:180!important;
    overflow:visible!important;
  }

  #propertyMap .mobile-basemap-current{
    min-width:94px!important;
    min-height:36px!important;
    padding:6px 27px 6px 9px!important;
    border-radius:7px!important;
    font-size:12px!important;
  }

  /* Open UPWARD so it never falls below the map window. */
  #propertyMap .mobile-basemap-menu{
    top:auto!important;
    bottom:calc(100% + 6px)!important;
    right:0!important;
    width:218px!important;
    max-width:calc(100vw - 24px)!important;
    padding:5px!important;
    border-radius:9px!important;
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:4px;
    z-index:190!important;
  }

  #propertyMap .mobile-basemap-menu[hidden]{
    display:none!important;
  }

  #propertyMap .mobile-basemap-control.open .mobile-basemap-menu{
    display:grid!important;
    visibility:visible!important;
    opacity:1!important;
  }

  /* Parcel consumes one full row above the map-type choices. */
  #propertyMap .mobile-parcel-option{
    grid-column:1 / -1;
    width:100%;
    min-height:34px;
    display:flex;
    align-items:center;
    gap:7px;
    padding:6px 9px;
    border:0;
    border-radius:6px;
    background:#fff;
    color:#111827;
    font-size:12px;
    font-weight:800;
    text-align:left;
    pointer-events:auto!important;
    touch-action:manipulation!important;
  }

  #propertyMap .mobile-parcel-option.active{
    background:#eef6ff;
  }

  #propertyMap .mobile-parcel-check{
    display:inline-flex;
    width:18px;
    height:18px;
    align-items:center;
    justify-content:center;
    border:1px solid #98a2b3;
    border-radius:5px;
    background:#fff;
    color:#0b66ff;
    font-size:14px;
    line-height:1;
    flex:0 0 18px;
  }

  #propertyMap .mobile-parcel-option.active .mobile-parcel-check{
    border-color:#0b66ff;
  }

  #propertyMap .mobile-basemap-option{
    min-height:34px!important;
    padding:6px 8px!important;
    font-size:12px!important;
    white-space:nowrap;
  }
}


/* Desktop/Windows: use the same compact Layers selector as mobile.
   Parcel lives inside the Layers menu together with the basemap choices. */
@media (min-width:761px) and (pointer:fine){
  #propertyMap .napr-layer-toggle,
  #propertyMap .basemap-control{
    display:none!important;
  }

  #propertyMap .mobile-basemap-control{
    display:block!important;
    position:absolute;
    right:12px!important;
    top:94px!important;
    bottom:auto!important;
    z-index:180!important;
    overflow:visible!important;
    pointer-events:auto!important;
  }

  #propertyMap .mobile-basemap-current{
    display:block!important;
    min-width:104px!important;
    min-height:38px!important;
    padding:7px 29px 7px 10px!important;
    border:1px solid #aeb4bc!important;
    border-radius:7px!important;
    background:#fff!important;
    color:#111827!important;
    box-shadow:0 2px 8px rgba(0,0,0,.18)!important;
    font-size:12px!important;
    font-weight:800!important;
    text-align:left!important;
    position:relative!important;
    cursor:pointer!important;
  }

  #propertyMap .mobile-basemap-current::after{
    content:"▾";
    position:absolute;
    right:10px;
    top:50%;
    transform:translateY(-50%);
  }

  #propertyMap .mobile-basemap-menu{
    position:absolute!important;
    right:0!important;
    top:calc(100% + 6px)!important;
    bottom:auto!important;
    width:218px!important;
    padding:5px!important;
    border:1px solid #c8cdd4!important;
    border-radius:9px!important;
    background:#fff!important;
    box-shadow:0 10px 28px rgba(0,0,0,.25)!important;
    grid-template-columns:1fr 1fr!important;
    gap:4px!important;
    z-index:190!important;
    pointer-events:auto!important;
  }

  #propertyMap .mobile-basemap-menu[hidden]{
    display:none!important;
  }

  #propertyMap .mobile-basemap-control.open .mobile-basemap-menu{
    display:grid!important;
    visibility:visible!important;
    opacity:1!important;
  }

  #propertyMap .mobile-parcel-option{
    grid-column:1 / -1!important;
    width:100%!important;
    min-height:34px!important;
    display:flex!important;
    align-items:center!important;
    gap:7px!important;
    padding:6px 9px!important;
    border:0!important;
    border-radius:6px!important;
    background:#fff!important;
    color:#111827!important;
    font-size:12px!important;
    font-weight:800!important;
    text-align:left!important;
    cursor:pointer!important;
  }

  #propertyMap .mobile-parcel-option.active{
    background:#eef6ff!important;
  }

  #propertyMap .mobile-parcel-check{
    display:inline-flex!important;
    width:18px!important;
    height:18px!important;
    align-items:center!important;
    justify-content:center!important;
    border:1px solid #98a2b3!important;
    border-radius:5px!important;
    background:#fff!important;
    color:#0b66ff!important;
    font-size:14px!important;
    line-height:1!important;
    flex:0 0 18px!important;
  }

  #propertyMap .mobile-parcel-option.active .mobile-parcel-check{
    border-color:#0b66ff!important;
  }

  #propertyMap .mobile-basemap-option{
    display:block!important;
    width:100%!important;
    min-height:34px!important;
    padding:6px 8px!important;
    border:0!important;
    border-radius:6px!important;
    background:#fff!important;
    color:#111827!important;
    font-size:12px!important;
    font-weight:700!important;
    text-align:left!important;
    white-space:nowrap!important;
    cursor:pointer!important;
  }

  #propertyMap .mobile-basemap-option:hover,
  #propertyMap .mobile-basemap-option.active{
    background:#eef2f7!important;
    font-weight:900!important;
  }
}
