/* ============================================================================
   styles.css — ВСЕ СТИЛИ ПРИЛОЖЕНИЯ
   ----------------------------------------------------------------------------
   • Цвета через CSS-переменные. Часть переменных перезаписывает telegram.js
     из tg.themeParams (--tg-bg, --tg-text, --tg-hint, --tg-secondary-bg ...).
   • Светлая тема — значения по умолчанию. Тёмная — body.theme-dark
     (класс ставит telegram.js по colorScheme Telegram или media-query браузера).
   • Акцент агентства фиксированный: #2AABEE.
   • Только мобильный экран 320–430px, без горизонтальной прокрутки.
   ========================================================================= */

:root {
  /* Базовые переменные темы (светлая). Часть приходит из Telegram. */
  --tg-bg: #ffffff;
  --tg-secondary-bg: #f0f2f5;
  --tg-section-bg: #ffffff;
  --tg-header-bg: #ffffff;
  --tg-text: #0f1419;
  --tg-hint: #707991;
  --tg-link: #2AABEE;

  /* Бренд */
  --accent: #2AABEE;
  --accent-d: #1E8FCB;
  --ok: #34C759;
  --danger: #FF3B30;

  /* Скругления и тени (нативный мягкий стиль) */
  --r-sm: 9px;
  --r: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, .14);

  --skel: #e6e9ee;
  --skel-hl: #f2f4f7;
  --hairline: rgba(16, 24, 40, .08);
}

body.theme-dark {
  --tg-bg: #17212b;
  --tg-secondary-bg: #0e1621;
  --tg-section-bg: #232e3c;
  --tg-header-bg: #17212b;
  --tg-text: #f5f5f5;
  --tg-hint: #8a95a3;
  --tg-link: #5fb3ee;

  --shadow: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, .5);
  --skel: #2b3845;
  --skel-hl: #364453;
  --hairline: rgba(255, 255, 255, .08);
}

/* --- Сброс и базовая типографика ----------------------------------------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--tg-text);
  background: var(--tg-secondary-bg);
  overflow-x: hidden;                 /* нет горизонтальной прокрутки */
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h2, h3 { margin: 0; }
svg { display: block; fill: currentColor; }

/* Контейнер «приложения»: мобильная ширина по центру на десктопе */
#app {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--tg-bg);
  overflow: hidden;                   /* экраны скроллятся внутри себя */
}

/* --- Экраны и переходы (slide/fade ~260ms) ------------------------------- */
.screen {
  position: absolute;
  inset: 0;
  background: var(--tg-bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(100%);
  opacity: 0;
  visibility: hidden;
  transition: transform .26s cubic-bezier(.32, .72, 0, 1), opacity .24s ease;
  padding-bottom: 96px;               /* место под MainButton */
}
.screen::-webkit-scrollbar { width: 0; }

/* Каталог и избранное — на сером фоне: белые карточки читаются как нативные
   сгруппированные секции (паттерн iOS / Telegram), а не «веб-карточки». */
#screen-catalog, #screen-favorites { background: var(--tg-secondary-bg); }

/* --- Шапка каталога ------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--tg-header-bg);
  border-bottom: 1px solid var(--hairline);
}
.topbar--simple { justify-content: center; }
.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__logo {
  width: 38px; height: 38px; flex: none;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  color: #fff; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: .5px;
}
.topbar__name { font-weight: 700; font-size: 16px; }
.topbar__sub { font-size: 12px; color: var(--tg-hint); }
.topbar__trust {
  font-size: 12px; color: var(--tg-hint); text-align: right; flex: none;
  background: var(--tg-secondary-bg); padding: 6px 10px; border-radius: 20px;
}

/* --- Строка поиска + фильтры --------------------------------------------- */
.searchrow { display: flex; gap: 10px; padding: 12px 16px 8px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 14px;
  background: var(--tg-section-bg); border: 1px solid var(--hairline);
  border-radius: var(--r);
  color: var(--tg-hint); font-size: 15px;
}
.search svg { fill: var(--tg-hint); flex: none; }
.filters-btn {
  width: 44px; height: 44px; flex: none;
  background: var(--tg-section-bg); border: 1px solid var(--hairline); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  color: var(--tg-text);
}
.filters-btn:active, .search:active { transform: scale(.97); }

/* --- Чипы ----------------------------------------------------------------- */
.chips {
  display: flex; gap: 8px; padding: 4px 16px 12px;
  overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { height: 0; }
/* Быстрые фильтры переносятся на ряды вместо горизонтального скролла */
#quick-chips { flex-wrap: wrap; overflow: visible; }
.chips--wrap { flex-wrap: wrap; overflow: visible; padding: 0; }
.chips--center { justify-content: center; flex-wrap: wrap; padding: 0 16px; }
.chip {
  flex: none;
  min-height: 36px; padding: 0 14px;
  border-radius: 20px;
  background: var(--tg-section-bg); border: 1px solid var(--hairline);
  color: var(--tg-text); font-size: 14px; font-weight: 500;
  display: inline-flex; align-items: center;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.chip:active { transform: scale(.95); }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip--stat { background: var(--tg-secondary-bg); color: var(--tg-text); font-weight: 600; }

/* --- Лента карточек ------------------------------------------------------- */
.list { display: flex; flex-direction: column; gap: 12px; padding: 8px 16px 16px; }

.card {
  background: var(--tg-section-bg);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .12s;
}
.card:active { transform: scale(.985); }
.card__photo {
  position: relative;
  width: 100%; aspect-ratio: 16 / 9;
  display: flex; align-items: flex-end;
}
.card__body { padding: 12px 14px 14px; }
.card__price { font-size: 21px; font-weight: 800; letter-spacing: -.3px; }
.card__meta { font-size: 14px; color: var(--tg-text); margin-top: 3px; }
.card__addr { font-size: 13px; color: var(--tg-hint); margin-top: 3px; }

.photo__cap {
  font-size: 12px; color: rgba(15, 20, 25, .55);
  padding: 8px 12px; font-weight: 600;
}
.card__badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.badge {
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 8px;
  color: #fff; backdrop-filter: blur(4px);
}
.badge--excl { background: rgba(42, 171, 238, .92); }
.badge--drop { background: rgba(52, 199, 89, .92); }

/* Сердечко */
.heart {
  position: absolute; top: 8px; right: 8px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, .28); backdrop-filter: blur(6px);
  color: #fff;
  transition: transform .12s;
}
.heart svg { fill: #fff; transition: fill .15s; }
.heart:active { transform: scale(.85); }
.heart.is-on svg { fill: var(--danger); }

/* Бейдж снижения цены в избранном */
.drop-wrap { margin-top: -8px; }
.drop-note {
  background: rgba(52, 199, 89, .14); color: var(--ok);
  font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 10px;
}

/* --- Скелетон ------------------------------------------------------------- */
.skel { background: var(--tg-section-bg); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); padding-bottom: 14px; }
.skel__photo { width: 100%; aspect-ratio: 16/9; }
.skel__photo, .skel__line {
  background: linear-gradient(90deg, var(--skel) 25%, var(--skel-hl) 37%, var(--skel) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s infinite;
}
.skel__line { height: 14px; border-radius: 7px; margin: 12px 14px 0; }
.skel__line--lg { height: 20px; width: 50%; }
.skel__line--sm { width: 70%; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* --- Пустые состояния ----------------------------------------------------- */
.empty { text-align: center; padding: 64px 32px; }
.empty__icon { font-size: 52px; }
.empty__title { font-size: 18px; font-weight: 700; margin-top: 12px; }
.empty__text { font-size: 14px; color: var(--tg-hint); margin-top: 6px; line-height: 1.45; }
.btn-secondary {
  margin-top: 18px; min-height: 44px; padding: 0 22px;
  background: var(--accent); color: #fff; font-size: 15px; font-weight: 600;
  border-radius: var(--r);
}
.btn-secondary:active { transform: scale(.97); }

/* --- Таб-бар -------------------------------------------------------------- */
#tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 200;
  display: flex;
  background: var(--tg-header-bg);
  border-top: 1px solid var(--hairline);
  padding-bottom: env(safe-area-inset-bottom);
  transition: transform .25s ease;
}
#tabbar.is-hidden { transform: translateY(120%); }
.tabbar__btn {
  flex: 1; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--tg-hint);
}
.tabbar__btn svg { fill: var(--tg-hint); }
.tabbar__btn.is-active, .tabbar__btn.is-active svg { color: var(--accent); fill: var(--accent); }

/* --- Карточка объекта ----------------------------------------------------- */
/* Галерея со свайпом, боковые отступы 16px (защита от iOS swipe-to-close) */
.gallery { position: relative; padding-top: env(safe-area-inset-top); }
.gallery__track {
  display: flex; gap: 8px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; padding: 0 16px;
}
.gallery__track::-webkit-scrollbar { height: 0; }
.photo {
  flex: none; display: flex; align-items: flex-end;
  border-radius: var(--r);
}
.photo--gal { width: 100%; aspect-ratio: 16/10; scroll-snap-align: center; }
.gallery__count {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, .45); color: #fff; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px; backdrop-filter: blur(4px);
}
.round-btn {
  position: absolute; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(0, 0, 0, .32); backdrop-filter: blur(6px);
  color: #fff; transition: transform .12s;
}
.round-btn:active { transform: scale(.88); }
.gallery__heart { top: calc(env(safe-area-inset-top) + 10px); right: 22px; }
.gallery__share { top: calc(env(safe-area-inset-top) + 10px); right: 70px; }
.gallery__heart svg { fill: #fff; }
.gallery__heart.is-on svg { fill: var(--danger); }

.obj { padding: 16px; }
.obj__price { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.obj__mortgage { font-size: 14px; color: var(--tg-hint); margin-top: 2px; }
.obj__addr { font-size: 15px; color: var(--tg-text); margin-top: 8px; font-weight: 500; }
.obj__h { font-size: 17px; font-weight: 700; margin: 22px 0 10px; }

.specs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px;
  margin-top: 16px; padding: 14px;
  background: var(--tg-secondary-bg); border-radius: var(--r);
}
.spec { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.spec__ic { font-size: 18px; flex: none; }
.spec__t { font-weight: 500; }

.map {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  margin-top: 16px; padding: 14px;
  background: linear-gradient(135deg, #cfe0ef, #bcd0e3);
  border-radius: var(--r); color: #0f1419; position: relative; overflow: hidden;
}
body.theme-dark .map { background: linear-gradient(135deg, #2b3a49, #22303d); color: #f5f5f5; }
.map__pin { font-size: 26px; }
.map__addr { font-weight: 700; font-size: 15px; }
.map__metro { font-size: 13px; opacity: .85; margin-top: 2px; }
.map__open { position: absolute; right: 12px; bottom: 10px; font-size: 12px; font-weight: 600; color: var(--accent-d); }
body.theme-dark .map__open { color: var(--accent); }
.map:active { transform: scale(.99); }

.obj__desc {
  font-size: 15px; color: var(--tg-text); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.obj__desc.is-open { -webkit-line-clamp: unset; }
.more-btn { color: var(--accent); font-size: 14px; font-weight: 600; margin-top: 8px; min-height: 32px; }

.photo--plan {
  width: 100%; aspect-ratio: 4/3; border: 1px solid var(--hairline);
}

.infra { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.infra li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.infra__ic { font-size: 18px; width: 24px; text-align: center; flex: none; }

/* Карточка агента в объекте */
.agent-card {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px; background: var(--tg-secondary-bg); border-radius: var(--r);
}
.agent-card:active { transform: scale(.99); }
.agent-card__ava {
  width: 52px; height: 52px; flex: none; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 17px;
}
.agent-card__info { flex: 1; min-width: 0; }
.agent-card__name { font-weight: 700; font-size: 16px; }
.agent-card__meta { font-size: 13px; color: var(--tg-hint); margin-top: 2px; }
.agent-card__chev { font-size: 24px; color: var(--tg-hint); }

.btn-write {
  width: 100%; min-height: 46px; margin-top: 10px;
  background: rgba(42, 171, 238, .12); color: var(--accent);
  font-size: 15px; font-weight: 600; border-radius: var(--r);
}
.btn-write:active { transform: scale(.99); }

/* Горизонтальные карусели (похожие, объекты агента, отзывы) */
.hscroll {
  display: flex; gap: 12px; overflow-x: auto; scrollbar-width: none;
  padding: 2px 16px; margin: 0 -16px;
}
.hscroll::-webkit-scrollbar { height: 0; }
.mini { flex: none; width: 150px; }
.mini__photo { width: 100%; aspect-ratio: 4/3; border-radius: var(--r); }
.mini__price { font-weight: 700; font-size: 15px; margin-top: 6px; }
.mini__meta { font-size: 13px; color: var(--tg-hint); }

/* --- Галерея fullscreen --------------------------------------------------- */
#screen-gallery { background: #000; padding-bottom: 0; }
.fs-count {
  position: absolute; top: calc(env(safe-area-inset-top) + 14px); left: 50%; transform: translateX(-50%);
  z-index: 3; color: #fff; font-size: 13px; font-weight: 600;
  background: rgba(255, 255, 255, .15); padding: 5px 12px; border-radius: 20px;
}
.fs-track {
  display: flex; height: 100dvh; overflow-x: auto;
  scroll-snap-type: x mandatory; scrollbar-width: none;
}
.fs-track::-webkit-scrollbar { height: 0; }
.fs-slide { flex: none; width: 100%; scroll-snap-align: center; display: flex; align-items: center; padding: 16px; }
.photo--fs { width: 100%; aspect-ratio: 3/4; border-radius: var(--r-lg); }

/* --- Форма заявки --------------------------------------------------------- */
.pad { padding: calc(env(safe-area-inset-top) + 16px) 16px 16px; }
.h2 { font-size: 22px; font-weight: 800; margin-bottom: 16px; }

.lead-obj {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; background: var(--tg-secondary-bg); border-radius: var(--r); margin-bottom: 20px;
}
.lead-obj__photo { width: 56px; height: 56px; flex: none; border-radius: 12px; }
.lead-obj__price { font-weight: 700; font-size: 16px; }
.lead-obj__addr { font-size: 13px; color: var(--tg-hint); margin-top: 2px; }

.field { display: block; margin-bottom: 18px; }
.field__label { display: block; font-size: 13px; color: var(--tg-hint); margin-bottom: 8px; font-weight: 600; }
.input {
  width: 100%; min-height: 48px; padding: 0 14px;
  background: var(--tg-secondary-bg); border: 1.5px solid transparent; border-radius: var(--r);
  font-size: 16px; color: var(--tg-text);                /* 16px — чтобы iOS не зумил */
}
.input:focus { outline: none; border-color: var(--accent); }
.is-hidden { display: none !important; }

.phone-btn {
  width: 100%; min-height: 48px; padding: 0 14px;
  background: var(--tg-secondary-bg); border: 1.5px dashed var(--accent); border-radius: var(--r);
  color: var(--accent); font-size: 15px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.phone-btn.is-done {
  border-style: solid; border-color: var(--ok);
  background: rgba(52, 199, 89, .12); color: var(--ok);
}
.phone-btn:active { transform: scale(.99); }

.consent { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--tg-text); margin-top: 4px; }
.consent input { width: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--accent); }

/* --- Подтверждение -------------------------------------------------------- */
.confirm { text-align: center; padding: 64px 32px; }
.confirm__check { display: flex; justify-content: center; animation: pop .4s cubic-bezier(.18, .89, .32, 1.28); }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.confirm__title { font-size: 24px; font-weight: 800; margin-top: 18px; }
.confirm__text { font-size: 15px; color: var(--tg-hint); margin-top: 10px; line-height: 1.5; }
.confirm__agent {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 22px; padding: 10px 16px 10px 10px;
  background: var(--tg-secondary-bg); border-radius: 40px;
}
.confirm__agent .agent-card__ava { width: 40px; height: 40px; border-radius: 12px; font-size: 14px; }
.link-btn { color: var(--accent); font-size: 15px; font-weight: 600; min-height: 44px; margin-top: 22px; }

/* --- Профиль агента ------------------------------------------------------- */
.agent-hero { text-align: center; margin-bottom: 16px; }
.agent-hero__ava {
  width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 28px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 32px;
}
.agent-hero__name { font-size: 22px; font-weight: 800; }
.agent-hero__role { font-size: 14px; color: var(--tg-hint); margin-top: 2px; }
.agent-spec { text-align: center; font-size: 14px; color: var(--tg-text); margin: 12px 0 0; }

.review {
  flex: none; width: 250px; padding: 14px;
  background: var(--tg-secondary-bg); border-radius: var(--r);
}
.review__stars { color: #FFB400; font-size: 14px; letter-spacing: 1px; }
.review__text { font-size: 14px; line-height: 1.45; margin-top: 8px; }
.review__author { font-size: 12px; color: var(--tg-hint); margin-top: 10px; }

/* --- Bottom sheet (фильтры) ---------------------------------------------- */
#sheet-backdrop {
  position: absolute; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, .4); opacity: 0; visibility: hidden;
  transition: opacity .25s;
}
#sheet-backdrop.is-open { opacity: 1; visibility: visible; }
#sheet-filters {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 310;
  max-height: 88dvh; overflow-y: auto;
  background: var(--tg-bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32, .72, 0, 1);
  padding-bottom: calc(env(safe-area-inset-bottom) + 90px);
  box-shadow: var(--shadow-lg);
}
#sheet-filters.is-open { transform: translateY(0); }
.sheet__handle { width: 40px; height: 4px; border-radius: 2px; background: var(--tg-hint); opacity: .4; margin: 8px auto 0; }
.sheet__head {
  position: sticky; top: 0; z-index: 2; background: var(--tg-bg);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--hairline);
}
.sheet__head .link-btn { margin: 0; text-align: left; min-height: 36px; }
.sheet__title { font-size: 17px; font-weight: 700; text-align: center; }
.round-btn--ghost {
  position: static; justify-self: end;
  width: 32px; height: 32px; background: var(--tg-secondary-bg); color: var(--tg-text);
  font-size: 15px;
}
.sheet__body { padding: 16px; }
.grp { margin-bottom: 22px; }
.grp__label { font-size: 13px; font-weight: 700; color: var(--tg-hint); margin-bottom: 10px; }

.seg {
  display: flex; gap: 6px; padding: 4px; background: var(--tg-secondary-bg);
  border-radius: var(--r); margin-bottom: 22px;
}
.seg__btn {
  flex: 1; min-height: 44px; border-radius: 11px; font-size: 15px; font-weight: 600;
  color: var(--tg-text); transition: background .15s, color .15s;
}
.seg__btn.is-on { background: var(--accent); color: #fff; }

.range-vals { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input[type="range"] {
  width: 100%; height: 28px; -webkit-appearance: none; background: transparent; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--tg-secondary-bg); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); margin-top: -11px; box-shadow: var(--shadow); border: 2px solid #fff;
}
body.theme-dark input[type="range"]::-webkit-slider-thumb { border-color: var(--tg-bg); }

.checks { display: flex; flex-direction: column; gap: 4px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }

/* --- Экран-оффер (приветственная модалка, показывается один раз) --------- */
#offer-backdrop {
  position: absolute; inset: 0; z-index: 500;
  background: rgba(0, 0, 0, .5); opacity: 0; visibility: hidden;
  transition: opacity .28s;
}
#offer-backdrop.is-open { opacity: 1; visibility: visible; }
#offer {
  position: absolute; inset: 0; z-index: 510;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  opacity: 0; visibility: hidden; transition: opacity .28s;
}
#offer.is-open { opacity: 1; visibility: visible; }
.offer__card {
  width: 100%; max-width: 360px;
  background: var(--tg-bg); border-radius: var(--r-lg);
  padding: 28px 22px calc(env(safe-area-inset-bottom) + 22px);
  box-shadow: var(--shadow-lg); text-align: center;
  transform: scale(.85) translateY(12px);
  transition: transform .32s cubic-bezier(.32, .72, 0, 1);
}
#offer.is-open .offer__card { transform: scale(1) translateY(0); }
.offer__emoji { font-size: 56px; line-height: 1; margin-bottom: 14px; }
.offer__title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.offer__sub { font-size: 15px; color: var(--tg-hint); margin: 0 0 20px; }
.offer__list {
  list-style: none; margin: 0 0 22px; padding: 0;
  text-align: left; display: flex; flex-direction: column; gap: 12px;
}
.offer__list li { position: relative; padding-left: 30px; font-size: 14px; line-height: 1.45; }
.offer__list li::before {
  content: '✓'; position: absolute; left: 0; top: 0;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(42, 171, 238, .14); color: var(--accent);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.offer__cta {
  width: 100%; min-height: 50px; border-radius: var(--r);
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 700;
  box-shadow: var(--shadow); transition: transform .12s, background .15s;
}
.offer__cta:active { transform: scale(.99); background: var(--accent-d); }
.offer__skip { width: 100%; min-height: 44px; margin-top: 6px; color: var(--tg-hint); font-size: 15px; font-weight: 600; }

/* --- Экран приветствия (онбординг, показывается один раз) ---------------- */
#welcome {
  position: absolute; inset: 0; z-index: 520;
  background: var(--tg-bg);
  opacity: 0; visibility: hidden; transition: opacity .3s;
  overflow-y: auto;
}
#welcome.is-open { opacity: 1; visibility: visible; }
.welcome__inner {
  min-height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 32px) 24px calc(env(safe-area-inset-bottom) + 24px);
  transform: translateY(10px); transition: transform .34s cubic-bezier(.32, .72, 0, 1);
}
#welcome.is-open .welcome__inner { transform: translateY(0); }
.welcome__hero { text-align: center; margin-bottom: 28px; }
.welcome__emoji {
  font-size: 64px; line-height: 1; margin-bottom: 16px;
  display: inline-block;
}
.welcome__title { font-size: 26px; font-weight: 800; margin-bottom: 10px; }
.welcome__sub { font-size: 15px; line-height: 1.5; color: var(--tg-hint); margin: 0 auto; max-width: 320px; }
.welcome__list {
  list-style: none; margin: 0 0 28px; padding: 0;
  display: flex; flex-direction: column; gap: 14px;
}
.welcome__list li {
  display: flex; align-items: flex-start; gap: 14px;
  background: var(--tg-secondary-bg); border-radius: var(--r);
  padding: 14px 16px;
}
.welcome__ic { font-size: 26px; line-height: 1.2; flex: none; }
.welcome__txt { font-size: 14px; line-height: 1.4; color: var(--tg-hint); }
.welcome__txt b { display: block; font-size: 15px; font-weight: 700; color: var(--tg-text); margin-bottom: 2px; }
.welcome__foot { margin-top: auto; }
.welcome__cta {
  width: 100%; min-height: 52px; border-radius: var(--r);
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 700;
  box-shadow: var(--shadow); transition: transform .12s, background .15s;
}
.welcome__cta:active { transform: scale(.99); background: var(--accent-d); }
.welcome__share { width: 100%; min-height: 44px; margin-top: 8px; color: var(--accent); font-size: 15px; font-weight: 600; }

/* --- Кнопка «Поделиться с другом» в каталоге ----------------------------- */
.share-friend {
  display: flex; align-items: center; gap: 14px; width: 100%;
  margin: 8px 0 4px; padding: 16px;
  background: var(--tg-section-bg); border: 1px solid var(--hairline); border-radius: var(--r);
  text-align: left; transition: transform .12s;
}
.share-friend:active { transform: scale(.99); }
.share-friend__ic { font-size: 24px; flex: none; }
.share-friend__txt { flex: 1; font-size: 13px; line-height: 1.4; color: var(--tg-hint); }
.share-friend__txt b { display: block; font-size: 15px; font-weight: 700; color: var(--tg-text); margin-bottom: 2px; }
.share-friend__chev { color: var(--tg-hint); font-size: 22px; flex: none; }

/* --- Вкладки «Агенты» и «Об агентстве» ----------------------------------- */
/* Под sticky-топбаром safe-area уже учтена — не добавляем её ещё раз сверху. */
.pad--tab { padding-top: 16px; }
.tab-intro { font-size: 14px; line-height: 1.45; color: var(--tg-hint); margin: 0 0 16px; }

.agents-list { display: flex; flex-direction: column; gap: 10px; }

.about-hero { text-align: center; margin-bottom: 20px; }
.about-hero__logo {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-d));
  color: #fff; font-weight: 800; font-size: 22px; letter-spacing: .5px;
  display: flex; align-items: center; justify-content: center;
}
.about-hero__name { font-size: 20px; font-weight: 800; }
.about-hero__tag { font-size: 14px; color: var(--tg-hint); margin-top: 2px; }

.about-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.about-stat {
  padding: 14px 8px; text-align: center;
  background: var(--tg-secondary-bg); border-radius: var(--r);
}
.about-stat__num { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.about-stat__lbl { font-size: 12px; color: var(--tg-hint); margin-top: 3px; }

.about-list { display: flex; flex-direction: column; gap: 10px; }
.about-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; background: var(--tg-secondary-bg); border-radius: var(--r);
  color: var(--tg-text); text-decoration: none; transition: transform .12s;
}
.about-row:active { transform: scale(.99); }
.about-row__ic { font-size: 22px; flex: none; }
.about-row__txt { flex: 1; font-size: 13px; color: var(--tg-hint); }
.about-row__txt b { display: block; font-size: 15px; font-weight: 600; color: var(--tg-text); margin-bottom: 2px; }
.about-row__chev { color: var(--tg-hint); font-size: 22px; flex: none; }

.why-list { display: flex; flex-direction: column; gap: 10px; }
.why-row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px; background: var(--tg-secondary-bg); border-radius: var(--r);
}
.why-row__ic { font-size: 22px; flex: none; line-height: 1.3; }
.why-row__txt { flex: 1; font-size: 13px; line-height: 1.5; color: var(--tg-hint); }
.why-row__txt b { display: block; font-size: 15px; font-weight: 600; color: var(--tg-text); margin-bottom: 2px; }

.about-legal {
  font-size: 13px; line-height: 1.6; color: var(--tg-hint);
  padding: 14px 16px; background: var(--tg-secondary-bg); border-radius: var(--r);
}

/* --- Фолбэк-кнопки (только вне Telegram, для проверки в браузере) --------- */
#fb-main-btn {
  position: absolute; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 14px);
  z-index: 400; min-height: 50px; border-radius: var(--r);
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 700;
  opacity: 0; visibility: hidden; transition: opacity .2s, transform .12s;
  box-shadow: var(--shadow-lg);
}
#fb-main-btn.is-visible { opacity: 1; visibility: visible; }
#fb-main-btn:disabled { background: #9bb3c4; }
#fb-main-btn:active:not(:disabled) { transform: scale(.99); }
#fb-back-btn {
  position: absolute; top: calc(env(safe-area-inset-top) + 10px); left: 10px; z-index: 410;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0, 0, 0, .32); backdrop-filter: blur(6px); color: #fff;
  font-size: 22px; display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity .2s;
}
#fb-back-btn.is-visible { opacity: 1; visibility: visible; }
