/* Светлый вид в духе iOS: белый фон, фото без рамок, текст в три веса, зелёный NiSea — только для действий. */
:root {
  --bg: #ffffff;
  --surface: #f5f5f7;
  --fill: #f2f2f4;
  --text: #111111;
  --body: #3a3a3c;
  --secondary: #86868b;
  --hairline: #e5e5ea;
  --accent: #17603a;
  --accent-soft: rgba(23, 96, 58, 0.09);
  --tertiary: #c7c7cc;
  --red: #ff3b30;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI Variable Display', 'Segoe UI', system-ui, sans-serif;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --gutter: 16px;
  --top-inset: var(--tg-content-safe-area-inset-top, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 var(--font); letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
svg { display: block; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
a { color: inherit; }

/* ——— шапка ——— */
.top { padding: calc(10px + var(--top-inset)) var(--gutter) 0; }
.bar { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.logo { height: 26px; width: auto; display: block; }
.saved-title { display: none; margin: 0; font: 600 20px/1 var(--display); letter-spacing: -0.02em; }
.icon-btn { position: relative; display: grid; place-items: center; width: 44px; height: 44px; margin-right: -10px; color: var(--text); }
.icon-btn svg { width: 24px; height: 24px; stroke-width: 1.75; }
.icon-btn .n { position: absolute; top: 8px; right: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; line-height: 17px; text-align: center; letter-spacing: 0; }
.icon-btn.done { width: auto; padding: 0 10px; color: var(--accent); font-size: 16px; font-weight: 600; }

.controls { padding-top: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 12px; background: var(--fill); color: var(--secondary); }
.search svg { width: 18px; height: 18px; stroke-width: 2.2; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); font-size: 16px; }
.search input::placeholder { color: var(--secondary); }
.filter { width: 44px; margin: 0; border-radius: 12px; background: var(--fill); }
.filter svg { width: 20px; height: 20px; }
.filter.on { background: var(--accent-soft); color: var(--accent); }
.logo { cursor: pointer; }

.segmented { position: relative; display: grid; grid-template-columns: 1fr 1fr; margin-top: 10px; padding: 2px; border-radius: 10px; background: var(--fill); }
.segmented button { position: relative; z-index: 1; height: 32px; font-size: 14px; font-weight: 500; color: var(--secondary); transition: color 0.2s; }
.segmented button.on { color: #fff; font-weight: 600; }
.segmented .thumb { position: absolute; top: 2px; left: 2px; bottom: 2px; width: calc(50% - 2px); border-radius: 8px; background: var(--accent); box-shadow: 0 1px 3px rgba(23, 96, 58, 0.35); transition: transform 0.35s var(--ease); }
.segmented.rent .thumb { transform: translateX(100%); }

.meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; margin-top: 2px; color: var(--secondary); font-size: 15px; }
.summary { min-width: 0; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.clear { display: inline-flex; align-items: center; gap: 4px; min-width: 0; height: 30px; padding: 0 8px 0 10px; border-radius: 15px; background: var(--fill); color: var(--text); font-size: 14px; font-weight: 500; }
.clear span { overflow: hidden; text-overflow: ellipsis; }
.clear svg { width: 14px; height: 14px; stroke-width: 2.4; color: var(--secondary); }
.clear::after { content: ''; position: absolute; inset: -7px 0; }
.clear { position: relative; }
#sort-btn { display: inline-flex; align-items: center; gap: 2px; height: 44px; margin-right: -4px; padding: 0 4px; color: var(--secondary); font-weight: 500; }
#sort-btn svg { width: 16px; height: 16px; stroke-width: 2.2; }

body.saved-mode .logo, body.saved-mode .controls, body.saved-mode .meta { display: none; }
body.saved-mode .list { padding-top: 12px; }
body.saved-mode .saved-title { display: block; }

/* ——— список ——— */
.list { display: grid; gap: 32px; padding: 4px var(--gutter) 0; }
@media (min-width: 720px) { .list { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
.card { content-visibility: auto; contain-intrinsic-size: auto 340px; cursor: pointer; }
.card .gallery { border-radius: 16px; aspect-ratio: 3 / 2; transform: translateZ(0); transition: transform 0.25s var(--ease); }
.card:active .gallery { transform: scale(0.985); }
.card .body { padding-top: 12px; }
.card .price { line-height: 1.2; }
.price { font: 700 21px/1.25 var(--display); letter-spacing: -0.015em; }
.price small { margin-left: 6px; font: 400 14px var(--font); color: var(--secondary); letter-spacing: 0; }
.line { margin-top: 1px; font-size: 15px; font-weight: 400; color: var(--body); }
.line2 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 6px; font-size: 15px; color: var(--secondary); }
.line2 span { display: inline-flex; align-items: center; gap: 5px; }
.line2 svg { width: 17px; height: 17px; stroke-width: 1.7; }

/* ——— фото ——— */
.gallery { position: relative; overflow: hidden; background: var(--surface); }
.track { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.track::-webkit-scrollbar { display: none; }
.slide { flex: none; width: 100%; height: 100%; scroll-snap-align: center; scroll-snap-stop: always; background-size: cover; background-position: center; }
.slide img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 0.3s; }
.slide img.ready { opacity: 1; }
.dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; justify-content: center; gap: 5px; pointer-events: none; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.6); box-shadow: 0 0 2px rgba(0, 0, 0, 0.25); transition: background 0.2s; }
.dots i.on { background: #fff; }
/* Стрелки листания — только там, где есть мышь; появляются при наведении на фото. */
.nav { position: absolute; top: 50%; z-index: 2; display: none; place-items: center; width: 36px; height: 36px; margin-top: -18px; border-radius: 18px; color: var(--text); background: rgba(255, 255, 255, 0.92); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); opacity: 0; transition: opacity 0.2s; }
.nav svg { width: 18px; height: 18px; stroke-width: 2.4; }
.nav.prev { left: 10px; }
.nav.next { right: 10px; }
@media (hover: hover) and (pointer: fine) {
  .nav { display: grid; }
  .gallery:hover .nav { opacity: 1; }
  .gallery.at-start .nav.prev, .gallery.at-end .nav.next { opacity: 0 !important; pointer-events: none; }
}
.fav { position: absolute; top: 2px; right: 2px; display: grid; place-items: center; width: 48px; height: 48px; color: #fff; }
.fav svg { width: 24px; height: 24px; stroke-width: 2; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35)); transition: transform 0.2s var(--ease); }
.fav:active svg { transform: scale(0.85); }
.fav.on svg { fill: var(--red); stroke: var(--red); animation: pop 0.35s var(--ease); }
@keyframes pop { 40% { transform: scale(1.25); } }

.empty { padding: 72px 24px; text-align: center; color: var(--secondary); font-size: 15px; }
.empty b { display: block; margin-bottom: 4px; color: var(--text); font-size: 17px; font-weight: 600; }
.empty button { margin-top: 8px; height: 44px; padding: 0 12px; color: var(--accent); font-weight: 500; }

/* Кнопка «наверх»: появляется, когда список прокручен далеко вниз. */
.to-top { position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 15; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 22px; color: var(--accent); background: rgba(255, 255, 255, 0.94); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16); opacity: 0; transform: translateY(12px) scale(0.9); pointer-events: none; transition: opacity 0.25s, transform 0.3s var(--ease); }
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top svg { width: 22px; height: 22px; stroke-width: 2.4; }
@media (min-width: 900px) { .to-top { right: max(16px, calc(50% - 600px)); } }

/* ——— страница объекта ——— */
.detail { position: fixed; inset: 0; z-index: 20; overflow-y: auto; background: var(--bg); overscroll-behavior: contain; animation: push-in 0.42s var(--ease); }
.detail.out { animation: push-out 0.3s var(--ease) forwards; pointer-events: none; }
@keyframes push-in { from { transform: translateX(100%); } }
@keyframes push-out { to { transform: translateX(100%); } }
.detail .gallery { aspect-ratio: 4 / 3; max-height: 55vh; width: 100%; }
@media (min-width: 720px) { .detail .gallery { aspect-ratio: 16 / 9; } }
.counter { position: absolute; right: 12px; bottom: 12px; padding: 3px 8px; border-radius: 6px; color: #fff; font-size: 12px; font-weight: 500; background: rgba(0, 0, 0, 0.4); font-variant-numeric: tabular-nums; pointer-events: none; }
.round { position: absolute; top: calc(10px + var(--top-inset)); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 18px; color: var(--text); background: rgba(255, 255, 255, 0.9); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.round::after { content: ''; position: absolute; inset: -4px; }
.round svg { width: 18px; height: 18px; stroke-width: 2.2; }
.round.back { left: 12px; }
.round.share { right: 56px; }
.round.save { right: 12px; }
.round.save.on svg { fill: var(--red); stroke: var(--red); animation: pop 0.35s var(--ease); }
.in-tg .round.back { display: none; }
.back-bar { display: none; }

.content { padding: 22px var(--gutter) 0; }
/* Взгляд идёт так: фото → цена → что это и где → главные цифры → подробности. Зелёный — только у действий. */
.big-price { font: 700 30px/1.1 var(--display); letter-spacing: -0.025em; }
.big-price small { margin-left: 6px; font: 500 16px var(--font); color: var(--secondary); letter-spacing: 0; }
.title { margin: 10px 0 0; font: 600 22px/1.25 var(--display); letter-spacing: -0.02em; }
.content .place { display: flex; align-items: center; gap: 5px; margin-top: 6px; color: var(--secondary); font-size: 15px; }
.content .place svg { width: 16px; height: 16px; stroke-width: 2; }
.sub { margin-top: 4px; color: var(--secondary); font-size: 14px; letter-spacing: 0; }
.facts { display: grid; margin-top: 20px; padding: 14px 4px; border-radius: 16px; background: var(--surface); }
.facts div { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.facts div + div { border-left: 1px solid var(--hairline); }
.facts svg { width: 20px; height: 20px; margin-bottom: 4px; color: var(--secondary); stroke-width: 1.7; }
.facts b { font: 600 19px/1.2 var(--display); }
.facts span { color: var(--secondary); font-size: 12px; }
.group { margin-top: 32px; }
.group h3 { margin: 0 0 12px; font: 700 20px/1.2 var(--display); letter-spacing: -0.02em; }
.text p { margin: 0 0 10px; color: var(--body); font-size: 16px; line-height: 1.55; }
.text.clamp { max-height: 7.75em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.more { display: flex; align-items: center; height: 44px; text-align: left; color: var(--accent); font-size: 15px; font-weight: 600; }
.rows { margin: 0; padding: 0; list-style: none; }
.rows li { display: flex; align-items: center; gap: 14px; min-height: 44px; padding: 10px 0; color: var(--text); font-size: 16px; line-height: 1.35; }
.rows li + li, .rest li:first-child { border-top: 1px solid var(--hairline); margin-left: 36px; }
.rows li + li .ico, .rest li:first-child .ico { margin-left: -36px; }
.ico { flex: none; display: grid; place-items: center; width: 22px; height: 22px; color: var(--secondary); }
.ico svg { width: 22px; height: 22px; stroke-width: 1.6; }
.maps { text-decoration: none; }
.text { max-width: 620px; }
.cta { position: sticky; bottom: 0; margin: 28px calc(-1 * var(--gutter)) 0; padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--hairline); }
.cta a { display: grid; place-items: center; height: 50px; border-radius: 12px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; text-decoration: none; }
.in-tg .cta { display: none; }
.in-tg .content { padding-bottom: 28px; }

/* ——— фильтры ——— */
.sheet { position: fixed; inset: 0; z-index: 25; }
.backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.3); animation: fade 0.25s; }
.panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow-y: auto; padding: 8px var(--gutter) calc(16px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; background: var(--bg); animation: up 0.38s var(--ease); overscroll-behavior: contain; }
.sheet.out { pointer-events: none; }
.sheet.out .panel { animation: down 0.25s var(--ease) forwards; }
.sheet.out .backdrop { animation: fade 0.25s reverse forwards; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes down { to { transform: translateY(100%); } }
.grabber { width: 36px; height: 5px; margin: 0 auto 6px; border-radius: 3px; background: var(--hairline); }
.panel-head { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.panel-head b { font: 600 17px var(--display); }
.panel-head button { height: 44px; padding: 0 2px; color: var(--accent); font-weight: 500; }
.panel-head button:disabled { color: var(--secondary); opacity: 0.5; }
.fgroup { margin-top: 18px; }
.fgroup h4 { margin: 0 0 10px; color: var(--secondary); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { height: 40px; padding: 0 14px; border-radius: 20px; background: var(--fill); font-size: 15px; font-weight: 500; transition: background 0.15s, color 0.15s; }
.pill.on { background: var(--accent); color: #fff; }
.choices { margin: 4px 0 0; padding: 0; list-style: none; }
.choices button { display: flex; align-items: center; justify-content: space-between; width: 100%; height: 52px; border-bottom: 1px solid var(--hairline); font-size: 17px; }
.choices li:last-child button { border-bottom: 0; }
.choices svg { width: 20px; height: 20px; stroke-width: 2.4; color: var(--accent); }
.apply { display: block; width: 100%; height: 50px; margin-top: 24px; border-radius: 12px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; }

@keyframes fade { from { opacity: 0; } }

/* На большом экране — колонка по центру, а не полоса во всю ширину. */
@media (min-width: 900px) {
  .top, .list { max-width: 1120px; margin-left: auto; margin-right: auto; }
  .detail > .gallery, .detail > .content { max-width: 760px; margin-left: auto; margin-right: auto; }
  .detail > .gallery { border-radius: 16px; }
  .back-bar { display: flex; align-items: center; gap: 4px; width: 100%; max-width: 760px; height: 52px; margin: 8px auto 0; padding: 0 4px; color: var(--accent); font-size: 16px; font-weight: 500; }
  .back-bar svg { width: 20px; height: 20px; stroke-width: 2.2; }
  .in-tg .back-bar { display: none; }
  .round.back { display: none; }
  .cta a { max-width: 360px; }
  .controls { display: flex; align-items: center; gap: 12px; padding-top: 4px; }
  .controls .row { flex: 1; }
  .segmented { width: 220px; margin-top: 0; }
  .panel { max-width: 520px; margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
