/* Цвета берём из темы Telegram (светлая/тёмная), акцент — фирменный оранжевый */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f2f5);
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --text: var(--tg-theme-text-color, #111318);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #ff5b3a);
  --accent: #ff5b3a;
  --accent-soft: rgba(255, 91, 58, .12);
  --good: #19b26b;
  --good-soft: rgba(25, 178, 107, .14);
  --bad: #e5484d;
  --bad-soft: rgba(229, 72, 77, .14);
  --line: rgba(127, 127, 127, .16);
  --radius: 18px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg2); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
.boot { height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page { padding: 12px 14px calc(var(--nav-h) + var(--safe-b) + 16px); max-width: 720px; margin: 0 auto; }
.h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; }
.sub { color: var(--hint); font-size: 13px; }
.section-title { text-transform: uppercase; letter-spacing: .06em; font-size: 12px; font-weight: 700; color: var(--hint); margin: 22px 4px 8px; }
.box { background: var(--card); border-radius: var(--radius); padding: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- шапка поиска ---- */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.region { font-size: 24px; font-weight: 800; letter-spacing: -.02em; display: flex; align-items: center; gap: 6px; }
.region .chev { font-size: 16px; color: var(--hint); }
.ring { position: relative; width: 52px; height: 52px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .lbl { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; font-size: 11px; font-weight: 700; line-height: 1.05; }
.ring .lbl small { display: block; font-weight: 500; color: var(--hint); font-size: 8px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 14px; padding: 10px 12px; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; background: var(--card); border-radius: 999px; padding: 8px 13px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--accent); color: #fff; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin: 12px 2px 6px; }
.sort { background: transparent; border: 0; color: var(--link); font-weight: 600; appearance: none; }
.views { display: flex; background: var(--card); border-radius: 12px; padding: 3px; }
.views button { width: 34px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--hint); }
.views button.on { background: var(--accent-soft); color: var(--accent); }
.count { color: var(--hint); font-size: 13px; margin: 0 4px 10px; }

/* ---- карточки ---- */
.feed-big { display: grid; gap: 14px; }
.feed-list { display: grid; gap: 8px; }
.feed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; position: relative; text-align: left; width: 100%; }
.card .ph { position: relative; aspect-ratio: 16/10; background: var(--bg2) center/cover no-repeat; }
.feed-grid .card .ph { aspect-ratio: 1/1; }
.card .ph::after { content: ""; position: absolute; inset: 45% 0 0; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.card .price-on { position: absolute; left: 12px; bottom: 10px; color: #fff; z-index: 1; font-weight: 800; font-size: 24px; text-shadow: 0 1px 6px rgba(0,0,0,.35); }
.feed-grid .card .price-on { font-size: 18px; left: 9px; bottom: 7px; }
.card .price-on small { font-size: 13px; font-weight: 600; opacity: .9; }
.card .price-on .en { display: block; font-size: 11px; font-weight: 600; opacity: .9; }
.card .badges { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; z-index: 1; }
.badge { font-size: 11px; font-weight: 800; padding: 3px 7px; border-radius: 7px; background: rgba(0,0,0,.55); color: #fff; backdrop-filter: blur(6px); }
.badge.new { background: var(--accent); }
.card .cnt { position: absolute; right: 10px; bottom: 10px; z-index: 1; font-size: 12px; color: #fff; background: rgba(0,0,0,.5); padding: 2px 7px; border-radius: 7px; }
.fav-btn { position: absolute; right: 10px; top: 10px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; background: rgba(0,0,0,.4); color: #fff; display: grid; place-items: center; font-size: 17px; backdrop-filter: blur(6px); }
.fav-btn.on { color: var(--accent); background: #fff; }
.card .body { padding: 11px 13px 13px; }
.feed-grid .card .body { padding: 8px 10px 10px; }
.card .title { font-weight: 700; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.feed-grid .card .title { font-size: 13px; -webkit-line-clamp: 1; }
.card .meta { color: var(--hint); font-size: 13px; margin-top: 3px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 8px; background: var(--bg2); }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.acc { background: var(--accent-soft); color: var(--accent); }
.lcard { display: flex; gap: 11px; padding: 9px; background: var(--card); border-radius: 16px; text-align: left; width: 100%; }
.lcard .thumb { width: 92px; height: 78px; border-radius: 12px; background: var(--bg2) center/cover; flex: none; }
.lcard .p { font-weight: 800; font-size: 17px; display: flex; align-items: center; gap: 7px; }
.more { width: 100%; padding: 13px; border-radius: 14px; background: var(--card); font-weight: 700; color: var(--link); margin-top: 12px; }
.empty { text-align: center; padding: 50px 20px; }
.empty .ico { font-size: 52px; }
.empty b { display: block; font-size: 18px; margin: 10px 0 6px; }

/* ---- карта ---- */
/* isolation: слои Leaflet (z-index 400+) не должны перекрывать меню и шторки */
.map { height: calc(100vh - 250px - var(--nav-h)); min-height: 320px; border-radius: var(--radius); overflow: hidden; isolation: isolate; }
.minimap { isolation: isolate; }
.pin { background: var(--accent); color: #fff; font-weight: 800; font-size: 12px; padding: 3px 7px; border-radius: 9px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.3); border: 2px solid #fff; transform: translate(-50%, -50%); display: inline-block; }
.leaflet-div-icon { background: none; border: 0; }
.dark-tiles { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }

/* ---- нижнее меню ---- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--bg); border-top: 1px solid var(--line); display: flex; padding-bottom: var(--safe-b); }
.nav button { flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--hint); font-weight: 600; }
.nav button .i { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .75; }
.nav button.on { color: var(--accent); }
.nav button.on .i { filter: none; opacity: 1; }

/* ---- шторки ---- */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 80; animation: fade .2s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 81; background: var(--bg2); border-radius: 22px 22px 0 0; max-height: 88vh; display: flex; flex-direction: column; animation: up .25s ease-out; max-width: 720px; margin: 0 auto; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 2px; flex: none; }
.sheet .sc { overflow-y: auto; padding: 8px 14px 14px; }
.sheet .foot { padding: 10px 14px calc(12px + var(--safe-b)); display: grid; gap: 8px; border-top: 1px solid var(--line); background: var(--bg2); }
.sheet h2 { margin: 6px 0 2px; font-size: 22px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.btn { width: 100%; padding: 14px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 700; font-size: 16px; }
.btn.ghost { background: var(--card); color: var(--link); }
.btn.sm { padding: 10px; font-size: 14px; }
.btn:disabled { opacity: .5; }

/* бюджет */
.budget { text-align: center; }
.budget .val { font-size: 34px; font-weight: 800; }
.budget .val small { font-size: 14px; color: var(--hint); font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 12px 0 2px; }
.scale { display: flex; justify-content: space-between; color: var(--hint); font-size: 11px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; justify-content: center; }
.presets button { padding: 7px 11px; border-radius: 10px; background: var(--bg2); font-weight: 600; font-size: 13px; }
.presets button.on { background: var(--accent); color: #fff; }

/* плитки типа */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tile { background: var(--card); border-radius: 16px; padding: 12px; text-align: left; border: 2px solid transparent; position: relative; }
.tile.on { border-color: var(--accent); }
.tile .e { font-size: 24px; }
.tile b { display: block; margin-top: 4px; }
.tile .chk { position: absolute; right: 10px; top: 10px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; color: #fff; }
.tile.on .chk { background: var(--accent); border-color: var(--accent); }
.opt { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 16px; padding: 12px; width: 100%; text-align: left; border: 2px solid transparent; margin-bottom: 8px; }
.opt.on { border-color: var(--accent); }
.opt .e { font-size: 24px; width: 32px; text-align: center; }
.opt .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.opt.on .radio { border: 6px solid var(--accent); }
.list { background: var(--card); border-radius: 16px; overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; text-align: left; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; font-size: 17px; flex: none; }
.li .arr { color: var(--hint); }
.switch { width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; flex: none; transition: .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch.on { background: var(--accent); }
.switch.on::after { left: 21px; }
.seg { display: flex; background: var(--card); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; padding: 8px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--hint); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

/* ---- карточка объявления ---- */
.detail { position: fixed; inset: 0; z-index: 60; background: var(--bg2); overflow-y: auto; padding-bottom: calc(86px + var(--safe-b)); animation: fade .15s; }
.gallery { position: relative; background: #000; }
.gallery .strip { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery .strip::-webkit-scrollbar { display: none; }
.gallery img { width: 100%; flex: none; aspect-ratio: 4/3; object-fit: cover; scroll-snap-align: center; display: block; }
.gallery .noimg { aspect-ratio: 16/9; display: grid; place-items: center; font-size: 60px; background: var(--card); }
.gallery .num { position: absolute; right: 12px; bottom: 12px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 8px; }
.gallery .gbtn { position: absolute; top: 12px; width: 38px; height: 38px; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; display: grid; place-items: center; font-size: 18px; backdrop-filter: blur(6px); }
.dhead { padding: 14px 14px 4px; }
.dhead .pr { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.dhead .pr small { font-size: 15px; color: var(--hint); font-weight: 600; }
.dhead .tt { font-weight: 700; font-size: 17px; margin-top: 2px; }
.dsec { margin: 12px 14px 0; }
.dsec h3 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--hint); }
.kv span:last-child { font-weight: 600; text-align: right; }
.gauge { position: relative; height: 8px; border-radius: 4px; margin: 26px 0 6px; background: linear-gradient(90deg, var(--good), #f5c542 50%, var(--bad)); opacity: .85; }
.gauge .dot { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); transform: translate(-50%, -50%); }
.gauge .med { position: absolute; top: -20px; transform: translateX(-50%); font-size: 11px; color: var(--hint); white-space: nowrap; }
.gauge .med::after { content: ""; position: absolute; left: 50%; top: 16px; height: 16px; border-left: 2px solid var(--text); opacity: .6; }
.params { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.param { background: var(--bg2); border-radius: 12px; padding: 9px 11px; }
.param span { color: var(--hint); font-size: 12px; display: block; }
.param b { font-size: 15px; }
.desc { white-space: pre-wrap; font-size: 14px; }
.desc.clamp { display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.minimap { height: 180px; border-radius: 14px; overflow: hidden; }
.hscroll { display: flex; gap: 10px; overflow-x: auto; padding: 2px 14px 4px; margin: 0 -14px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll .card { width: 210px; flex: none; }
.seller { display: flex; align-items: center; gap: 12px; }
.ava { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; flex: none; }
.phone { display: flex; align-items: center; gap: 8px; margin-top: 12px; background: var(--bg2); border-radius: 12px; padding: 10px 12px; font-size: 18px; font-weight: 700; }
.circle { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--card); font-size: 17px; }
.circle.go { background: var(--good); color: #fff; }
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; background: var(--bg); border-top: 1px solid var(--line); padding: 10px 12px calc(10px + var(--safe-b)); display: flex; gap: 8px; }
.bar .sq { width: 50px; flex: none; border-radius: 14px; background: var(--card); font-size: 20px; }
.bar .sq.on { color: var(--accent); }
.bar .btn { padding: 13px 8px; }

/* ---- рынок ---- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px 14px; }
.stat span { color: var(--hint); font-size: 12px; }
.stat b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.stat small { color: var(--hint); font-size: 12px; }
.hbar { display: grid; grid-template-columns: 112px 1fr auto; align-items: center; gap: 10px; padding: 6px 0; width: 100%; text-align: left; font-size: 14px; }
.hbar .tr { height: 10px; border-radius: 5px; background: var(--bg2); overflow: hidden; }
.hbar .tr i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.hbar .tr i.fit { background: var(--good); }
.cols { display: flex; align-items: flex-end; gap: 4px; height: 120px; margin-top: 18px; }
.cols .c { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.cols .c i { width: 100%; background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 2px; opacity: .85; }
.cols .c small { font-size: 10px; color: var(--hint); }
.cols .c em { font-style: normal; font-size: 10px; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 20px); transform: translateX(-50%); z-index: 100; background: rgba(20,20,22,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; animation: up .2s; white-space: nowrap; }
.remind-opts { display: grid; gap: 8px; }
.field { width: 100%; padding: 12px; border-radius: 12px; border: 0; background: var(--card); outline: 0; }
