/* Narrow screens: only Leaflet's own controls stay over the map. */
@media (max-width:850px){
  header{height:auto;min-height:60px;padding:8px 10px;gap:7px}
  header .brand{min-width:0;gap:7px}
  header .header-actions{flex-shrink:0}
  header .header-actions .btn{min-height:40px;padding-inline:8px}
  main{display:flex;flex-direction:column;height:auto;min-height:0}
  main .mobile-tabs{order:-1;position:sticky;inset:auto;top:0;transform:none;justify-content:center;align-self:stretch;z-index:900;border-radius:0;box-shadow:none;padding:4px 8px}
  main .mobile-tabs button{min-height:44px}
  main .sidebar{position:static;overflow:visible;min-width:0;padding-bottom:24px}
  main .map-wrap{position:static;display:flex;flex-direction:column;gap:6px;overflow:visible;height:auto;padding-bottom:12px}
  body.list-mode main .map-wrap{display:none}
  main #map{order:4;flex:none;width:100%;height:clamp(265px,58vh,660px);height:clamp(265px,58svh,660px);isolation:isolate}
  main .housing-tools{display:contents}
  main .overlay-buttons{order:0;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;padding:0 8px;align-items:stretch}
  main .overlay-buttons .btn{min-height:44px;white-space:normal;line-height:1.2;font-size:12px;padding:5px 7px}
  #housingStatus,main .housing-nav,main #sitesPanel{margin:0 8px;max-width:none;box-sizing:border-box}
  #housingStatus{order:1}
  main .housing-nav{order:2;display:flex;flex-wrap:wrap;justify-content:flex-start;gap:4px}
  main .housing-nav select{max-width:100%;min-height:36px}
  main #sitesPanel{order:3;width:auto}
  main #sitesQuery,main #sitesKind{min-height:38px;font-size:16px}
  main .sites-hit-list{max-height:92px}
  main .map-top,main .map-status,main .legend,main .coverage{position:static;inset:auto;max-width:none;margin:0 8px;z-index:auto;box-shadow:none}
  main .map-top{order:5;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px}
  main .map-top .btn{min-height:40px;white-space:normal;font-size:12px;box-shadow:none}
  main .map-status{order:6}
  main .legend{order:7}
  main .coverage{order:8}
  main .leaflet-popup-content{max-width:calc(100vw - 72px);max-height:40svh;overflow:auto;overflow-wrap:anywhere}
}
