:root {
  --bg: #f4f6fb;
  --text: #1e2433;
  --muted: #6f7788;
  --card: #ffffff;
  --border: #e5e9f2;
  --brand: #1760ff;
  --brand-dark: #0e48c4;
  --premium: #ffb547;
  --mobile-bottom-nav-height: 72px;
  --mobile-sheet-top-gap: 104px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
}

body.view-map {
  overflow: hidden;
  height: 100dvh;
  height: 100vh;
}

body.view-map #app {
  height: 100dvh;
  height: 100vh;
  max-height: 100dvh;
  max-height: 100vh;
  overflow: hidden;
}

.demo-page,
.map-page {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.demo-map-wrap {
  min-height: 0;
}

.demo-map-layout,
.map-layout--app-sheet {
  flex: 1;
  min-height: 0;
  height: auto;
}

.demo-hero {
  position: absolute;
  top: 86px;
  right: 16px;
  width: min(540px, calc(100% - 32px));
  max-width: calc(100vw - 220px);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.16);
  z-index: 6;
}

.demo-hero h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.demo-hero p {
  margin: 0;
  color: var(--muted);
}

.demo-hero .demo-hero-hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.demo-hero-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.demo-list {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: min(460px, calc(100% - 32px));
  max-height: 34dvh;
  overflow: auto;
  z-index: 9;
}

/* Моб. демо: краткая полоска под шапкой; плашки .demo-float-desktop — только десктоп (поверх карты) */
.demo-top-strip {
  display: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  flex-shrink: 0;
}

.demo-top-strip__line {
  margin: 0;
  flex: 1 1 min(0, 360px);
}

.demo-top-strip__line strong {
  font-weight: 600;
}

.demo-top-strip__open {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.demo-about-card {
  width: min(520px, 92vw);
  max-height: min(88dvh, 88vh);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.demo-about-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.demo-about-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.demo-about-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.demo-about-body h3 {
  margin: 14px 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.demo-about-body h3:first-of-type {
  margin-top: 0;
}

/* Ручка свайпа (показ только в моб. демо, см. max-width: 900px) */
.left-panel-handle-wrap {
  display: none;
}

/* Карта: десктоп — иконка слева; моб. — усыпка + свайп (см. max-width) */
.open-left-panel-btn--sheet {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.open-left-panel-btn--sheet .open-left-panel-ico--desk {
  display: none;
}

.open-left-panel-btn--sheet .open-left-panel-ico--mob {
  display: inline;
}

.map-sheet-left-scrim {
  display: none;
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 11;
  background: rgba(15, 23, 42, 0.38);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

/* Нижняя плашка (legacy): в разметке карты больше не используется */
.map-sheet-peek {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 22;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px max(6px, env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(16, 24, 40, 0.14);
  border: 1px solid var(--border);
  border-bottom: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.map-sheet-peek__handle {
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: #c3cad8;
  flex-shrink: 0;
  margin-bottom: 6px;
}

.map-sheet-peek__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  padding: 0 8px;
}

.map-sheet-peek__sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.map-layout--app-sheet .left-panel {
  width: 100%;
}

.demo-blur-line {
  margin-top: 4px;
  color: var(--muted);
  filter: blur(3px);
  user-select: none;
}

.cabinet-btn-short {
  display: none;
}

.topbar {
  height: 68px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 18px;
  gap: 12px;
}

.mobile-map-top,
.mobile-map-bottom-nav,
.mobile-map-title {
  display: none;
}

.brand {
  font-weight: 700;
  font-size: 20px;
}

.brand-home-btn {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
}

.filters {
  display: flex;
  gap: 8px;
  flex: 1;
  max-width: 760px;
}

.filters input,
.filters select,
.filters button,
.auth button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text);
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0 12px;
  font-size: 14px;
}

.filters input,
.filters select {
  flex: 1;
}

.filters .price-input {
  flex: 1;
  min-width: 140px;
}

.filters .bedrooms-select {
  flex: 0 0 112px;
}

.auth {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.top-action {
  color: var(--text);
  border-color: transparent;
  background: transparent;
}

.top-action:hover {
  border-color: var(--border);
  background: #fff;
}

.topbar-demo .auth .top-action.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.topbar-demo .auth .top-action.primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.filters button,
.auth button,
.btn {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 160ms ease, filter 160ms ease, background-color 160ms ease, border-color 160ms ease;
  will-change: transform;
}

.filters button:not(:disabled):active,
.auth button:not(:disabled):active,
.btn:not(:disabled):active {
  transform: translateY(1px) scale(0.992);
  filter: brightness(0.985);
}

.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.primary:hover {
  background: var(--brand-dark);
}

.contact-call-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  height: 40px;
  padding: 0 14px;
}

.map-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/** Обёртка карты: на мобилке колонка (карта flex); шторка — absolute поверх .map-stage. */
.map-wrap {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.map-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

@media (min-width: 901px) and (pointer: fine) {
  .map-layout--app-sheet .map-wrap {
  display: grid;
    grid-template-columns: clamp(290px, 24vw, 380px) 1fr;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
}

  .map-layout.collapsed .map-wrap {
  grid-template-columns: 1fr;
  }

  .map-layout--app-sheet .map-stage {
    display: block;
    min-height: 0;
  }
}

.left-panel {
  border-right: 1px solid var(--border);
  background: #fff;
  overflow: auto;
  padding: 16px;
}

.map-layout.collapsed .left-panel {
  display: none;
}

.left-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.close-left-panel {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #fff 0%, #f5f8ff 100%);
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
  color: #556079;
}

.left-panel-list-footer {
  padding: 16px 4px max(28px, env(safe-area-inset-bottom, 0px));
}

.left-panel-list-footer p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}

/* Десктоп: список скроллится. На моб. app-sheet переопределяется — шторка без внутреннего скролла, движется целиком. */
.left-panel-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  overscroll-behavior-x: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.map {
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1;
  touch-action: none;
  overscroll-behavior: none;
}

.map-draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 8;
}

.map-draw-canvas.active {
  pointer-events: auto;
  cursor: crosshair;
}

.open-left-panel-btn {
  position: absolute;
  left: max(10px, env(safe-area-inset-left, 0px));
  top: max(56px, env(safe-area-inset-top, 0px));
  transform: none;
  z-index: 10;
  width: 32px;
  height: 46px;
  border-radius: 10px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(23, 96, 255, 0.35);
  cursor: pointer;
  display: none;
}

.map-layout.collapsed .open-left-panel-btn {
  display: block;
}

.map-draw-tools {
  position: absolute;
  right: max(14px, env(safe-area-inset-right, 0px));
  top: max(14px, env(safe-area-inset-top, 0px));
  transform: none;
  z-index: 20;
  display: flex !important;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.map-draw-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #cdd8f3;
  background: linear-gradient(180deg, #ffffff 0%, #f3f7ff 100%);
  color: #1a4ed8;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(19, 32, 62, 0.18);
  transition: transform 0.16s ease, box-shadow 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.map-draw-btn__icon {
  display: inline-block;
  line-height: 1;
  transform: translateY(-0.5px);
}

.map-draw-btn.active {
  border-color: var(--brand);
  color: #fff;
  background: linear-gradient(180deg, #2f67ff 0%, #1755f5 100%);
  box-shadow: 0 10px 22px rgba(23, 96, 255, 0.36);
}

.map-draw-btn:active {
  transform: translateY(1px) scale(0.98);
}

.map-draw-hint {
  position: absolute;
  right: calc(100% + 8px);
  top: 0;
  width: min(250px, calc(100vw - 84px));
  border-radius: 12px;
  border: 1px solid #dbe4fb;
  background: rgba(255, 255, 255, 0.98);
  color: #1f2a44;
  font-size: 12px;
  line-height: 1.35;
  padding: 10px 28px 10px 10px;
  box-shadow: 0 10px 24px rgba(19, 32, 62, 0.14);
}

.map-draw-hint.hidden {
  display: none;
}

.map-draw-hint__close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6f7788;
  font-size: 14px;
  cursor: pointer;
}

/* Демо: плашка «Демо BrokerMap» вверху справа — кисть смещена вниз, не перекрывает текст */
.demo-page .map-wrap .map-draw-tools {
  top: 200px;
  right: 14px;
  bottom: auto;
}

@media (max-width: 900px), ((max-width: 1366px) and (pointer: coarse)) {
  .demo-page .map-wrap .map-draw-tools {
    top: 14px;
  }
}

.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 12px;
  background: #fff;
}

.card.premium {
  border-color: var(--premium);
  box-shadow: 0 8px 18px rgba(255, 181, 71, 0.26);
}

.card.card--feed {
  padding: 0;
  overflow: hidden;
}

.card.card--feed .card-body {
  padding: 10px 12px 12px;
}

.card.card--feed.card--tappable {
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 170ms ease, filter 170ms ease;
}

.card.card--feed.card--tappable:hover {
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.card.card--feed.card--tappable:active {
  transform: translateY(1px) scale(0.992);
  filter: brightness(0.99);
}

.card.card--feed.card--route-opening {
  transform: scale(0.988);
  opacity: 0.86;
}

.sheet-route-transition {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(247, 250, 255, 0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 2400;
}

.sheet-route-transition.visible {
  opacity: 1;
}

.sheet-route-transition__card {
  width: min(460px, calc(100vw - 40px));
  background: #fff;
  border: 1px solid #dce5f7;
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.16);
}

.sheet-route-transition__bar {
  height: 10px;
  border-radius: 999px;
  margin: 8px 0;
  background: linear-gradient(90deg, #e8edf8 0%, #f4f7fd 35%, #e8edf8 70%);
  background-size: 220% 100%;
  animation: sheet-route-shimmer 1.05s linear infinite;
}

.sheet-route-transition__bar--lg {
  height: 14px;
  width: 78%;
}

.sheet-route-transition__bar--sm {
  width: 54%;
}

@keyframes sheet-route-shimmer {
  from {
    background-position: 220% 0;
  }
  to {
    background-position: -20% 0;
  }
}

body.sheet-property-popup-open {
  overflow: hidden;
}

.sheet-property-popup {
  position: fixed;
  inset: 0;
  z-index: 980;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-property-popup__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.52);
}

.sheet-property-popup__panel {
  position: relative;
  z-index: 1;
  width: min(1040px, calc(100vw - 24px));
  max-height: min(92dvh, 92vh);
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  border: 1px solid #dbe4fb;
  box-shadow: 0 22px 48px rgba(15, 23, 42, 0.34);
  padding: 18px;
}

.sheet-property-popup__close {
  position: sticky;
  top: 0;
  margin-left: auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: #eef2ff;
  color: #3b4460;
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  display: block;
}

.sheet-property-popup__loading {
  padding: 28px 10px 14px;
  text-align: center;
  color: #667189;
}

.sheet-property-popup__grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr);
}

.sheet-property-popup__main,
.sheet-property-popup__aside {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 14px;
}

.sheet-property-popup__main h2,
.sheet-property-popup__aside h3 {
  margin-top: 0;
}

.card-media {
  position: relative;
}

.card.card--feed .card-media__img {
  display: block;
  width: 100%;
  height: 172px;
  object-fit: cover;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.card-photo-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
}

.card-photo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.card-photo-dot--active {
  background: #fff;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
}

.card-badge--partner {
  color: #047857;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.card-badge--amount {
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.card-price {
  font-size: 20px;
  font-weight: 700;
  margin: 2px 0 6px;
}

.card-spec {
  font-size: 13px;
  color: var(--text);
  margin: 0 0 4px;
}

.card-address {
  font-size: 13px;
  margin: 0 0 6px;
}

.card-metro {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 10px;
}

.card-metro__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.card-actions {
  margin: 0;
}

.card-actions--split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.card img {
  width: 100%;
  height: 170px;
  object-fit: cover;
}

.card-body {
  padding: 12px;
}

.price {
  font-size: 20px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.page {
  max-width: 1080px;
  margin: 20px auto;
  padding: 0 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.gallery img {
  width: 100%;
  border-radius: 12px;
  height: 220px;
  object-fit: cover;
  cursor: zoom-in;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 24, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.gallery-lightbox.open {
  display: flex;
}

.gallery-lightbox-image {
  max-width: min(90vw, 1200px);
  max-height: 80vh;
  border-radius: 14px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.4);
}

.gallery-lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.gallery-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

#galleryPrevBtn,
#cardGalleryPrevBtn,
#popupGalleryPrevBtn {
  left: 18px;
}

#galleryNextBtn,
#cardGalleryNextBtn,
#popupGalleryNextBtn {
  right: 18px;
}

.gallery-lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
}

.cabinet-head-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.close-panel-action {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.auth-wrap,
.cabinet {
  max-width: 760px;
  margin: 22px auto;
  padding: 0 14px;
}

.cabinet .card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
}

.cabinet .card img {
  width: 88px;
  height: 66px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.cabinet .card .card-body {
  padding: 0;
  min-width: 0;
}

.cabinet .card .card-body p {
  margin: 6px 0 0;
}

.login-page {
  min-height: 100dvh;
  min-height: 100vh;
  background: #f3f3f3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
}

/* Вход / регистрация поверх демо-карты (не отдельная страница) */
.auth-demo-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  pointer-events: none;
}

.auth-demo-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  pointer-events: auto;
}

.auth-demo-overlay__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  max-height: min(92dvh, 92vh);
  overflow-y: auto;
  margin: 0 auto;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.2);
  pointer-events: auto;
  padding-top: 8px;
}

.login-page.login-page--overlay {
  min-height: 0;
  max-height: min(92dvh, 92vh);
  border-radius: 18px 18px 0 0;
  margin: 0;
  padding-top: 44px;
}

.auth-demo-overlay__x {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 3;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  color: #334155;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
}

.auth-demo-overlay__x:active {
  transform: scale(0.96);
}

/* Демо-оверлей: регистрация / сброс — один слой, без белой формы входа «под» модалкой */
.auth-demo-overlay--submodal .login-wrapper,
.auth-demo-overlay--submodal .contact-us-card {
  display: none;
}

.auth-demo-overlay--submodal .auth-demo-overlay__panel {
  max-height: min(96dvh, 96vh);
  min-height: min(380px, 78dvh);
  margin-bottom: max(44px, calc(env(safe-area-inset-bottom, 0px) + 24px));
}

.auth-demo-overlay--submodal #registerModal.active,
.auth-demo-overlay--submodal #resetModal.active {
  position: absolute;
  inset: 0;
  background: transparent;
  display: flex;
  align-items: stretch;
  justify-content: center;
  z-index: 2;
}

.auth-demo-overlay--submodal #registerModal.active .auth-modal-content,
.auth-demo-overlay--submodal #resetModal.active .auth-modal-content {
  width: 100%;
  max-width: none;
  align-self: stretch;
  max-height: min(96dvh, 96vh);
  border-radius: 18px 18px 0 0;
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
}

.contact-us-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.08);
}

.contact-us-card h4 {
  margin: 0 0 6px;
}

.contact-us-card p {
  margin: 0 0 8px;
}

.cabinet .contact-us-card {
  max-width: none;
  width: 100%;
}

.auth-result-wrap {
  padding: 4px 0 2px;
}

.auth-result-text {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
}

.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

.login-box h3,
.auth-modal-content h3 {
  margin-top: 0;
}

.auth-notice {
  display: none;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.35;
}

.auth-notice.visible {
  display: block;
}

.login-box input,
.auth-modal-content input {
  margin-top: 10px;
}

.login-box .btn,
.auth-modal-content .btn {
  margin-top: 12px;
}

.full {
  width: 100%;
}

.auth-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
}

.auth-modal.active {
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.auth-modal-content {
  background: #fff;
  width: 100%;
  max-width: 420px;
  padding: 20px;
  border-radius: 20px 20px 0 0;
  max-height: 90vh;
  overflow-y: auto;
}

.auth-modal-content--register {
  border: 1px solid #dbe4fb;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.24);
}

.phone-group {
  display: flex;
  margin-top: 10px;
}

.phone-group span {
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: #eee;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 10px 0 0 10px;
  font-size: 14px;
}

.phone-group input {
  margin-top: 0;
  border-radius: 0 10px 10px 0;
}

.note {
  font-size: 12px;
  color: #666;
  margin: 8px 0 0;
}

.checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
}

.checkbox-line input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex-shrink: 0;
}

.checkbox-line a {
  color: #007aff;
  text-decoration: none;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.field-block {
  display: flex;
  flex-direction: column;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 6px;
}

.field-block .phone-group {
  margin-top: 0;
}

.photo-drop-zone {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #f8faff;
  color: var(--muted);
  text-align: center;
  margin-bottom: 8px;
}

.photo-drop-zone.active {
  border-color: var(--brand);
  background: #eef3ff;
  color: #264fba;
}

.photo-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 8px;
  background: #fff;
}

.photo-list-row img {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

.field-span-2 {
  grid-column: span 2;
}

.address-row {
  display: flex;
  gap: 8px;
}

.address-row input {
  margin-top: 0;
}

.address-preview-map {
  margin-top: 10px;
  height: 0;
  border-radius: 12px;
  overflow: hidden;
  transition: height 0.2s ease;
}

.address-preview-map.visible {
  height: 180px;
  border: 1px solid var(--border);
}

input,
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
}

.input-invalid {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.field-error-text {
  margin: 6px 0 0;
  font-size: 12px;
  color: #dc2626;
  line-height: 1.3;
}

textarea {
  min-height: 120px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(14, 21, 35, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(620px, 90vw);
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

.property-form-modal-card {
  width: min(980px, 94vw);
  max-height: 88vh;
  overflow: visible;
}

.filters-modal-card {
  width: min(620px, 92vw);
  max-height: min(82vh, 760px);
  overflow-y: auto;
  border: 1px solid #dbe4fb;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.24);
}

#propertyFormWrap {
  max-height: calc(88vh - 84px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.modal.open,
.auth-modal.active,
.sheet-property-popup {
  overscroll-behavior-x: none;
}

.auth-modal-content,
.sheet-property-popup__panel,
.filters-modal-card {
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

.modal-card p,
.modal-card span,
.modal-card div,
.modal-card label,
.modal-card h1,
.modal-card h2,
.modal-card h3,
.modal-card h4,
.modal-card h5,
.modal-card h6,
.modal-card a,
.modal-card li,
.auth-modal-content p,
.auth-modal-content span,
.auth-modal-content div,
.auth-modal-content label,
.auth-modal-content h1,
.auth-modal-content h2,
.auth-modal-content h3,
.auth-modal-content h4,
.auth-modal-content h5,
.auth-modal-content h6,
.auth-modal-content a,
.auth-modal-content li,
.sheet-property-popup__panel p,
.sheet-property-popup__panel span,
.sheet-property-popup__panel div,
.sheet-property-popup__panel label,
.sheet-property-popup__panel h1,
.sheet-property-popup__panel h2,
.sheet-property-popup__panel h3,
.sheet-property-popup__panel h4,
.sheet-property-popup__panel h5,
.sheet-property-popup__panel h6,
.sheet-property-popup__panel a,
.sheet-property-popup__panel li {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ymaps-2-1-79-suggest {
  z-index: 3000 !important;
}

.address-suggest-list {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(18, 32, 58, 0.16);
  margin-top: 6px;
  max-height: 220px;
  overflow: auto;
  position: relative;
  z-index: 4000;
}

.address-suggest-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #edf1f7;
  background: #fff;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
}

.address-suggest-item:last-child {
  border-bottom: 0;
}

.address-suggest-item:hover {
  background: #f4f8ff;
}

.address-suggest-item span {
  display: block;
  font-size: 12px;
  color: #667189;
  margin-top: 2px;
}

@media (max-width: 900px), ((max-width: 1366px) and (pointer: coarse)) {
  .sheet-property-popup {
    align-items: flex-end;
  }

  .sheet-property-popup__panel {
    width: 100%;
    max-width: 100%;
    max-height: min(94dvh, 94vh);
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 12px;
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
  }

  .sheet-property-popup__grid {
    grid-template-columns: 1fr;
  }

  body.auth-modal-open .mobile-map-bottom-nav {
    display: none !important;
  }

  .auth-modal.active {
    align-items: flex-start;
    justify-content: center;
    padding-top: max(64px, calc(env(safe-area-inset-top, 0px) + 54px));
    padding-bottom: 10px;
  }

  .auth-modal-content {
    width: calc(100% - 20px);
    max-width: none;
    margin: 0 10px;
    border-radius: 14px;
    max-height: calc(100dvh - max(92px, calc(env(safe-area-inset-top, 0px) + 80px)) - 10px);
    overflow-y: auto;
  }

  .auth-modal-content--register {
    border: 1px solid #dbe4fb;
  }

  .topbar.topbar--no-filters .filters {
    display: none !important;
  }

  .demo-page,
  .map-page {
    min-height: 100%;
  }

  .demo-top-strip {
    display: flex;
    position: fixed;
    top: max(8px, env(safe-area-inset-top, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
    z-index: 58;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
    pointer-events: none;
  }

  .demo-top-strip__line {
    display: none !important;
  }

  .demo-top-strip__open {
    pointer-events: auto;
    height: 36px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.14);
    padding: 0 12px;
  }

  .demo-float-desktop {
    display: none !important;
  }

  .map-page > .topbar,
  .demo-page > .topbar {
    display: none !important;
  }

  .mobile-map-top {
    display: flex;
    position: fixed;
    top: max(8px, env(safe-area-inset-top, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    z-index: 60;
    justify-content: flex-end;
    pointer-events: none;
  }

  .mobile-map-title {
    display: block;
    position: fixed;
    top: max(10px, env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 59;
    font-size: 24px;
    font-weight: 800;
    color: #1f2a44;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
  }

  .mobile-map-top .btn {
    pointer-events: auto;
    height: 36px;
    border-radius: 12px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.14);
  }

  .mobile-map-bottom-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 120;
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--border);
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
    pointer-events: auto;
  }

  .mobile-map-bottom-nav__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    text-decoration: none;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 14px;
    color: var(--text);
    box-shadow: 0 1px 6px rgba(15, 23, 42, 0.08);
    position: relative;
    z-index: 121;
    touch-action: manipulation;
  }

  .mobile-map-bottom-nav__btn.active {
    border-color: var(--brand);
    color: var(--brand);
    font-weight: 600;
    background: rgba(23, 96, 255, 0.06);
  }

  .mobile-map-bottom-nav__btn:active,
  .mobile-map-bottom-nav__btn:focus-visible {
    border-color: var(--brand);
    color: var(--brand);
    font-weight: 600;
    background: rgba(23, 96, 255, 0.06);
  }

  .demo-page > .demo-top-strip {
    margin-top: 0;
  }

  /* Моб. шторка: без кнопки «Список» — только тянуть за блок (ручка/шапка/карточки). На десктопе кнопка в @media (min-width: 901px) and (pointer: fine). */
  .map-page .map-layout--app-sheet .map-wrap .open-left-panel-btn--sheet,
  .demo-page .map-layout--app-sheet .map-wrap .open-left-panel-btn--sheet {
    display: none !important;
    pointer-events: none !important;
  }

  .open-left-panel-btn--sheet .open-left-panel-ico--desk {
    display: none !important;
  }

  .open-left-panel-btn--sheet .open-left-panel-ico--mob {
    display: inline;
    line-height: 1;
  }

  .map-layout .map-sheet-left-scrim {
    display: none !important;
    pointer-events: none !important;
  }

  .map-page .map-layout--app-sheet,
  .demo-page .map-layout--app-sheet {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
  }

  .map-page .map-layout--app-sheet .map-wrap,
  .demo-page .map-layout--app-sheet .map-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
    z-index: 0;
    display: flex;
    flex-direction: column;
  }

  .map-page .map-layout--app-sheet .map-stage,
  .demo-page .map-layout--app-sheet .map-stage {
    flex: 1;
    min-height: 0;
    position: relative;
    z-index: 0;
  }

  /** Шторка — слой над картой в пределах .map-wrap, не fixed на весь viewport (ломало высоту карты на iOS). */
  .map-page .map-layout--app-sheet .left-panel,
  .demo-page .map-layout--app-sheet .left-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100% !important;
    max-width: none !important;
    z-index: 40;
    border: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
    overflow: hidden;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: visible;
  }

  /* В полушторке должна быть видна карта сверху — фон только у белого трека, не на весь экран. */

  .map-page .map-layout--app-sheet .left-panel__track.left-panel--sheet-anim,
  .demo-page .map-layout--app-sheet .left-panel__track.left-panel--sheet-anim {
    transition: transform 0.44s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .map-page .map-layout--app-sheet .left-panel__track.left-panel--sheet-live,
  .demo-page .map-layout--app-sheet .left-panel__track.left-panel--sheet-live {
    transition: none !important;
  }

  .map-page .map-layout--app-sheet:not(.collapsed) .left-panel,
  .demo-page .map-layout--app-sheet:not(.collapsed) .left-panel {
    visibility: visible;
  }

  .map-page .map-layout--app-sheet.collapsed .left-panel,
  .demo-page .map-layout--app-sheet.collapsed .left-panel {
    display: flex !important;
    visibility: visible;
    pointer-events: none;
  }

  .map-page .map-layout--app-sheet .left-panel-handle-wrap,
  .demo-page .map-layout--app-sheet .left-panel-handle-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0 0;
    margin: 0 0 10px;
    flex-shrink: 0;
  }

  .left-panel-handle {
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background: #c3cad8;
  }

  .left-panel-handle-hint {
    margin: 6px 0 0;
    font-size: 11px;
    color: var(--muted);
    text-align: center;
  }

  /* Одинаковый отступ и в свёрнутом, и в развёрнутом — геометрия шторки не должна прыгать от .collapsed */
  .map-page .map-layout--app-sheet .left-panel-head,
  .demo-page .map-layout--app-sheet .left-panel-head {
    flex-shrink: 0;
    padding: 10px 0 14px;
  }

  .map-page .map-layout--app-sheet .left-panel-head h3,
  .demo-page .map-layout--app-sheet .left-panel-head h3 {
    margin: 0;
    line-height: 1.25;
  }

  .map-page .map-layout--app-sheet .left-panel__track,
  .demo-page .map-layout--app-sheet .left-panel__track {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    /* Вся белая штора = полная высота контента; «пролистывание» объектов = движение translateY всего блока */
    height: auto;
    max-height: none;
    min-height: 72px;
    will-change: transform;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: visible;
    touch-action: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    /* Вторым слоем — фон под «носителем», чтобы между шторкой и нижней навигацией не зияла карта. */
    box-shadow:
      0 -6px 28px rgba(16, 24, 40, 0.18),
      0 calc(140px + 50vmin) 0 calc(140px + 50vmin) rgb(255, 255, 255);
    padding: 0 12px 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    background: #fff;
    pointer-events: auto;
    /* До первого JS-settle держим трек ниже экрана, чтобы не было кадра "полностью раскрыто". */
    transform: translate3d(0, 120%, 0);
  }

  .map-page .map-layout--app-sheet .sheet-back-to-first,
  .demo-page .map-layout--app-sheet .sheet-back-to-first {
    position: fixed;
    right: max(12px, env(safe-area-inset-right, 0px) + 6px);
    bottom: calc(var(--mobile-bottom-nav-height, 72px) + var(--mobile-browser-extra-bottom, 0px) + max(34px, env(safe-area-inset-bottom, 0px) + 22px));
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.42);
    background: rgba(22, 31, 47, 0.42);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(16, 24, 40, 0.28);
    z-index: 260;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 160ms ease, transform 160ms ease;
  }

  .map-page .map-layout--app-sheet .sheet-back-to-first.visible,
  .demo-page .map-layout--app-sheet .sheet-back-to-first.visible {
    opacity: 1;
    transform: translateY(0);
  }

  .map-page .map-layout--app-sheet .sheet-back-to-first > span,
  .demo-page .map-layout--app-sheet .sheet-back-to-first > span {
    display: inline-block;
    transform: translateY(1px);
    font-weight: 700;
  }

  .map-page .map-layout--app-sheet .left-panel.left-panel--updating .left-panel__track,
  .demo-page .map-layout--app-sheet .left-panel.left-panel--updating .left-panel__track {
    transition: opacity 140ms ease;
    opacity: 0.94;
  }

  .map-page .map-layout--app-sheet .left-panel-scroll,
  .demo-page .map-layout--app-sheet .left-panel-scroll {
    flex: 0 0 auto;
    min-height: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: visible;
    overscroll-behavior: none;
    touch-action: none;
    -webkit-overflow-scrolling: auto;
  }

  .map-page .map-layout--app-sheet .left-panel__track button,
  .demo-page .map-layout--app-sheet .left-panel__track button {
    touch-action: manipulation;
  }

  .map-page .map-layout--app-sheet .left-panel__track::after,
  .demo-page .map-layout--app-sheet .left-panel__track::after {
    content: "";
    display: block;
    height: 28px;
    width: 100%;
    background: #fff;
    border-radius: 0 0 16px 16px;
  }

  .map-page .map-layout--app-sheet .close-left-panel,
  .demo-page .map-layout--app-sheet .close-left-panel {
    display: none !important;
  }

  .map-page .map-layout--app-sheet .left-panel-handle-hint,
  .demo-page .map-layout--app-sheet .left-panel-handle-hint {
    display: none !important;
  }

  .map-draw-tools {
    top: max(88px, env(safe-area-inset-top, 0px)) !important;
  }

  .map-page .map-layout--app-sheet .map-wrap .map-draw-tools,
  .demo-page .map-layout--app-sheet .map-wrap .map-draw-tools {
    z-index: 45;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: span 1;
  }

  .topbar {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    padding: 10px 12px;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-top: max(10px, env(safe-area-inset-top, 0px));
    gap: 0;
  }

  .brand {
    order: 1;
    font-size: 18px;
  }

  .auth {
    order: 2;
    margin-left: auto;
  }

  .filters {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
  }

  .filters .price-input,
  .filters .bedrooms-select {
    min-width: 0;
    width: 100%;
  }

  .filters .bedrooms-select {
    grid-column: 1 / -1;
  }

  .filters #moreFilters {
    grid-column: 1;
  }

  .filters #resetFilters {
    grid-column: 2;
  }

  .card img {
    height: 140px;
  }

  .card.card--feed .card-media__img {
    height: 148px;
  }

  .page {
    margin: 12px auto;
    padding: 0 12px;
    padding-bottom: calc(var(--mobile-bottom-nav-height, 72px) + max(16px, env(safe-area-inset-bottom, 0px)));
  }

  .cabinet,
  .auth-wrap,
  .login-page {
    margin: 12px auto;
    padding: 0 12px;
    padding-bottom: calc(var(--mobile-bottom-nav-height, 72px) + max(16px, env(safe-area-inset-bottom, 0px)));
  }

  .address-row {
    flex-direction: column;
  }

  .map-page,
  .demo-page {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }
}

/* iPad / широкий «мобильный» режим: скролл списка внутри шторки вместо только transform-рулона */
@media (max-width: 900px) and (min-width: 744px), ((max-width: 1366px) and (min-width: 744px) and (pointer: coarse)) {
  .map-page .map-layout--app-sheet .left-panel__track,
  .demo-page .map-layout--app-sheet .left-panel__track {
    transform: none !important;
    transition: none !important;
    max-height: calc(
      100dvh - var(--mobile-sheet-top-gap, 120px) - var(--mobile-bottom-nav-height, 72px) - 12px
    );
    overflow: hidden;
    touch-action: auto;
    will-change: auto;
    box-shadow:
      0 -6px 28px rgba(16, 24, 40, 0.18),
      0 28px 0 28px #fff;
  }

  .map-page .map-layout--app-sheet .left-panel-scroll,
  .demo-page .map-layout--app-sheet .left-panel-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto !important;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* Широкий экран: кнопка свернуть слева, иконка ❯, без усыпки */
@media (min-width: 901px) and (pointer: fine) {
  .map-sheet-peek {
    display: none !important;
  }

  .map-layout--app-sheet.collapsed .left-panel {
    display: none !important;
  }

  .map-layout--app-sheet.collapsed .map-wrap {
    grid-template-columns: 1fr !important;
  }

  .map-page .map-layout--app-sheet .sheet-back-to-first,
  .demo-page .map-layout--app-sheet .sheet-back-to-first {
    display: none !important;
  }

  .open-left-panel-btn--sheet .open-left-panel-ico--mob {
    display: none !important;
  }

  .open-left-panel-btn--sheet .open-left-panel-ico--desk {
    display: inline !important;
  }

  .open-left-panel-btn--sheet .open-left-panel-label {
    display: none;
  }

  .map-sheet-left-scrim {
    display: none !important;
  }

  .open-left-panel-btn--sheet {
    min-width: 32px;
    width: 32px;
    height: 46px;
    min-height: 46px;
    padding: 0;
    font-size: 18px;
    font-weight: 500;
    border-radius: 10px;
  }

  /**
   * Та же DOM-разметка (трек + scroll), что и на мобилке, но на широком экране — сетка и скролл списка, без transform-шторки.
   * Сбрасываем стили из @media (max-width: 900px), ((max-width: 1366px) and (pointer: coarse)), иначе overflow-y: visible / touch-action: none ломают прокрутку карточек.
   */
  .map-page .map-layout--app-sheet .left-panel,
  .demo-page .map-layout--app-sheet .left-panel {
    position: relative !important;
    inset: auto !important;
    width: auto !important;
    z-index: auto;
    overflow: hidden;
    pointer-events: auto !important;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 16px;
    background: #fff;
    justify-content: flex-start;
    border-right: 1px solid var(--border);
  }

  .map-page .map-layout--app-sheet .left-panel__track,
  .demo-page .map-layout--app-sheet .left-panel__track {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: none !important;
    will-change: auto;
    touch-action: auto;
    box-shadow: none !important;
    border-radius: 0;
    border: 0;
    padding: 0;
    background: transparent;
    max-width: none !important;
    width: 100% !important;
  }

  .map-page .map-layout--app-sheet .left-panel-scroll,
  .demo-page .map-layout--app-sheet .left-panel-scroll {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: none;
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch;
  }

  .map-page .map-layout--app-sheet .left-panel__track::after,
  .demo-page .map-layout--app-sheet .left-panel__track::after {
    display: none !important;
  }

  .map-page .map-layout--app-sheet .left-panel-handle-wrap,
  .demo-page .map-layout--app-sheet .left-panel-handle-wrap {
    display: none !important;
  }

  .map-page .map-layout--app-sheet .close-left-panel,
  .demo-page .map-layout--app-sheet .close-left-panel {
    display: inline-flex !important;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .cabinet-btn-long {
    display: none;
  }

  .cabinet-btn-short {
    display: inline;
  }

  .gallery {
    grid-template-columns: 1fr;
  }

  .gallery img {
    height: 200px;
  }

  .filters input,
  .filters select,
  .filters button,
  .auth button,
  .topbar .btn,
  .login-box input,
  .auth-modal-content input,
  input,
  textarea,
  select {
    font-size: 16px;
  }

  .map-draw-btn {
    width: 44px;
    height: 44px;
  }

  .map-draw-hint {
    right: calc(100% + 8px);
    top: 0;
    width: min(230px, calc(100vw - 96px));
    font-size: 11px;
    padding: 8px 24px 8px 8px;
  }

  .open-left-panel-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .modal-card {
    width: 100%;
    max-width: none;
    margin: 0 12px;
    max-height: 88dvh;
    max-height: 88vh;
    overflow-y: auto;
  }

  .gallery-lightbox-nav {
    width: 40px;
    height: 40px;
  }

  #galleryPrevBtn,
  #cardGalleryPrevBtn,
  #popupGalleryPrevBtn {
    left: 8px;
  }

  #galleryNextBtn,
  #cardGalleryNextBtn,
  #popupGalleryNextBtn {
    right: 8px;
  }

  #filtersModal {
    align-items: flex-start;
    justify-content: center;
    padding-top: max(64px, calc(env(safe-area-inset-top, 0px) + 54px));
    padding-bottom: 10px;
  }

  .filters-modal-card {
    margin: 0 10px;
    max-height: calc(100dvh - max(92px, calc(env(safe-area-inset-top, 0px) + 80px)) - 10px);
    overflow-y: auto;
    border: 1px solid #dbe4fb;
    border-radius: 14px;
  }
}

.topbar-slim {
  flex-wrap: wrap;
  gap: 8px;
}

.topbar-slim .auth {
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-page h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.admin-page h2 {
  margin: 24px 0 10px;
  font-size: 1.1rem;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0 6px;
}

.admin-search-row {
  margin-bottom: 10px;
}

.admin-table-wrap--spaced {
  margin-top: 10px;
}

.admin-tab-btn {
  background: #fff;
  border-color: var(--border);
}

.admin-tab-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.admin-tab-panel {
  display: none;
}

.admin-tab-panel.active {
  display: block;
}

.admin-modal-card {
  width: min(720px, 94vw);
  max-height: 86vh;
  overflow-y: auto;
}

.admin-mini-list {
  display: grid;
  gap: 6px;
}

.admin-mini-list-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  font-size: 13px;
}

.admin-mini-list-item .admin-row-actions {
  margin-top: 8px;
}

.agency-broker-prop-card {
  border-color: #dbe4fb;
  background: #fbfdff;
}

.agency-broker-prop-title {
  font-weight: 600;
  color: #1f2a44;
  line-height: 1.35;
}

.agency-broker-prop-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
  margin-top: 8px;
}

.agency-broker-prop-owner-select {
  min-width: 0;
}

.agency-broker-prop-owner-save {
  white-space: nowrap;
}

.agency-broker-prop-actions {
  margin-top: 8px;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.admin-stat {
  text-align: center;
  padding: 16px;
}

.admin-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--brand);
}

.admin-table-wrap {
  overflow-x: auto;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  background: #f4f6fb;
  font-weight: 600;
  font-size: 13px;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-demo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  user-select: none;
}

.admin-demo-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.admin-demo-modal-row {
  margin: 12px 0 0;
}

.admin-table code {
  font-size: 12px;
  word-break: break-all;
}

.admin-row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agency-prop-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(112px, 1fr));
  gap: 8px;
  min-width: 240px;
}

.agency-prop-actions .danger-btn {
  grid-column: 1 / -1;
}

.admin-prop-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-prop-thumb {
  width: 56px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f4f6fb;
  flex-shrink: 0;
}

.danger-btn {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.danger-btn:hover {
  background: #991b1b;
  border-color: #991b1b;
}

@media (max-width: 900px), ((max-width: 1366px) and (pointer: coarse)) {
  .admin-page {
    margin: 10px auto;
    padding: 0 10px 18px;
  }

  .admin-tabs {
    flex-wrap: wrap;
  }

  .admin-tab-btn {
    flex: 1 1 0;
    min-height: 42px;
  }

  .admin-search-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .admin-search-row .btn,
  .admin-search-row input {
    width: 100%;
  }

  .admin-table {
    font-size: 13px;
    border: 0;
    background: transparent;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
    width: 100%;
  }

  .admin-table tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    margin-bottom: 10px;
    padding: 8px 10px;
  }

  .admin-table td {
    padding: 6px 0;
    border-bottom: 1px dashed #e8edf7;
  }

  .admin-table td:last-child {
    border-bottom: 0;
    padding-bottom: 2px;
  }

  .admin-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 2px;
    font-weight: 600;
  }

  .admin-row-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .agency-prop-actions {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .admin-row-actions .btn {
    width: 100%;
    min-height: 38px;
  }

  .admin-modal-card {
    width: 100%;
    max-width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .admin-mini-list-item {
    font-size: 12px;
    line-height: 1.45;
    display: grid;
    gap: 8px;
  }

  .agency-broker-prop-controls {
    grid-template-columns: 1fr;
  }

  .agency-broker-prop-owner-save {
    width: 100%;
    min-height: 38px;
  }

  .agency-broker-prop-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .admin-prop-thumb {
    width: 88px;
    height: 62px;
  }
}

@media (min-width: 901px) and (pointer: fine) {
  .auth-modal.active {
    align-items: center;
  }

  .auth-modal-content {
    border-radius: 16px;
  }
}
