:root {
  --bg: #f5f4f0;
  --card: #ffffff;
  --text: #1d1f21;
  --muted: #6a6f75;
  --line: #e5e2db;
  --accent: #0e7a5a;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1eb;
  --warn-soft: #fdf1dc;
  --warn: #8a5a00;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 24, 28, 0.06), 0 4px 14px rgba(20, 24, 28, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Шапка ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 20px; flex: none;
}
.brand b { display: block; font-size: 18px; line-height: 1.2; }
.brand small { display: block; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
}

/* ---------- Фильтры ---------- */
.seg { display: flex; background: #eae8e2; border-radius: 12px; padding: 3px; gap: 2px; }
.seg button {
  flex: 1 1 0; min-width: 0; min-height: 40px; border: 0; border-radius: 10px; background: transparent; font-size: 15px; color: var(--muted); padding: 0 6px; white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.controls { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.search-row { display: flex; gap: 8px; }
.search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; min-height: 46px; color: var(--muted);
}
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 16px; color: var(--text); height: 44px; }
.filter-btn {
  display: flex; align-items: center; gap: 6px; padding: 0 12px; min-height: 46px; border-radius: 12px; flex: none;
  border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 15px;
}
.filter-btn .dot { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; display: none; place-items: center; }
.filter-btn.on .dot { display: grid; }
.count { color: var(--muted); font-size: 15px; margin: 14px 0 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.count button { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 15px; padding: 8px 0; }

/* ---------- Карточки каталога ---------- */
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; padding-bottom: 40px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: block; }
.card-img { position: relative; aspect-ratio: 4 / 3; background: #e8e6e0; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.badges { position: absolute; left: 10px; right: 10px; top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 14px;
  background: rgba(255,255,255,.94); font-size: 13px; font-weight: 600; color: var(--text);
}
.badge.vid { background: var(--accent); color: #fff; }
.badge.vid svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.badge.reserved { background: var(--warn-soft); color: var(--warn); }
.photo-count { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.55); color: #fff; font-size: 13px; padding: 3px 8px; border-radius: 10px; }
.card-body { padding: 12px 14px 14px; }
.card-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.price { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.code {
  font: 600 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .03em;
  padding: 6px 8px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.card-title { font-weight: 600; margin-top: 4px; }
.card-spec { color: var(--text); font-size: 15px; margin-top: 2px; }
.card-place { color: var(--muted); font-size: 15px; margin-top: 2px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; grid-column: 1 / -1; }

/* ---------- Нижняя панель фильтров ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 88vh;
  border-radius: 20px 20px 0 0; background: var(--card); color: var(--text);
}
dialog.sheet::backdrop { background: rgba(20, 22, 24, .45); }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 20px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.sheet-head h2 { font-size: 19px; margin: 0; }
.sheet-body { padding: 4px 16px 16px; overflow-y: auto; display: grid; gap: 18px; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.field-label { font-size: 14px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--card); font-size: 15px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.range { display: flex; gap: 10px; align-items: center; }
.input {
  width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px;
}
.input:focus, .search:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 12px; }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 15px; background: #d9d6cf; position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  font-weight: 600; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.grow { flex: 1; }

/* ---------- Карточка объекта ---------- */
.obj-top {
  position: sticky; top: 0; z-index: 5; background: rgba(245,244,240,.94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.obj-top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; min-height: 44px; padding-right: 8px; }
.obj { max-width: 760px; margin: 0 auto; padding: 0 0 120px; }
.media-block { background: #111; }
.video-tabs { display: flex; gap: 6px; padding: 8px 16px 0; background: #111; overflow-x: auto; }
.video-tabs button { border: 0; border-radius: 16px; min-height: 36px; padding: 0 14px; background: #2a2a2a; color: #ddd; font-size: 14px; }
.video-tabs button[aria-pressed="true"] { background: #fff; color: #111; font-weight: 600; }
.video { position: relative; margin: 0 auto; background: #000; width: 100%; aspect-ratio: 16 / 9; }
.video.short { aspect-ratio: 9 / 16; width: min(100%, calc(58vh * 9 / 16)); }
.video iframe, .video .poster { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video .poster { padding: 0; border: 0; background: #1b1b1b center / cover no-repeat; display: grid; place-items: center; color: #fff; }
.play { width: 72px; height: 72px; border-radius: 50%; background: rgba(0,0,0,.6); display: grid; place-items: center; }
.play svg { width: 30px; height: 30px; fill: #fff; stroke: none; margin-left: 4px; }
.poster-note { position: absolute; left: 12px; right: 12px; bottom: 14px; text-align: center; font-size: 15px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.video.placeholder .poster { background: linear-gradient(160deg, #3a3f44, #22262a); }
.video-caption { color: #cfcfcf; background: #111; font-size: 14px; padding: 8px 16px 12px; display: flex; align-items: center; gap: 6px; }

.gallery { position: relative; background: #e8e6e0; }
.strip { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip > button { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 4 / 3; border: 0; padding: 0; background: #e8e6e0; }
.strip img { width: 100%; height: 100%; object-fit: cover; }
.counter { position: absolute; right: 12px; bottom: 12px; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; padding: 4px 10px; border-radius: 12px; pointer-events: none; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px 0; scrollbar-width: none; }
.thumbs::-webkit-scrollbar { display: none; }
.thumbs button { flex: none; width: 64px; height: 48px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: #ddd; opacity: .7; }
.thumbs button[aria-current="true"] { border-color: var(--accent); opacity: 1; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }

.sec { padding: 16px; }
.sec + .sec { border-top: 1px solid var(--line); }
.sec h2 { font-size: 18px; margin: 0 0 12px; }
.status-banner { margin: 16px 16px 0; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.status-banner.sold { background: #eceae5; color: var(--muted); }
.code-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px dashed var(--accent); background: var(--accent-soft); color: var(--accent);
  border-radius: 10px; min-height: 40px; padding: 0 12px; font: 700 16px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em;
}
.code-btn small { font: 500 13px var(--font); letter-spacing: 0; color: var(--accent); opacity: .85; }
.obj-price { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; margin: 12px 0 2px; }
.obj-title { font-size: 20px; margin: 0; line-height: 1.3; }
.obj-spec { font-size: 16px; margin-top: 4px; }
.obj-place { color: var(--muted); margin-top: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: 14px; padding: 6px 10px; border-radius: 10px; background: #ecebe6; }
.tag.accent { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.specs { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 0; }
.specs div { background: var(--card); padding: 10px 12px; }
.specs div:last-child:nth-child(odd) { grid-column: span 2; }
.specs dt { font-size: 13px; color: var(--muted); }
.specs dd { margin: 2px 0 0; font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list li { display: flex; gap: 10px; align-items: flex-start; }
.mark { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-top: 1px; }
.mark svg { width: 14px; height: 14px; stroke-width: 3; }
.mark.progress { background: var(--warn-soft); color: var(--warn); }
.mark.no { background: #eceae5; color: var(--muted); }
.list small { display: block; color: var(--muted); font-size: 14px; }
.desc p { margin: 0 0 8px; }
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.loc-grid button { padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; aspect-ratio: 3 / 4; background: #eee; }
.loc-grid img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.agent { display: flex; align-items: center; gap: 12px; }
.agent .logo { width: 48px; height: 48px; }
.agent b { display: block; }
.agent a { color: var(--accent); font-weight: 600; }

.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: rgba(255,255,255,.97);
  border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.actionbar .in { max-width: 760px; margin: 0 auto; display: flex; gap: 8px; }
.actionbar .btn { min-height: 50px; padding: 0 12px; min-width: 0; white-space: nowrap; }
.actionbar .wa { flex: 1.3; }
.actionbar .call { flex: 1; }
.actionbar .share { flex: none; width: 52px; padding: 0; }
@media (min-width: 560px) { .actionbar .share { width: auto; padding: 0 16px; } }
.actionbar .share span { display: none; }
@media (min-width: 560px) { .actionbar .share span { display: inline; } }
.actionbar svg.i { width: 20px; height: 20px; }
.actionbar .wa svg { fill: currentColor; stroke: none; }

/* ---------- Просмотр фото на весь экран ---------- */
dialog.lightbox { border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: #000; color: #fff; }
dialog.lightbox::backdrop { background: #000; }
.lb-strip { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.lb-strip::-webkit-scrollbar { display: none; }
.lb-strip figure { flex: 0 0 100%; height: 100%; margin: 0; scroll-snap-align: center; display: grid; place-items: center; }
.lb-strip img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.lb-bar button { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; display: grid; place-items: center; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; display: none; place-items: center; }
.lb-nav.prev { left: 16px; } .lb-nav.next { right: 16px; }
@media (hover: hover) and (min-width: 800px) { .lb-nav { display: grid; } }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; z-index: 50;
  background: #1d1f21; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 15px; transition: opacity .2s, transform .2s; pointer-events: none;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.not-found { text-align: center; padding: 64px 16px; }
.not-found h1 { font-size: 22px; }
