:root {
  --bg: #f5f1e8;
  --panel: #fffaf0;
  --ink: #27231c;
  --muted: #746b5d;
  --line: rgba(39, 35, 28, 0.16);
  --active: #13945d;
  --archive: #cf3d34;
  --owner-yes: #dff3e6;
  --coffee: #8b5a2b;
  --food: #e07a2f;
  --sport: #2f6f8f;
  --supermarket: #5f8c2f;
  --other: #2f6a92;
  --shadow: 0 18px 48px rgba(50, 42, 29, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.app {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 10% -20%, rgba(19, 148, 93, 0.18), transparent 34%),
    radial-gradient(circle at 90% 0%, rgba(207, 61, 52, 0.14), transparent 30%),
    var(--panel);
}

.title {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.title strong {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.title span {
  color: var(--muted);
  font-size: 12px;
}

.legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.layer-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 3px 2px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.layer-toggle:hover,
.layer-toggle:focus-visible {
  color: var(--ink);
  outline: none;
}

.layer-toggle:focus-visible {
  box-shadow: 0 0 0 3px rgba(19, 148, 93, 0.18);
}

.layer-toggle.is-off {
  opacity: 0.38;
}

.layer-toggle.is-off .dot {
  background: transparent;
}

.dot {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: var(--panel);
  display: inline-block;
}

.dot.active {
  border: 3px solid var(--active);
}

.dot.archive {
  border: 3px solid var(--archive);
}

.dot.coffee {
  border: 3px solid var(--coffee);
}

.dot.food {
  border: 3px solid var(--food);
}

.dot.sport {
  border: 3px solid var(--sport);
}

.dot.supermarket {
  border: 3px solid var(--supermarket);
}

.dot.owner-yes {
  border: 1px solid var(--line);
  background: var(--owner-yes);
}

.dot.owner-no {
  border: 1px solid var(--line);
  background: var(--panel);
}

.map-shell {
  width: 100%;
  min-height: 0;
  height: 100%;
}

.price-pin {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 250, 240, 0.96);
  color: var(--ink);
  border: 4px solid var(--active);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  transform: translate(-27px, -27px);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.price-pin.archive {
  border-color: var(--archive);
}

.price-pin.active {
  border-color: var(--active);
}

.price-pin.owner-yes {
  background: var(--owner-yes);
}

.price-pin.message-sent {
  background: #fff2ad;
}

.coffee-pin,
.food-pin,
.sport-pin,
.supermarket-pin,
.other-pin {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 250, 240, 0.98);
  box-shadow: 0 7px 18px rgba(0, 0, 0, 0.2);
  transform: translate(-17px, -17px);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.coffee-pin {
  color: var(--coffee);
  border: 1px solid var(--coffee);
}

.food-pin {
  color: var(--food);
  border: 1px solid var(--food);
}

.sport-pin {
  color: var(--sport);
  border: 1px solid var(--sport);
}

.supermarket-pin {
  color: var(--supermarket);
  border: 1px solid var(--supermarket);
}

.other-pin {
  color: var(--other);
  border: 1px solid var(--other);
}

.balloon {
  width: 260px;
  max-width: 100%;
  padding: 4px 0;
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
}

.apartment-balloon.has-photo {
  width: 460px;
  display: grid;
  grid-template-columns: 185px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.balloon-photo-wrap {
  position: relative;
  min-height: 196px;
  overflow: hidden;
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(39, 35, 28, 0.12), rgba(39, 35, 28, 0.04)),
    var(--panel);
}

.balloon-photo-button {
  all: unset;
  display: block;
  width: 100%;
  height: 100%;
  cursor: zoom-in;
}

.balloon-photo {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 196px;
  object-fit: cover;
}

.balloon-photo-count {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  background: rgba(22, 20, 16, 0.68);
  backdrop-filter: blur(8px);
}

.balloon-details {
  min-width: 0;
}

.balloon-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
}

.balloon-title-link {
  color: var(--ink);
  text-decoration: none;
}

.balloon-title-link:hover {
  color: #1168b4;
}

.balloon-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
  padding: 5px 0;
  border-top: 1px solid rgba(39, 35, 28, 0.1);
}

.balloon-row:first-of-type {
  border-top: 0;
}

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

.balloon-value {
  overflow-wrap: anywhere;
}

.balloon-link {
  color: #1168b4;
  text-decoration: none;
  font-weight: 650;
}

.balloon-message-button {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #27231c;
  color: #fffaf0;
  font-weight: 750;
  text-decoration: none;
}

.balloon-message-button:hover {
  background: #1168b4;
}

.phone-link {
  white-space: nowrap;
}

.communication-status-select {
  width: 100%;
  min-width: 0;
  padding: 5px 26px 5px 8px;
  border: 1px solid rgba(39, 35, 28, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.92);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.communication-status-select:disabled {
  cursor: wait;
  opacity: 0.66;
}

body.gallery-open {
  overflow: hidden;
}

.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gallery-modal[hidden] {
  display: none;
}

.gallery-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(22, 20, 16, 0.78);
  backdrop-filter: blur(10px);
}

.gallery-dialog {
  position: relative;
  z-index: 1;
  width: min(960px, 96vw);
  max-height: 94vh;
  padding: 16px;
  border-radius: 24px;
  background: #14120f;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.gallery-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
}

.gallery-title {
  display: inline-block;
  max-width: calc(100% - 52px);
  margin: 0 0 12px;
  color: #fff;
  font-weight: 750;
  text-decoration: none;
}

.gallery-title:hover {
  text-decoration: underline;
}

.gallery-stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 420px;
  border-radius: 18px;
  background: #080706;
}

.gallery-image {
  display: block;
  max-width: 100%;
  max-height: min(74vh, 760px);
  object-fit: contain;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 44px;
  height: 64px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  font-size: 42px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transform: translateY(-50%);
}

.gallery-nav:disabled {
  opacity: 0.25;
  cursor: default;
}

.gallery-prev {
  left: 14px;
}

.gallery-next {
  right: 14px;
}

.gallery-meta {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.76);
  text-align: center;
  font-weight: 650;
}

.error {
  max-width: 720px;
  margin: 40px auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .legend {
    justify-content: flex-start;
  }

  .map-shell {
    min-height: calc(100vh - 245px);
  }

  .apartment-balloon.has-photo {
    width: min(82vw, 320px);
    display: block;
  }

  .balloon-photo-wrap {
    min-height: 170px;
    margin-bottom: 10px;
  }

  .balloon-photo {
    min-height: 170px;
  }

  .gallery-dialog {
    width: 96vw;
    padding: 12px;
    border-radius: 18px;
  }

  .gallery-stage {
    min-height: 320px;
  }

  .gallery-nav {
    width: 38px;
    height: 56px;
    font-size: 36px;
  }
}
