:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --brand: #7e2226;
  --brand-strong: #64171b;
  --text: #414141;
  --muted: #7b7474;
  --surface: #ffffff;
  --surface-soft: #f3f3f3;
  --line: #e3e3e3;
  --pink: #f29199;
  --red: #f23d4c;
  --shadow: 0 10px 28px rgba(47, 24, 26, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  min-width: 100%;
  height: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background: #ffffff;
  color: var(--text);
}

button {
  border: 0;
  font: inherit;
}

.telegram-app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: #ffffff;
}

.map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-canvas::after {
  position: absolute;
  inset: 0;
  z-index: 450;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58) 0%, rgba(255, 255, 255, 0.08) 20%, rgba(255, 255, 255, 0) 40%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.48) 0%, rgba(255, 255, 255, 0) 24%);
}

.leaflet-control-container .leaflet-top,
.leaflet-control-container .leaflet-bottom {
  display: none;
}

.leaflet-tile-pane {
  filter: saturate(0.78) contrast(0.98) brightness(1.03);
}

.topbar {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.brand-block,
.icon-button,
.filter-chip,
.list-toggle,
.map-control,
.property-card,
.list-sheet {
  border: 1px solid rgba(65, 65, 65, 0.1);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 10px;
  border-radius: 8px;
  pointer-events: auto;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.brand-block strong,
.sheet-header strong {
  display: block;
  color: var(--brand);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
}

.brand-block span:last-child {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.icon-button {
  display: none;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  color: var(--brand);
  font-weight: 800;
  pointer-events: auto;
}

.filter-rail {
  position: absolute;
  top: calc(76px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  z-index: 590;
  display: flex;
  gap: 8px;
  padding: 0 14px 10px;
  overflow-x: auto;
  pointer-events: auto;
  scrollbar-width: none;
}

.filter-rail::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.filter-chip.active {
  border-color: rgba(126, 34, 38, 0.32);
  background: var(--brand);
  color: #fff;
}

.stats-panel {
  display: none;
  position: absolute;
  top: calc(128px + env(safe-area-inset-top));
  left: 14px;
  z-index: 580;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.stats-panel strong {
  color: var(--brand);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

.map-control,
.list-toggle {
  position: absolute;
  z-index: 590;
  pointer-events: auto;
}

.map-control {
  right: 14px;
  bottom: calc(188px + env(safe-area-inset-bottom));
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
}

.map-control span {
  width: 17px;
  height: 17px;
  border: 3px solid var(--brand);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px #fff;
}

.list-toggle {
  right: 14px;
  bottom: calc(130px + env(safe-area-inset-bottom));
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--brand);
  font-weight: 900;
}

.list-toggle strong {
  display: grid;
  min-width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
}

.price-marker {
  position: relative;
  padding: 7px 11px;
  border: 1px solid rgba(126, 34, 38, 0.2);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(64, 24, 26, 0.2);
  color: var(--brand);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.price-marker::after {
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(126, 34, 38, 0.2);
  border-bottom: 1px solid rgba(126, 34, 38, 0.2);
  background: inherit;
  content: "";
  transform: translateX(-50%) rotate(45deg);
}

.price-marker.selected {
  background: var(--brand);
  color: #fff;
  transform: translateY(-4px);
}

.cluster-marker {
  display: grid;
  width: 74px;
  height: 74px;
  place-items: center;
  padding: 10px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 10px 24px rgba(64, 24, 26, 0.18);
  color: #fff;
  text-align: center;
}

.cluster-marker strong {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 19px;
  line-height: 0.95;
}

.cluster-marker span,
.cluster-marker small {
  display: block;
  max-width: 60px;
  overflow: hidden;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cluster-marker small {
  opacity: 0.82;
}

.preview-marker {
  display: grid;
  grid-template-columns: 42px auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  min-width: 132px;
  padding: 6px 9px 6px 6px;
  border: 1px solid rgba(126, 34, 38, 0.22);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(64, 24, 26, 0.16);
  color: var(--brand);
}

.preview-marker::after {
  position: absolute;
  bottom: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(126, 34, 38, 0.22);
  border-bottom: 1px solid rgba(126, 34, 38, 0.22);
  background: inherit;
  content: "";
  transform: translateX(-50%) rotate(45deg);
}

.preview-marker span {
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background-position: center;
  background-size: cover;
}

.preview-marker strong {
  align-self: end;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  line-height: 1;
}

.preview-marker small {
  align-self: start;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
}

.preview-marker.selected {
  border-color: rgba(126, 34, 38, 0.48);
  transform: translateY(-4px);
}

.property-card {
  position: absolute;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 12px;
  z-index: 620;
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 12px;
  max-height: 38dvh;
  padding: 10px;
  border-radius: 8px;
  transform: translateY(0);
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.property-card.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(100% + 24px));
}

.card-handle {
  position: absolute;
  top: 7px;
  left: 50%;
  display: none;
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: #ded8d8;
  transform: translateX(-50%);
}

.property-media {
  min-height: 148px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(126, 34, 38, 0.28), rgba(242, 145, 153, 0.16)),
    var(--photo-url),
    linear-gradient(135deg, #eadfdf, #ffffff);
  background-position: center;
  background-size: cover;
}

.property-content {
  min-width: 0;
}

.property-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.eyeline {
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 8px;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(16px, 3.8vw, 21px);
  line-height: 1.18;
}

.share-button,
.ghost-action,
.sheet-header button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
}

.price-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 9px;
}

.price-row strong {
  color: var(--brand);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 20px;
}

.price-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.facts-row,
.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.fact,
.feature {
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
}

.feature {
  background: rgba(242, 145, 153, 0.18);
  color: var(--brand);
}

#propertyDescription {
  display: -webkit-box;
  margin: 0 0 11px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.primary-action {
  flex: 1;
  min-height: 40px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.ghost-action {
  min-width: 86px;
}

.list-sheet {
  position: absolute;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 12px;
  z-index: 650;
  max-height: 70dvh;
  padding: 12px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(100% + 24px));
  transition: transform 0.26s ease, opacity 0.26s ease;
}

.list-sheet.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.listing-list {
  display: grid;
  max-height: calc(70dvh - 70px);
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.listing-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.listing-thumb {
  border-radius: 8px;
  background: var(--photo-url) center / cover, linear-gradient(135deg, #eadfdf, #fff);
}

.listing-row strong {
  display: block;
  color: var(--brand);
  font-family: "Unbounded", sans-serif;
  font-size: 13px;
}

.listing-row span {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-row small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

@media (min-width: 760px) {
  .topbar {
    top: 22px;
    left: 24px;
    right: auto;
  }

  .filter-rail {
    top: 88px;
    right: auto;
    left: 24px;
    width: min(720px, calc(100vw - 48px));
    padding-inline: 0;
  }

  .stats-panel {
    top: 144px;
    left: 24px;
  }

  .property-card {
    right: 24px;
    bottom: 24px;
    left: auto;
    width: min(520px, calc(100vw - 48px));
  }

  .list-sheet {
    right: 24px;
    bottom: 24px;
    left: auto;
    width: 430px;
  }

  .map-control {
    right: 24px;
    bottom: 238px;
  }

  .list-toggle {
    right: 24px;
    bottom: 176px;
  }
}

@media (max-width: 430px) {
  .property-card {
    grid-template-columns: 1fr;
    max-height: 58dvh;
    padding-top: 18px;
  }

  .card-handle {
    display: block;
  }

  .property-media {
    min-height: 126px;
  }

  .brand-block span:last-child {
    display: none;
  }

  .map-control {
    bottom: calc(320px + env(safe-area-inset-bottom));
  }

  .list-toggle {
    bottom: calc(264px + env(safe-area-inset-bottom));
  }
}
