/* ===== layout ===== */

.wrap {
  max-width:1200px;
  margin:0 auto;
  padding:16px;
  height:100vh;
}

.grid {
  display:grid;
  grid-template-columns:380px 1fr;
  gap:12px;
  height:100%;
}

@media (max-width:900px){
  .grid { grid-template-columns:1fr; }
  .wrap { height:auto; min-height:100vh; }
}

/* ===== sidebar ===== */

.topbar {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
}

.brand {
  font-weight:900;
  font-size:16px;
}

.userbox {
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.link-muted {
  color:var(--muted);
  font-size:12px;
  text-decoration:none;
}
.link-muted:hover { text-decoration:underline; }

/* ===== results list ===== */

.results {
  font-weight:800;
  font-size:14px;
}

.status { margin-left:8px; }

.list {
  overflow:auto;
  max-height:calc(100vh - 260px);
}

.item {
  padding:12px;
  border-top:1px solid var(--border);
  cursor:pointer;
}

.item:hover { background:#f9fafb; }

.title {
  font-weight:800;
  font-size:14px;
}

.meta {
  font-size:12px;
  color:var(--muted);
  margin-top:4px;
}

.price {
  font-weight:800;
  font-size:14px;
}

.details-btn {
  display:inline-block;
  margin-top:6px;
  font-size:12px;
  font-weight:800;
  color:var(--primary);
  text-decoration:none;
}
.details-btn:hover { text-decoration:underline; }

/* ===== map ===== */

#map {
  width:100%;
  height:100%;
  min-height:340px;
  position:relative;
}

/* ===== leaflet popup ===== */

.leaflet-popup-content {
  max-width:220px;
}

.leaflet-popup-content img {
  display:block;
  max-width:100%;
  max-height:140px;
  margin:8px auto 0;
  border-radius:10px;
  object-fit:contain;
}

@media (max-width:600px){
  .leaflet-popup-content { max-width:160px; }
  .leaflet-popup-content img { max-height:70px; }
}

/* ===== mobile: list first ===== */

@media (max-width:900px){

  .list { max-height:none; }

  .grid > :nth-child(2){ display:none; } /* карта */
  body.map-mode .grid > :nth-child(2){ display:block; }
  body.map-mode .grid > :nth-child(1){ display:none; }

  body.map-mode #map{
    height:calc(100vh - 32px);
    min-height:420px;
  }
}

/* ===== mobile back button ===== */

.back-to-list{
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  bottom:14px;
  z-index:9999;
  height:44px;
  border-radius:999px;
  padding:0 14px;
  background:var(--dark);
  color:#fff;
  font-weight:900;
  display:none;
  align-items:center;
  gap:8px;
  box-shadow:0 10px 24px rgba(0,0,0,.18);
}

@media (max-width:900px){
  body.map-mode .back-to-list{ display:inline-flex; }
}