:root {
  /* Каноническая палитра Noticasa: три цвета. */
  --terracotta: #C65D3C;
  --terracotta-dark: #A44928;
  --terracotta-soft: #E8B7A6;
  --navy: #0A2540;
  --navy-soft: #2C4363;
  --cream: #F7F3EE;
  --paper: #FFFFFF;
  --line: #E9E1D7;
  --ink: #1A1A1A;
  --ink-soft: #5D5D5D;
  /* UI-5: --sky — вспомогательная поверхность, производная от navy (hue),
     светлая (L≈95%), низкая насыщенность. ТОЛЬКО как фон реплик ассистента.
     Никогда как текст/кнопка/акцент. Контраст navy на --sky ≈ 13:1. */
  --sky: #E7F0F7;
  --shadow: 0 4px 24px rgba(15, 40, 70, .06);
  --shadow-lg: 0 12px 40px rgba(15, 40, 70, .18);
  /* Единый радиус для карточек, кнопок-примеров, полей ввода, крупных
     контейнеров. --radius-pill — для чипов и pill-кнопок. */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  /* Единая толщина обводок. */
  --border-w: 1.5px;
  /* Ритм отступов (используется в CSS gap / margin / padding). */
  --gap-xs: 8px;
  --gap-sm: 12px;
  --gap-md: 16px;
  --gap-lg: 24px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}
/* Курсор в полях ввода — терракотовый и заметный (bug: был невидим). */
input, textarea, [contenteditable="true"] {
  caret-color: var(--terracotta);
}
body {
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

/* HEADER */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top, 0)) 16px 10px;
  background: var(--cream);
}
/* Логотип Noticasa: SVG-знак + wordmark на Montserrat Alternates SemiBold.
   Блок в шапке — высота 30px. Никаких raster-битов, только вектор. */
.brand {
  background: transparent; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  /* высота — авто, чтобы поместилась и знак, и wordmark+tagline (UI-2) */
}
.brand-mark {
  height: 24px; width: auto;   /* высота знака = x-height wordmark'а */
  flex: 0 0 auto;
  transition: transform .18s ease;
  /* Страховка: если SVG когда-нибудь подключат inline и path будет
     использовать currentColor — тут terracotta. У <img src=.svg>
     currentColor не резолвится через CSS (fill забит в самом SVG). */
  color: var(--terracotta);
}
.brand-wordmark {
  font-family: 'Montserrat Alternates', 'Montserrat', system-ui, sans-serif;
  font-weight: 600;                    /* SemiBold */
  font-size: 26px;
  letter-spacing: -0.5px;
  color: var(--navy);
  line-height: 1;
  margin-top: 2px;                     /* оптическое выравнивание x-height */
}
/* UI-2: тэглайн под wordmark'ом — мелкий вторичный navy на пониженной
   opacity, не конкурирует со знаком, шапка растёт на ~10px. */
.brand-text {
  display: inline-flex; flex-direction: column;
  align-items: flex-start; line-height: 1;
}
.brand-tagline {
  font-family: 'Montserrat', system-ui, sans-serif;
  font-weight: 500; font-size: 11px;
  letter-spacing: 0.1px;
  color: var(--navy); opacity: .55;
  margin-top: 3px;
  white-space: nowrap;
}
.brand:hover, .brand:focus-visible { outline: none; }
.brand:hover .brand-mark { transform: scale(1.03); }

.icon-btn {
  background: var(--paper); border: 1px solid var(--line); color: var(--navy);
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 22px; line-height: 1;
}
.icon-btn:hover, .icon-btn:focus-visible { background: #fff; border-color: var(--terracotta); color: var(--terracotta); outline: none; }

/* SEARCH */
.search-wrap { padding: 4px 16px 8px; background: var(--cream); }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper); border-radius: 14px;
  padding: 6px 6px 6px 12px; border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.search-box .search-ico { color: var(--navy-soft); flex: 0 0 auto; }
.search-box input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--ink);
  min-width: 0; padding: 6px 0;
}
#search-clear {
  border: 0; background: transparent; color: var(--ink-soft);
  font-size: 20px; cursor: pointer; padding: 0 4px;
  visibility: hidden;
}
#search-clear.visible { visibility: visible; }
#search-submit {
  border: 0; background: var(--terracotta); color: #fff;
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: 0 0 auto;
  transition: background .12s ease;
}
#search-submit:hover, #search-submit:focus-visible {
  background: var(--terracotta-dark); outline: none;
}
#search-submit svg { transform: translateX(1px); }
/* Скрываем нативный ×-очиститель WebKit — у нас свой. */
.search-box input::-webkit-search-cancel-button,
.search-box input::-webkit-search-decoration { -webkit-appearance: none; display: none; }

/* QUICK CHIPS — единый язык:
   inactive = обводка + прозрачный фон + тёмный текст;
   active   = сплошная терракота + белый текст.
   Рублёвый чип в неактивном тоже прозрачный, только с ЦВЕТНОЙ обводкой. */
.chips {
  display: flex; gap: 8px; padding: 0 16px 10px;
  overflow-x: auto; scrollbar-width: none;
  /* UI-1: fade на правом краю (~28px) — намекает «листай», а не
     ломанная вёрстка. Статичный, работает поверх горизонтального скролла. */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--navy);
  padding: 8px 14px; border-radius: 999px;
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.chip:hover { border-color: var(--terracotta); }
.chip.active {
  background: var(--terracotta);
  color: #fff;
  border-color: var(--terracotta);
}
/* Рублёвый — ФИЛЬТР. В неактивном состоянии визуально не отличается
   от соседей (нейтральная обводка, приглушённая ₽-иконка), чтобы не
   создавать впечатление «фильтр включён по умолчанию». Активное состояние
   = базовое .chip.active (сплошная терракота), плюс белая ₽-иконка.
   UI-1: chips-spacer убран — единый gap 8px между всеми чипами. */
.chip-rubles .chip-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--line);
  font-weight: 700; font-size: 11px;
}
.chip-rubles.active .chip-ico {
  background: rgba(255, 255, 255, .22); color: #fff; border-color: transparent;
}

/* Ряд чипов внутри секции фильтров (тип, регионы, спальни, санузлы). */
.chip-row {
  display: flex; flex-wrap: wrap; gap: var(--gap-xs);
}
.region-list-empty { padding: 12px 0; color: var(--ink-soft); font-size: 13px; }
.region-chips .chip { padding: 8px 12px; }
.region-chips .chip .count {
  color: var(--ink-soft); font-weight: 500;
  font-variant-numeric: tabular-nums; margin-left: 6px;
}
.region-chips .chip.active .count { color: rgba(255,255,255,.85); }

/* Двухуровневые чипы: блок родителя + ряд под-чипов под ним. */
.region-block { display: contents; }
.region-sub {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: var(--gap-xs);
  padding: 6px 0 4px 12px;
  border-left: 2px solid var(--line);
  margin-left: 4px;
  width: 100%;
}
.region-sub .sub-chip {
  padding: 6px 10px; font-size: 12px;
  border-width: 1px;
}
.region-sub .sub-chip.active {
  background: var(--terracotta); color: #fff; border-color: var(--terracotta);
}
/* 2026-08-13 (owner fix): chevron — отдельная кнопка справа от chip'а.
   Тап по chip = применить фильтр региона (toggle). Тап по chevron =
   раскрыть/свернуть sub-муни. Раньше был двойной клик (chip раскрывал,
   а чтобы применить фильтр надо было тапнуть «Вся <регион>»). */
.region-chip-row { display: inline-flex; align-items: stretch; gap: 0; }
.region-chip-row .region-chip {
  border-top-right-radius: 0; border-bottom-right-radius: 0;
  border-right: 0;
}
.chip-chevron {
  border: 1px solid var(--line);
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  border-top-right-radius: 999px; border-bottom-right-radius: 999px;
  background: #fff; color: var(--ink);
  padding: 8px 10px; font-size: 12px; opacity: .7;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}
.chip-chevron:hover { opacity: 1; background: var(--surface-1); }
.chip-chevron[aria-expanded="true"] span { display: inline-block; transform: rotate(180deg); }
.region-chip.active + .chip-chevron {
  background: var(--terracotta); color: #fff; border-color: var(--terracotta);
  opacity: 1;
}
/* Родитель, у которого есть sub, поверх контейнера flex-wrap, а не grid.
   .region-chips использует chip-row (flex wrap). Под-чипы должны идти
   на новую строку целиком. Дают им 100% ширины: */
.region-chips { display: flex; flex-wrap: wrap; gap: var(--gap-xs); }
.region-chips .region-block { display: flex; flex-wrap: wrap; }
.region-chips .region-block .region-chip { flex: 0 0 auto; }
.region-chips .region-sub { flex: 1 0 100%; }

/* Рублёвый тумблер: в брендовых тонах, без navy-кругляша. */
.rubles-toggle {
  display: flex; align-items: center; gap: var(--gap-sm);
  padding: 14px 16px;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  cursor: pointer;
  margin-bottom: var(--gap-md);
}
.rubles-toggle input {
  appearance: none; -webkit-appearance: none; position: relative;
  width: 40px; height: 24px; border-radius: 999px;
  background: var(--line); cursor: pointer; margin: 0; flex: 0 0 auto;
  transition: background .15s ease;
}
.rubles-toggle input::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.rubles-toggle input:checked { background: var(--terracotta); }
.rubles-toggle input:checked::after { transform: translateX(16px); }
.rubles-face {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--navy); font-weight: 600;
}
.rubles-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(198, 93, 60, .12); color: var(--terracotta);
  font-weight: 700; font-size: 12px;
  transition: background .15s ease, color .15s ease;
}
.rubles-toggle:has(input:checked) { border-color: var(--terracotta); }
.rubles-toggle:has(input:checked) .rubles-ico {
  background: var(--terracotta); color: #fff;
}
.rubles-text { color: var(--navy); }

/* Дополнительно (details/summary) */
.filters-extra { border-top: 1px solid var(--line); padding-top: var(--gap-md);
                 margin-top: var(--gap-xs); }
.filters-extra summary {
  cursor: pointer; font-weight: 600; color: var(--navy);
  font-size: 14px; list-style: none; padding: 4px 0;
  display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.filters-extra summary::-webkit-details-marker { display: none; }
.filters-extra summary::after {
  content: '▾'; margin-left: auto; color: var(--ink-soft);
  transition: transform .15s ease;
}
.filters-extra[open] summary::after { transform: rotate(180deg); }
.filters-extra .field { margin-top: var(--gap-md); }

/* Значок-счётчик выбранных фильтров на иконке-фильтр в шапке */
/* «Фильтры» — визуально в паре с сортировкой (sort-btn): иконка + текст,
   ровно тот же вес, чтобы читалось не как декоративный значок. */
.filters-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 999px;
  background: transparent; border: 1px solid var(--line);
  color: var(--navy); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.filters-btn:hover { border-color: var(--terracotta); }
.filters-btn-text { line-height: 1; }
.filters-badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; border-radius: 999px;
  background: var(--terracotta); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 0 5px; line-height: 18px; text-align: center;
}

/* AI reply */
.ai-reply {
  padding: 0 16px 8px;
}
.ai-reply-inner {
  background: var(--navy); color: #fff;
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
}
.ai-label { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--terracotta-soft); font-weight: 600; }
.ai-reply-text { margin-top: 6px; font-size: 14px; line-height: 1.5; }
.ai-clarify {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
  font-size: 13px;
}

/* AI pick — выделенная карточка (среди подборки 3-х лучших) */
.card.is-pick {
  outline: 2px solid var(--terracotta);
  outline-offset: -2px;
}
.card.is-pick .card-badge {
  background: var(--terracotta); color: #fff;
}
.pick-reason {
  font-size: 12px; line-height: 1.35;
  color: var(--navy);
  padding: 8px 12px; margin: 0;
  border-top: 1px solid var(--line);
  background: rgba(185, 78, 50, .06);
}
.picks-heading, .rest-heading {
  grid-column: 1 / -1;
  font-size: 12px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600;
  padding: 4px 4px 0;
}
.expand-rest {
  grid-column: 1 / -1;
  margin: 4px 0 12px;
  padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--paper); color: var(--navy);
  font: inherit; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow);
}
.expand-rest:hover { border-color: var(--terracotta); color: var(--terracotta); }

/* FEED grid */
.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  padding: 0 12px 16px;
}
@media (min-width: 500px) {
  .feed { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; padding: 0 16px 20px; }
}

.card {
  background: var(--paper); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow);
  cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
  display: flex; flex-direction: column;
}
.card:active, .card:focus { transform: translateY(-1px); box-shadow: var(--shadow-lg); outline: none; }

.card-media {
  position: relative; aspect-ratio: 4 / 3;
  background: var(--cream);
  overflow: hidden;
}
.card-media .card-slider {
  position: absolute; inset: 0;
  display: flex; align-items: stretch;
}
.card-media img,
.card-media video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  background: var(--cream);
}
.card-media.no-image {
  display: flex; align-items: center; justify-content: center;
  background: var(--cream);
  color: var(--navy);
}
.card-media.no-image .no-image-inner {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.card-media.no-image .no-image-icon {
  width: 44px; height: 44px; opacity: .55;
}
.card-media.no-image .no-image-caption {
  font-size: 12px; line-height: 1.2; color: var(--navy-soft);
  letter-spacing: .1px;
}

/* Q4(a): skeleton пока грузится cover_preview. */
.card-media.is-loading {
  background: linear-gradient(90deg, #EFE9DD 0%, #F5F0E5 45%, #EFE9DD 100%);
  background-size: 200% 100%;
  animation: sk-shine 1.2s ease-in-out infinite;
}
.card-media.is-loading img { opacity: 0; }
@keyframes sk-shine {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.card-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(15, 40, 70, .88); color: #fff;
  font-size: 10px; padding: 3px 8px; border-radius: 8px;
  text-transform: uppercase; letter-spacing: .5px;
}
/* EB-12: приглушённая плашка «ПРОДАНО»/«СНЯТ» — стиль как у type-badge,
   но серый. Живёт 14 дней с момента deactivated_at, дальше объект
   вообще уходит из ленты. */
.card-sold-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(107, 124, 147, .92); color: #fff;
  font-size: 10px; padding: 3px 8px; border-radius: 8px;
  text-transform: uppercase; letter-spacing: .5px;
}
.card.is-sold .card-body { opacity: .68; }
.card.is-sold .card-media img { filter: grayscale(.35) brightness(.95); }

.card-rubles {
  position: absolute; top: 8px; right: 8px;
  background: var(--terracotta); color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 4px 9px 4px 5px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
  box-shadow: 0 2px 6px rgba(198, 93, 60, .35);
}
.card-rubles-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(255,255,255,.22); font-weight: 700; font-size: 11px;
}
.detail-rubles {
  margin-top: 14px; padding: 10px 12px;
  background: var(--terracotta); color: #fff;
  border-radius: 12px;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 4px 12px rgba(198, 93, 60, .25);
}
.detail-rubles-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,.22); font-weight: 700;
}
.card-body { padding: 12px 12px 14px; }
.card-price {
  font-weight: 700; color: var(--terracotta); font-size: 16px;
  line-height: 1.2;
}
.card-meta { color: var(--ink-soft); font-size: 12px; line-height: 1.4;
             margin-top: 4px; }
.card-city { color: var(--navy); font-size: 12px; font-weight: 600;
             line-height: 1.4; margin-top: 6px; }

.feed-loading, .feed-end {
  text-align: center; padding: 20px; color: var(--ink-soft); font-size: 13px;
}

/* Q7a/б: тулбар над лентой — счётчик + сортировка. */
.feed-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px 4px;
  gap: 12px;
}
.feed-toolbar[hidden] { display: none; }
.feed-count { color: var(--navy-soft); font-size: 13px; font-weight: 500; }
.feed-count #feed-count-num { color: var(--navy); font-weight: 700; }
.sort-wrap { position: relative; }
.sort-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 999px;
  font: inherit; font-size: 13px; color: var(--navy); cursor: pointer;
}
.sort-btn:active { background: var(--cream); }
.sort-btn svg { color: var(--navy-soft); }
.sort-menu {
  position: absolute; top: 100%; right: 0; margin-top: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 40, 70, .12);
  padding: 4px; min-width: 190px; z-index: 15;
  list-style: none;
}
.sort-menu[hidden] { display: none; }
.sort-item {
  padding: 10px 12px; border-radius: 8px; font-size: 14px; cursor: pointer;
  color: var(--navy);
}
.sort-item:hover { background: var(--cream); }
.sort-item.is-selected {
  color: var(--terracotta); font-weight: 600;
}
.sort-item.is-selected::after {
  content: '✓'; float: right; color: var(--terracotta);
}
/* Sentinel для infinite scroll: невидимый, но с bounding box —
   IntersectionObserver его увидит и подгрузит следующую страницу. */
.feed-sentinel {
  width: 100%; height: 1px; margin: 0; padding: 0;
}

/* PANEL (filters) */
.overlay {
  position: fixed; inset: 0; background: rgba(15,40,70,.45); z-index: 20;
}
.panel {
  position: fixed; z-index: 25; inset: auto 0 0 0;
  background: var(--paper); border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; display: flex; flex-direction: column;
  animation: slideup .22s cubic-bezier(.2,.8,.3,1);
}
@keyframes slideup { from { transform: translateY(100%);} to { transform: translateY(0);} }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--gap-md) 18px var(--gap-sm);
  border-bottom: 1px solid var(--line);
}
.panel-title { font-size: 18px; font-weight: 700; color: var(--navy); }
.panel-body {
  padding: var(--gap-md) 18px;
  /* Резервируем место под sticky-панель (Сбросить/Показать N) + safe-area
     + 16px, чтобы последний контент (тумблер рублей, «Дополнительно»)
     не залезал под неё. */
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0) + 16px);
  overflow-y: auto;
}
.panel-foot {
  padding: var(--gap-md) 18px calc(var(--gap-md) + env(safe-area-inset-bottom, 0));
  display: flex; gap: var(--gap-sm);
  border-top: 1px solid var(--line);
  background: var(--cream);
  /* Тень над панелью — чётко отделяет её от прокручиваемого контента */
  box-shadow: 0 -6px 16px rgba(10, 37, 64, .06);
  position: sticky; bottom: 0; z-index: 3;
}

.field { display: flex; flex-direction: column; gap: var(--gap-xs);
         margin-bottom: var(--gap-md); }
.field-label { font-size: 12px; color: var(--ink-soft);
               text-transform: uppercase; letter-spacing: .3px; font-weight: 600; }
.field input, .field select {
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px; font: inherit; background: var(--paper);
  color: var(--ink); outline: none;
  line-height: 1.4;
}
.field input:focus, .field select:focus { border-color: var(--terracotta); }
.row-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-sm);
}
.row-2 > * {
  /* Без этого <input type="number"> не даёт колонке ужаться и вылезает
     за viewport на 320-360px устройствах. */
  min-width: 0; width: 100%;
}
.row { display: flex; gap: var(--gap-sm); }
.row .field { flex: 1; }

.btn {
  flex: 1; border: 0; border-radius: 12px;
  padding: 12px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--terracotta); color: #fff; }
.btn.primary:hover { background: var(--terracotta-dark); }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
/* «Сбросить» приглушена, пока черновик == дефолт (Q3г). */
.btn.ghost.is-dim, .btn.ghost:disabled {
  opacity: .42; cursor: not-allowed; color: var(--muted);
}

/* Q8б: вторичная (ghost) кнопка — «Уведомлять о новых объектах».
   Основная кнопка (primary) остаётся у «Применить» / «Связаться». */
.btn.subscribe {
  display: block; width: calc(100% - 32px);
  margin: 8px 16px 16px;
  padding: 12px 16px;
  background: transparent; color: var(--navy);
  border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn.subscribe:hover {
  background: var(--cream); border-color: var(--navy);
}
.btn.subscribe.ok {
  /* Состояние «поиск сохранён» — тёмно-синий текст на кремовом фоне,
     галочка перед подписью. Без резкого терракотового обмана. */
  background: var(--cream); color: var(--navy);
  border-color: var(--cream);
  cursor: default;
}
.chat-subscribe {
  margin: 0 auto 10px;
}
/* FIX-3: тот же compact-pill в панели фильтров — не полноширинная плашка,
   а центрированный outline с колокольчиком (как в чате, см. UI-6). */
.filters-subscribe {
  margin: 6px auto 16px;
}

/* UI-6: компактный outline-pill «уведомлять о новых».
   Прозрачный фон, 1px terracotta, текст terracotta, иконка колокольчика,
   pill, по центру, ширина по контенту. Логика подписки не меняется. */
.btn-notify-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  background: transparent;
  color: var(--terracotta);
  border: 1px solid var(--terracotta);
  border-radius: 999px;
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer;
  transition: background .15s ease;
}
.btn-notify-pill:hover, .btn-notify-pill:focus-visible {
  background: rgba(198, 93, 60, .08); outline: none;
}
.btn-notify-pill svg { flex: 0 0 auto; }
.btn-notify-pill.ok {
  color: var(--navy-soft); border-color: var(--line);
  background: var(--cream); cursor: default;
}
/* Явно проверяем :not([hidden]) — иначе `.class` (0-2-0) перебивает
   стандартное `[hidden]` (0-1-0) и pill остаётся видимым, когда JS
   выставил .hidden=true. */
.chat-subscribe.btn-notify-pill:not([hidden]) { display: inline-flex; }
#chat-subscribe:not([hidden]) { align-self: center; }
.filters-subscribe:not([hidden]) { display: inline-flex; align-self: center; }

/* CHAT — полноэкранный view, ЗАМЕНЯЮЩИЙ ленту. Никаких шторок. */
.chat-sheet {
  position: fixed; inset: 0; z-index: 28;
  background: var(--paper);
  height: 100dvh;                 /* dynamic viewport height — учитывает клавиатуру */
  max-height: 100dvh;
  width: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: chatIn .28s cubic-bezier(.2, .8, .3, 1);
}
@keyframes chatIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-sheet.closing {
  animation: chatOut .22s ease-in forwards;
}
@keyframes chatOut {
  to   { opacity: 0; transform: translateY(10px); }
}
/* Когда чат открыт — скрываем всё, что ниже: чтобы ничего не просвечивало
   и лента не оставалась «висеть» под инпутом. */
body.chat-open .topbar,
body.chat-open .search-wrap,
body.chat-open .chips,
body.chat-open .ai-reply,
body.chat-open .feed,
body.chat-open #feed-end,
body.chat-open #feed-loading { display: none !important; }
body.chat-open { overflow: hidden; }

.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top, 0)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--cream);
  flex: 0 0 auto;
}
.chat-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--navy); font-size: 16px; }
.chat-title-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--terracotta);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1;} 50% { opacity: .4;} }
.chat-head-actions {
  display: flex; align-items: center; gap: var(--gap-xs);
}
.chat-reset-btn {
  color: var(--ink-soft);
  border-color: var(--line);
}
.chat-reset-btn:hover { color: var(--terracotta); border-color: var(--terracotta); }
.chat-back {
  border: var(--border-w) solid var(--line);
  background: var(--paper); color: var(--navy);
  border-radius: var(--radius); padding: 7px 12px;
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  line-height: 1.2;
}
.chat-back:hover { border-color: var(--terracotta); color: var(--terracotta); }

.chat-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; padding: 12px 12px 4px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, var(--cream) 0%, var(--paper) 60px, var(--paper) 100%);
}
.chat-empty {
  text-align: center; color: var(--ink-soft); font-size: 13px;
  padding: 56px var(--gap-lg) 32px;
  line-height: 1.5;
  display: flex; flex-direction: column; align-items: center;
  gap: 0;                                 /* воздух даём отдельными margin */
}
.chat-empty-title {
  font-size: 20px; font-weight: 600; color: var(--navy);
  line-height: 1.35;
  margin-bottom: var(--gap-md);           /* воздух до подсказки */
}
.chat-empty-hint {
  font-size: 13px; color: var(--ink-soft);
  margin-bottom: var(--gap-lg);           /* воздух между подсказкой и кнопками */
}
.chat-empty-examples {
  display: flex; flex-direction: column; gap: var(--gap-xs);
  width: 100%; max-width: 320px;
}
.chat-example {
  border: var(--border-w) solid var(--line);
  background: var(--paper); color: var(--navy);
  border-radius: var(--radius);           /* один радиус со всеми: карточки, поле ввода */
  padding: 12px 18px;
  font: inherit; font-size: 14px; font-weight: 500;
  line-height: 1.4;
  cursor: pointer; text-align: center;
  transition: border-color .12s ease, color .12s ease, transform .1s ease,
              background .12s ease;
}
.chat-example:hover  { border-color: var(--terracotta); color: var(--terracotta);
                       background: rgba(198, 93, 60, .04); }
.chat-example:active { transform: scale(.98); }
/* Единая типографика диалога: 16px реплики, 14px мета в карточках */
.chat-msg-wrap {
  margin: 12px 0;                    /* ритм между сообщениями */
  display: flex; flex-direction: column;
}
.chat-msg-wrap.user { align-items: flex-end; }
.chat-msg-wrap.assistant {
  transition: opacity .25s ease;
}
/* «Старая» ассистент-подборка: полупрозрачная, чтобы фокус был на свежей */
.chat-msg-wrap.assistant.old { opacity: .55; }
.chat-msg-wrap.assistant.old .chat-picks { pointer-events: none; }

.chat-msg {
  max-width: 92%; padding: 10px 14px;
  border-radius: 16px; font-size: 16px; line-height: 1.4;
  word-wrap: break-word; white-space: pre-line;
}
.chat-msg.user {
  background: var(--terracotta); color: #fff;
  border-bottom-right-radius: 6px;
}
.chat-msg.assistant {
  /* UI-5: --sky вместо cream — реплики ассистента визуально отделяются
     от кремового фона экрана. Текст остаётся navy (--ink). */
  background: var(--sky); color: var(--ink);
  border: 1px solid transparent;
  border-bottom-left-radius: 6px;
}
/* Курсивный подзаголовок «уточняющий вопрос» удалён — вопрос живёт в reply */
.chat-msg.assistant .msg-clarify { display: none; }

/* Компактные карточки-подборки: горизонтальная строка, фото слева 96×96 */
.chat-picks {
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px 2px 0;
  overflow: visible;
}
.chat-pick {
  display: grid; grid-template-columns: 96px 1fr;
  align-items: stretch;
  min-height: 96px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: border-color .12s ease, transform .12s ease;
}
.chat-pick:hover { border-color: var(--terracotta); }
.chat-pick:active { transform: scale(.99); }
.chat-pick-media {
  width: 96px; height: 96px;
  background: var(--cream);
  position: relative; overflow: hidden;
}
.chat-pick-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-pick-media.no-image {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #F2ECE1, #E9E1D7);
  color: var(--navy-soft);
}
.chat-pick-media.no-image svg { width: 30px; height: 30px; opacity: .5; }
.chat-pick-rubles {
  position: absolute; top: 4px; right: 4px;
  background: var(--terracotta); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 6px 2px 5px; border-radius: 999px;
}
.chat-pick-body {
  padding: 8px 10px; display: flex; flex-direction: column; gap: 2px;
  min-width: 0; justify-content: center;
}
.chat-pick-price { font-weight: 600; color: var(--terracotta); font-size: 17px; line-height: 1.1; }
.chat-pick-city  {
  color: var(--navy); font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-pick-meta  { color: var(--ink-soft); font-size: 14px; }
.chat-pick-reason {
  font-size: 13px; line-height: 1.35; color: var(--navy);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Явный разделитель для альтернатив вне hard-фильтра */
.chat-alt-divider {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 4px 6px;
  color: var(--ink-soft); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
}
.chat-alt-divider::before, .chat-alt-divider::after {
  content: ''; flex: 1; border-top: 1px dashed var(--line);
}
.chat-alt-differs {
  font-size: 12px; color: var(--navy-soft); font-style: italic;
  margin-top: 3px;
}

.chat-action {
  margin: 8px 4px 12px;
  padding: 12px 14px;
  background: var(--navy); color: #fff;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 4px 12px rgba(15, 40, 70, .15);
}
.chat-action .text { font-size: 13px; line-height: 1.35; }
.chat-action button {
  border: 0; background: var(--terracotta); color: #fff;
  padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}

.chat-typing {
  display: inline-block; padding: 10px 14px;
  background: var(--cream); border-radius: 16px;
  border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 13px;
}
.chat-typing .dots span {
  display: inline-block; width: 5px; height: 5px; margin: 0 1px;
  background: var(--ink-soft); border-radius: 50%;
  animation: chatDot 1s infinite;
}
.chat-typing .dots span:nth-child(2) { animation-delay: .15s; }
.chat-typing .dots span:nth-child(3) { animation-delay: .3s; }
@keyframes chatDot { 0%,60%,100% { transform: translateY(0); opacity: .3;} 30% { transform: translateY(-3px); opacity: 1;} }

/* UI-6: строка активных критериев ассистента — одна текстовая строка
   («мета фильтров»), тише реплики и карточек. Никаких фонов/рамок. */
.chat-criteria {
  padding: 6px 14px 10px;
  background: var(--paper);
  flex: 0 0 auto;
}
.chat-criteria[hidden] { display: none; }
.chat-criteria:empty { display: none; }
.crit-line {
  font-size: 12.5px; color: var(--ink-soft);
  font-weight: 500; line-height: 1.35;
}
.crit-line-label { color: var(--ink-soft); font-weight: 600; }

.chat-input {
  display: flex; gap: var(--gap-xs);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0));
  border-top: var(--border-w) solid var(--line);
  background: var(--paper);
  flex: 0 0 auto;
}
.chat-input input {
  flex: 1;
  border: var(--border-w) solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px; font: inherit; color: var(--ink);
  outline: none;
  background: var(--paper);
  min-width: 0;
  line-height: 1.4;
}
.chat-input input:focus { border-color: var(--terracotta); }
#chat-send {
  border: 0; background: var(--terracotta); color: #fff;
  width: 42px; height: 42px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: 0 0 auto;
}
#chat-send:hover { background: var(--terracotta-dark); }
#chat-send:disabled { opacity: .5; cursor: not-allowed; }
#chat-send svg { transform: translateX(1px); }

/* DETAIL SHEET (full-screen) */
.sheet {
  position: fixed; z-index: 30; inset: 0;
  background: var(--paper);
  overflow-y: auto; overscroll-behavior: contain;
  animation: fadein .12s ease-out;
}
@keyframes fadein { from { opacity: 0;} to { opacity: 1;} }
.sheet-close {
  position: sticky; top: 12px; left: 12px; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  color: var(--navy); font-size: 22px; cursor: pointer; margin: 12px;
  box-shadow: var(--shadow);
}
/* Финальная спека медиа карточки: ОДИН медиа-блок во всю ширину.
   video/gif — autoplay muted loop playsinline; фото — статичное <img>.
   Никаких галерей, слайдеров, точек, стрелок, значков, лайтбоксов. */
.media-single {
  width: 100%; background: var(--cream);
  overflow: hidden;
}
.media-single video {
  /* Пресет noticasa_card 1280×720 — 16:9. Занимает ширину карточки. */
  width: 100%; aspect-ratio: 16 / 9;
  object-fit: cover; display: block;
  background: #000;
}
.media-single img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block;
}
.media-empty {
  aspect-ratio: 4 / 3;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #F2ECE1, #E9E1D7);
  color: var(--navy-soft);
}
.media-empty svg { width: 56px; height: 56px; opacity: .5; }

/* ============================================================
   P1-B (2026-07-25, отменяет «ОДИН медиа-блок» из CLAUDE.md):
   мультислайд-галерея в детальной карточке. Swipe = scroll-snap,
   счётчик 1/N, тап по фото → fullscreen lightbox с pinch-zoom.
   ============================================================ */
.gallery-wrap { position: relative; background: #000; }
.gallery {
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* P1-2 (2026-07-26): peek убран — фото от края до края, как в lightbox.
     Владелец: «основное фото строго от края до края, без соседей». */
}
.gallery::-webkit-scrollbar { display: none; }
.gal-slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  aspect-ratio: 4 / 3;
  background: var(--cream);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-in;
  /* absolute-элементы внутри (▶-оверлей) относительно этого слайда. */
  position: relative;
}
.gal-slide[data-kind="video"] { cursor: pointer; aspect-ratio: 16 / 9; background: #000; }
.gal-slide img, .gal-slide video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
/* P1-3 (2026-07-26): счётчик поверх ОСНОВНОГО ФОТО в правом нижнем углу.
   .gal-media — обёртка вокруг .gallery viewport, position:relative;
   счётчик absolute от .gal-media = именно правый низ фото, не под
   миниатюрами. Не пересекается с safe-area Telegram-шапки. */
.gal-media {
  position: relative;
}
.gal-counter {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px; font-weight: 600; letter-spacing: 0.03em;
  border-radius: 999px;
  pointer-events: none;
  z-index: 3;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
/* Dots-индикаторы под галереей — стиль Instagram: активная точка крупнее,
   крайние точки в «окне» из 5 сжимаются. */
.gal-dots {
  position: absolute; bottom: 8px; left: 0; right: 0;
  display: flex; justify-content: center; align-items: center;
  gap: 4px; padding: 4px 12px;
  z-index: 2;
  pointer-events: none;
}
.gal-dot {
  width: 6px; height: 6px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  pointer-events: auto;
  cursor: pointer;
  flex: 0 0 auto;
}
.gal-dot.active {
  background: #fff;
  transform: scale(1.4);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}
.gal-dot.edge      { transform: scale(0.85); opacity: 0.75; }
.gal-dot.half-edge { transform: scale(0.55); opacity: 0.5; }

/* ▶-иконка на видео-слайде (2026-07-25). Показываем сразу — сигнал что
   это видео. Скрывается когда видео играет (браузер сам покажет controls
   при клике). */
.gal-slide[data-kind="video"] .gal-video-play {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 54px; height: 54px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; padding-left: 4px;
  pointer-events: none;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}

/* Полоса миниатюр под галереей — при 5+ элементов. Горизонтальный скролл,
   активная подсвечена терракотовой обводкой. */
.gal-thumbs {
  display: flex; gap: 6px;
  padding: 8px 6%;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  background: var(--paper);
}
.gal-thumbs::-webkit-scrollbar { display: none; }
.gal-thumb {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--cream);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, opacity 0.15s;
  opacity: 0.65;
  position: relative;
}
.gal-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.gal-thumb.active {
  border-color: var(--terracotta);
  opacity: 1;
}
.gal-thumb[data-kind="video"]::after {
  content: '▶';
  position: absolute; inset: 0;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  font-size: 14px;
}

/* Badge «1 фото» — для одиночных карточек делаем чуть более информативным. */
.card-photo-count.single { opacity: 0.9; }

/* Fullscreen lightbox — swipe-down hint полоска сверху (визуальный сигнал). */
.lightbox::before {
  content: '';
  position: fixed; top: calc(env(safe-area-inset-top, 0) + 6px);
  left: 50%; transform: translateX(-50%);
  width: 36px; height: 4px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  z-index: 61;
  pointer-events: none;
}

/* Бейдж числа фото на карточке ленты. Bottom-right, не конфликтует
   с ♥ (top-right) и типом объекта (сверху). */
.card-photo-count {
  position: absolute; bottom: 6px; right: 6px; z-index: 1;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 7px 3px 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  pointer-events: none;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.card-photo-count svg { flex: 0 0 auto; opacity: 0.9; }

/* Fullscreen lightbox. 2026-07-25 полностью перекроен.
   Ключ: .lightbox = чёрный контейнер, .lb-track = сам scroll-container
   на весь viewport, .lb-slide = ровно 100vw × 100dvh. Никаких flex-
   центрирований на .lightbox — они ломали scroll layout (соседи
   подглядывали слева). */
.lightbox {
  position: fixed; inset: 0;
  z-index: 60;
  background: #000;
  overscroll-behavior: contain;
}
body.lb-open { overflow: hidden; }
.lb-track {
  position: absolute; inset: 0;
  width: 100vw; height: 100dvh;
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-snap-type: x mandatory;
}
.lb-track::-webkit-scrollbar { display: none; }
.lb-slide {
  flex: 0 0 100vw;
  width: 100vw;
  height: 100dvh;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
  touch-action: pan-x;   /* по-умолчанию pan-x → track скроллится */
}
.lb-slide img {
  max-width: 100vw; max-height: 100dvh;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  user-select: none; -webkit-user-drag: none;
  display: block;
  /* Плавный snap-возврат к целевому масштабу (см. _wirePinchZoom
     touchend). Без transition promejut'очный зум смотрелся как glitch. */
  transition: transform 0.2s cubic-bezier(.2, .8, .3, 1);
}
.lb-slide img.no-anim { transition: none; }
.lb-slide video {
  max-width: 100vw; max-height: 100dvh;
  background: #000;
}
/* При активном зуме — блокируем горизонтальный скролл трека, чтобы
   pan работал внутри слайда. */
.lb-track.lb-zoomed {
  overflow: hidden;
  scroll-snap-type: none;
}
.lb-track.lb-zoomed .lb-slide { touch-action: none; }
/* Спиннер загрузки full-photo (после thumb показан). */
.lb-spin {
  position: absolute; top: 50%; left: 50%;
  width: 32px; height: 32px;
  margin: -16px 0 0 -16px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: lb-spin 0.8s linear infinite;
  z-index: 2;
}
@keyframes lb-spin { to { transform: rotate(360deg); } }

/* Стрелки навигации ‹ › — скрыты по-умолчанию, показываются на движение
   через class .lb-nav-visible на .lightbox (2с автоскрытие). */
.lb-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px;
  padding: 0; border: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  border-radius: 50%;
  font-size: 28px; line-height: 1;
  z-index: 62;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.lb-nav-prev { left: 12px; }
.lb-nav-next { right: 12px; }
.lb-nav.disabled { opacity: 0 !important; pointer-events: none !important; }
.lightbox.lb-nav-visible .lb-nav:not(.disabled) {
  opacity: 1; pointer-events: auto;
}
.lb-nav:hover, .lb-nav:focus-visible {
  background: rgba(0, 0, 0, 0.65);
  outline: none;
}

/* Toggle UI: скрывает крестик, стрелки, счётчик, точки, миниатюры
   (тап по центру → toggle). */
.lightbox.lb-ui-hidden .lb-close,
.lightbox.lb-ui-hidden .lb-nav,
.lightbox.lb-ui-hidden .lb-counter,
.lightbox.lb-ui-hidden .lb-dots,
.lightbox.lb-ui-hidden::before {
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.lightbox.lb-single .lb-nav { display: none; }
.lb-counter {
  position: fixed; top: calc(env(safe-area-inset-top, 0) + 12px);
  left: 12px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 13px; font-weight: 600;
  border-radius: 999px;
  z-index: 61;
  pointer-events: none;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.lb-close {
  position: fixed; top: calc(env(safe-area-inset-top, 0) + 8px);
  right: 8px;
  width: 48px; height: 48px;   /* ≥44 tap-target */
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 28px; line-height: 1;
  cursor: pointer;
  z-index: 70;   /* ВЫШЕ всех — крестик обязан ловить тап всегда */
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.lb-close:hover, .lb-close:focus-visible {
  background: rgba(255, 255, 255, 0.25);
  outline: none;
}
/* Точки для lightbox — снизу над safe-area. */
.lb-dots {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0) + 14px);
  left: 0; right: 0;
  display: flex; justify-content: center; align-items: center;
  gap: 5px;
  z-index: 61;
  pointer-events: none;
}
.lb-dot {
  width: 7px; height: 7px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  pointer-events: auto;
  cursor: pointer;
}
.lb-dot.active {
  background: #fff;
  transform: scale(1.4);
}
.lb-dot.edge      { transform: scale(0.85); opacity: 0.75; }
.lb-dot.half-edge { transform: scale(0.55); opacity: 0.5; }

/* обратная совместимость: старые классы всё ещё используются в других местах */
.detail-slider { position: relative; }

/* UI-3: padding-bottom = высота sticky CTA (кнопка ~44 + consent ~22 +
   верт. padding 32 + border) + запас 16px. Иначе последние строки описания
   уезжают под кнопку «Связаться» при полной прокрутке. */
.detail-body { padding: 16px 18px 140px; }
.detail-headline {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 8px;
}
.detail-price { font-size: 26px; font-weight: 700; color: var(--terracotta); }
.detail-area  { font-size: 15px; color: var(--navy); font-weight: 600; }
.detail-city  { margin-top: 6px; color: var(--navy); font-weight: 500; font-size: 14px;}
.detail-meta  { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }

/* Q5в: структурированный блок ключевых характеристик. Метка сверху,
   значение снизу; двухколоночная сетка на узких экранах. */
.detail-specs {
  margin: 14px 0 6px; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding-top: 12px; padding-bottom: 12px;
}
.detail-specs .spec { min-width: 0; }
.detail-specs dt {
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ink-soft); font-weight: 500;
}
.detail-specs dd {
  margin: 2px 0 0; font-size: 15px; color: var(--navy); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.detail-features {
  margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px;
}
.feature-chip {
  background: var(--cream); color: var(--navy); border: 1px solid var(--line);
  padding: 5px 10px; border-radius: 999px; font-size: 12px;
}
.detail-desc {
  margin-top: 16px; line-height: 1.55; font-size: 14px; color: var(--ink);
  white-space: pre-line;
}
/* Скелетон-плейсхолдеры для описания, пока /listings/{id} не приехал.
   CTA-футер в это время скрыт — кнопка появляется только после ready. */
.skel-line {
  height: 14px; margin: 8px 0; border-radius: 4px;
  background: linear-gradient(90deg,
    rgba(15,40,70,.06) 0%, rgba(15,40,70,.12) 50%, rgba(15,40,70,.06) 100%);
  background-size: 200% 100%;
  animation: skelWave 1.2s ease-in-out infinite;
}
.skel-line.short { width: 60%; }
@keyframes skelWave { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.detail-reason {
  margin-top: 14px; padding: 12px 14px; border-left: 3px solid var(--terracotta);
  background: rgba(185, 78, 50, .06); border-radius: 4px;
  font-size: 13px; color: var(--navy);
}
/* Закреплённый футер с CTA внутри .sheet. Скроллящийся контент имеет
   отступ снизу равный высоте футера, чтобы кнопка не перекрывала текст. */
.detail-cta-footer {
  position: sticky; bottom: 0;
  padding: var(--gap-md) 16px calc(var(--gap-md) + env(safe-area-inset-bottom, 0));
  background: var(--paper);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 20px rgba(15, 40, 70, .05);
  z-index: 3;
}
.detail-cta-footer .btn { width: 100%; padding: 14px;
                          font-size: 15px; letter-spacing: .3px; }
/* ============================================================
   P1-C-2: Избранное — ♥ на карточке, tab в шапке, fav-mode, пусто
   ============================================================ */

/* ♥ на карточке ленты — overlay top-right поверх cover. */
.card-media { position: relative; }
.card-fav-btn {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 34px; height: 34px; padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(10, 37, 64, 0.06);
  color: var(--navy-soft);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.12s;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.card-fav-btn:hover, .card-fav-btn:focus-visible {
  background: rgba(255, 255, 255, 1);
  color: var(--terracotta);
  outline: none;
}
.card-fav-btn.is-saved {
  color: var(--terracotta);
  background: rgba(255, 255, 255, 0.95);
}
.card-fav-btn:active { transform: scale(0.92); }

/* Таб «Избранное» в шапке — рядом с «Фильтры». */
.fav-tab-btn {
  border: 0;
  background: transparent;
  padding: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--navy-soft);
  cursor: pointer;
  border-radius: 10px;
  position: relative;
  transition: color 0.15s, background 0.15s;
}
.fav-tab-btn:hover, .fav-tab-btn:focus-visible {
  color: var(--terracotta);
  background: rgba(198, 93, 60, 0.05);
  outline: none;
}
.fav-tab-btn.active {
  color: var(--terracotta);
  background: rgba(198, 93, 60, 0.08);
}
.fav-tab-count {
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--terracotta); color: var(--paper);
  border: 2px solid var(--paper);
  border-radius: 999px;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  line-height: 1;
}

/* Пустое состояние fav-таба. */
.fav-empty {
  padding: 60px 24px 40px;
  text-align: center;
  color: var(--ink-soft);
  grid-column: 1 / -1;
}
.fav-empty-heart {
  font-size: 44px; color: var(--terracotta);
  opacity: 0.4;
  margin-bottom: 12px;
}
.fav-empty-title {
  font-size: 15px; font-weight: 600; color: var(--navy);
  margin-bottom: 4px;
}
.fav-empty-sub {
  font-size: 14px; color: var(--ink-soft);
}
.fav-loading, .fav-error {
  padding: 40px 20px; text-align: center;
  color: var(--ink-soft); font-size: 14px;
  grid-column: 1 / -1;
}
.fav-error { color: var(--terracotta); }

/* Detail-кнопка «В избранное» — ghost, рядом с «Поделиться». */
.detail-cta-footer .btn-fav {
  padding: 10px 12px;
  font-size: 13px; font-weight: 600; letter-spacing: 0;
  color: var(--navy-soft);
  background: transparent;
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin-bottom: 8px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.detail-cta-footer .btn-fav.is-saved {
  color: var(--terracotta);
  border-color: rgba(198, 93, 60, 0.5);
  background: rgba(198, 93, 60, 0.05);
}
.detail-cta-footer .btn-fav:hover,
.detail-cta-footer .btn-fav:focus-visible {
  color: var(--terracotta);
  border-color: var(--terracotta);
  background: rgba(198, 93, 60, 0.04);
  outline: none;
}

/* P1-C: «Поделиться» — компактная ghost-кнопка над primary CTA. */
.detail-cta-footer .btn-share {
  padding: 10px 12px;
  font-size: 13px; font-weight: 600; letter-spacing: 0;
  color: var(--navy-soft);
  background: transparent;
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin-bottom: 10px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.detail-cta-footer .btn-share:hover,
.detail-cta-footer .btn-share:focus-visible {
  color: var(--terracotta);
  border-color: var(--terracotta);
  background: rgba(198, 93, 60, 0.04);
  outline: none;
}
.detail-cta-footer .btn-share svg { flex: 0 0 auto; }
/* Q5г: 12–13px, контраст выше, tap-зона у ссылки ≥44px по высоте. */
.cta-consent {
  margin-top: 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--navy-soft);
  line-height: 1.45;
}
.cta-consent a {
  color: var(--navy);
  text-decoration: underline;
  /* Растим tap-зону через padding — визуально ссылка компактная. */
  display: inline-block; padding: 12px 6px; margin: -12px -6px;
  min-height: 44px; line-height: 20px;
}
.cta-consent a:hover { color: var(--terracotta); }

/* Lead flow v2: воронка WhatsApp → Telegram(+phone) → Telegram(no phone).
   Пользователь уходит в мессенджер — это и есть результат, никаких
   «Ваш запрос принят». */
.cta-step {
  display: flex; flex-direction: column; gap: var(--gap-sm);
  padding: 0 2px;
}
.cta-title {
  font-size: 16px; font-weight: 700; color: var(--navy);
  line-height: 1.3; text-align: center;
  margin-top: 4px;
}
.cta-sub {
  font-size: 13.5px; color: var(--ink); line-height: 1.5;
  text-align: center; margin-bottom: 4px;
}
.cta-step .btn.primary {
  width: 100%; padding: 14px;
  font-size: 15px; letter-spacing: .2px;
}
/* Главная кнопка WhatsApp — брендовый зелёный (#25D366), крупная. */
.btn.wa {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 15px 18px;
  background: #25D366; color: #fff;
  border: 0; border-radius: 12px;
  font: inherit; font-size: 16px; font-weight: 700; letter-spacing: .2px;
  cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.btn.wa:hover  { background: #1FBB58; }
.btn.wa:active { transform: scale(.98); }
.btn.wa svg    { flex: 0 0 auto; }

/* Вторичная текстовая ссылка (не кнопка) — переход в TG-ветку. */
.link-secondary {
  align-self: center;
  padding: 12px 8px;
  background: transparent; border: 0; cursor: pointer;
  font: inherit; font-size: 13.5px;
  color: var(--navy); text-decoration: underline;
}
.link-secondary:hover { color: var(--terracotta); }
/* «Продолжить без номера» — максимально скромно, серый. */
.link-secondary.link-muted {
  color: var(--ink-soft); font-size: 13px;
}
.link-secondary.link-muted:hover { color: var(--navy-soft); }

/* Privacy page (webapp/privacy.html) */
.privacy-body {
  max-width: 720px; margin: 0 auto; padding: 24px 20px 80px;
  color: var(--ink); font-size: 15px; line-height: 1.55;
}
.privacy-body h1 { font-size: 26px; color: var(--navy); margin: 8px 0 8px; }
.privacy-body h2 { font-size: 17px; color: var(--navy); margin: 28px 0 8px; }
.privacy-body p, .privacy-body ul { margin: 8px 0; }
.privacy-body ul { padding-left: 20px; }
.privacy-body li { margin: 4px 0; }
.privacy-body a { color: var(--terracotta); }
.privacy-body .lead { color: var(--ink-soft); font-size: 13px; }
.privacy-body code { background: rgba(10,37,64,.06); padding: 2px 6px;
                     border-radius: 4px; font-size: 13px; }
.privacy-body .footer-back { margin-top: 40px; }

/* Fallback-кнопка. Появляется, если синхронный tg.openLink не
   сработал (WebView заблокировал открытие после потери user gesture).
   Прямой user tap по <a> открывается всегда. */
.cta-fallback {
  display: block; margin-top: 12px;
  padding: 12px 16px; text-align: center;
  background: var(--navy); color: #fff;
  border-radius: 12px; text-decoration: none;
  font-weight: 600; font-size: 14px;
}
.cta-fallback:hover { background: var(--navy-soft); }

/* P0-3 rev-2 (2026-07-26 owner): в Telegram скрыто (нативная BackButton),
   в браузере — круглая 44×44 в стиле лайтбокса, ниже safe-area. */
.detail-back-btn {
  display: none;   /* по умолчанию скрыто — JS ставит .browser-only если нужно */
}
.detail-back-btn.browser-only {
  display: inline-flex; align-items: center; justify-content: center;
  position: fixed;
  top: calc(env(safe-area-inset-top, 0) + 8px);
  left: 12px;
  width: 44px; height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 24px;
  z-index: 8;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background 0.15s;
}
.detail-back-btn.browser-only:hover,
.detail-back-btn.browser-only:focus-visible {
  background: rgba(0, 0, 0, 0.75);
  outline: none;
}
.detail-back-btn.browser-only span { display: none; }
.detail-back-btn.browser-only svg { color: #fff; width: 22px; height: 22px; }
.sheet { display: flex; flex-direction: column; }

/* P0-1 (2026-07-26): action-строка в теле карточки под галереей.
   ♥ + Поделиться, компактно, 44+px tap-target. Разгружает нижнюю
   панель — там теперь только Связаться. */
.detail-actions {
  display: flex; gap: 8px;
  padding: 12px 16px 4px;
}
.detail-action-btn {
  flex: 1 1 0;
  min-height: 44px;
  padding: 10px 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--navy-soft);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.detail-action-btn:hover, .detail-action-btn:focus-visible {
  color: var(--terracotta);
  border-color: var(--terracotta);
  background: rgba(198, 93, 60, 0.04);
  outline: none;
}
.detail-action-btn.is-saved {
  color: var(--terracotta);
  border-color: rgba(198, 93, 60, 0.5);
  background: rgba(198, 93, 60, 0.06);
}

/* Detail load error (2026-07-25): показывается при таймауте >5с или
   падении рендера/API. Даёт пользователю retry вместо вечного скелетона. */
.detail-load-err {
  margin: 20px 16px;
  padding: 20px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: center;
}
.detail-load-err-title {
  font-size: 15px; font-weight: 600; color: var(--navy);
  margin-bottom: 6px;
}
.detail-load-err-sub {
  font-size: 13px; color: var(--ink-soft);
  margin-bottom: 16px;
}
.detail-load-err-btn {
  padding: 12px 24px; font-size: 14px; font-weight: 600;
  border: 0; border-radius: 10px;
  background: var(--terracotta); color: #fff;
  cursor: pointer;
}
.detail-load-err-btn:hover { background: var(--terracotta-dark); }

/* ============================================================
   Этап 5 (2026-07-26): вход в ассистента в проде.
   ✨-иконка + «Подобрать» + microcopy на focus + мост из фильтров +
   чипы интерпретации.
============================================================ */
/* ✨-иконка в поисковой строке — терракота (был navy-soft у лупы). */
.search-box .search-ico.assist-sparkle {
  color: var(--terracotta);
  transition: transform 0.25s ease;
}
.search-box.assist-focused .search-ico.assist-sparkle {
  transform: scale(1.1) rotate(6deg);
}
/* Кнопка «Подобрать» вместо стрелки: text, не квадратик. */
#search-submit.assist-submit {
  width: auto !important;
  min-width: 0;
  padding: 0 14px;
  height: 38px;
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 10px;
  flex: 0 0 auto;
  white-space: nowrap;
}
#search-submit.assist-submit svg { display: none; }
.search-box input { min-width: 0; }
/* Мягкое расширение на фокусе — падинг + shadow + обводка. */
.search-box { transition: padding 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease; }
.search-box.assist-focused {
  padding: 10px 6px 10px 14px;
  border-color: var(--terracotta);
  box-shadow: 0 4px 14px rgba(198, 93, 60, 0.14),
              0 0 0 3px rgba(198, 93, 60, 0.10);
}
/* Microcopy строкой под search-box, появляется на focus, исчезает при вводе. */
.assist-microcopy {
  margin: 6px 4px 2px;
  padding: 0 4px;
  font-size: 12.5px; color: var(--ink-soft);
  line-height: 1.4;
  animation: assistFadeIn 0.28s ease;
}
@keyframes assistFadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Мост из панели фильтров в ассистента. Ссылка, не perturbируется
   с primary «Показать N». */
.filters-to-assistant {
  border: 0; background: transparent;
  padding: 12px 18px calc(16px + env(safe-area-inset-bottom, 0));
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--terracotta); font-weight: 600; font-size: 14px;
  cursor: pointer; width: 100%;
  border-top: 1px dashed rgba(198, 93, 60, 0.25);
  background: var(--cream);
}
.filters-to-assistant:hover { color: var(--terracotta-dark); }
.assist-bridge-ico { font-size: 15px; line-height: 1; }
/* Чипы интерпретации над результатами ассистента.
   Заменяют старую строку «Фильтры: A · B · C». */
.chat-criteria .crit-chips {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 2px 2px 4px;
}
.crit-lead {
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  margin-right: 2px;
}
.crit-chip {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 4px 4px 4px 10px;
  background: var(--navy); color: var(--paper);
  border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
  animation: assistFadeIn 0.22s ease;
}
.crit-x {
  border: 0; background: transparent; color: var(--paper);
  padding: 0 6px 0 4px; font-size: 15px; line-height: 1;
  opacity: 0.7; cursor: pointer;
}
.crit-x:hover { opacity: 1; }
.crit-clear {
  margin-left: auto;
  border: 1px solid var(--line); background: transparent;
  color: var(--ink-soft); padding: 5px 10px; border-radius: 999px;
  font-size: 12px; cursor: pointer;
}
.crit-clear:hover { border-color: var(--terracotta); color: var(--terracotta); }
@media (prefers-reduced-motion: reduce) {
  .search-box, .search-box .search-ico, .assist-microcopy, .crit-chip
  { transition: none !important; animation: none !important; }
}

/* accessibility */
[hidden] { display: none !important; }
