/*
  Оформление мини-приложения Pinn.Lenta.
  Цвета — с аватарки бота: синий фон, красная булавка, белые карточки.
  Все цвета заданы переменными ниже — чтобы поменять цвет, меняйте только их.
*/

/* ----- Тёмная тема (по умолчанию) ----- */
:root {
  --bg: #0b1020;          /* фон */
  --surface: #151c31;     /* карточки */
  --surface-2: #1f2840;   /* поля, поиск */
  --line: #2b3553;        /* рамки */
  --text: #f3f6fc;
  --muted: #8b95ab;
  --accent: #2f6bff;      /* синий с аватарки — кнопки */
  --accent-2: #45a6ff;    /* голубое свечение — градиенты */
  --red: #ef3b45;         /* красная булавка — сердечко, акценты */
  --on-accent: #ffffff;
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  --radius: 16px;
  color-scheme: dark;
}

/* ----- Светлая тема ----- */
:root[data-theme="light"] {
  --bg: #f2f5fb;
  --surface: #ffffff;
  --surface-2: #e9eef7;
  --line: #dbe2ee;
  --text: #0f172a;
  --muted: #6b7486;
  --shadow: 0 6px 18px rgba(31, 60, 140, .12);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Noto Sans Georgian", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }

/* ----- Полоса сверху ----- */
.banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 32px; padding: 0 12px;
  background: linear-gradient(90deg, #1f5bff, var(--accent-2));
  color: #fff; font-size: 12.5px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
}
.banner .badge { width: 16px; height: 16px; fill: #fff; stroke: none; }
.banner .badge .tick { fill: none; stroke: #1f5bff; stroke-width: 2.4; }

/* ----- Шапка ----- */
.top { display: flex; align-items: center; gap: 10px; padding: 12px 16px 8px; }
.logo { font-size: 30px; font-weight: 900; letter-spacing: -1px; margin-right: auto; }
.logo b { color: var(--red); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; }
.icon-btn:active { background: var(--surface-2); }
.city-pill { display: flex; align-items: center; gap: 6px; max-width: 46vw; font-weight: 600; }
.city-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ----- Поиск и кнопка фильтров ----- */
.view { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.search-row { display: flex; gap: 10px; padding: 4px 16px 12px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 14px; border-radius: 14px; background: var(--surface-2); color: var(--muted);
}
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font-size: 16px; }
.search input::placeholder { color: var(--muted); }
.filter-btn {
  width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent);
  box-shadow: 0 6px 16px rgba(47, 107, 255, .35);
}

/* ----- Категории-«таблетки» ----- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1.5px solid var(--line); font-weight: 600; white-space: nowrap;
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ----- Заголовок ----- */
.title { font-size: 24px; font-weight: 800; margin: 4px 16px 2px; letter-spacing: -.3px; }
.subtitle { display: flex; align-items: center; gap: 8px; margin: 0 16px 14px; color: #33c27a; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #33c27a; }

/* ----- Сетка карточек ----- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 16px; }
.card { position: relative; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-align: left; }
.card:active { transform: scale(.98); }
.card .ph { position: relative; aspect-ratio: 3 / 4; background: var(--surface-2); overflow: hidden; }

/* Фото целиком на размытом фоне из него же (app.js: photoLayers) */
.photo-bg { position: absolute; inset: -12%; width: 124%; height: 124%; object-fit: cover; filter: blur(22px) brightness(.75); transform: translateZ(0); }
.photo-main { position: relative; display: block; width: 100%; height: 100%; object-fit: contain; }
.card .no-photo { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.heart {
  position: absolute; top: 8px; right: 8px; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: rgba(10, 14, 30, .38); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.heart.on { color: var(--red); }
.heart.on svg, #adFav.on svg { fill: var(--red); stroke: var(--red); }
.price-pill {
  position: absolute; left: 8px; bottom: 12px; max-width: calc(100% - 16px);
  padding: 5px 10px; border-radius: 10px; font-weight: 800; font-size: 14px; color: #fff;
  background: rgba(10, 14, 30, .62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.segs { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 3px; padding: 0 2px; }
.segs i { flex: 1; height: 3px; background: rgba(255, 255, 255, .35); }
.segs i:first-child { background: var(--red); }
.card .info { padding: 10px 12px 12px; }
.card .name { font-weight: 800; font-size: 15.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { color: var(--muted); font-size: 13.5px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.own-badge { position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 8px; font-size: 12px; font-weight: 700; background: var(--accent); color: #fff; }

.loader { height: 60px; }
.empty { text-align: center; color: var(--muted); font-size: 17px; margin: 60px 24px; }

/* ----- Нижнее меню ----- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--text); opacity: .85; }
.tab.active { color: var(--accent-2); opacity: 1; }
.tab[data-tab="create"] svg { color: var(--red); }

/* ----- Фильтры ----- */
.sheet { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: flex; flex-direction: column; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 4px; }
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 800; }
.sheet-body { flex: 1; overflow-y: auto; padding: 8px 16px 24px; }
.field {
  position: relative; display: block; margin-bottom: 12px; padding: 10px 44px 10px 16px;
  border-radius: 14px; background: var(--surface-2);
}
.field-label { display: block; color: var(--muted); font-size: 13px; }
.field select, .field input {
  width: 100%; border: 0; outline: 0; background: none; font-size: 17px; padding: 2px 0;
  -webkit-appearance: none; appearance: none;
}
.field select option { color: #000; }
.field .chev { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.group-title { font-size: 17px; font-weight: 800; margin: 18px 0 10px; }
.range { display: flex; align-items: center; gap: 12px; }
.range .field { flex: 1; display: flex; align-items: center; gap: 6px; padding: 16px; margin: 0; }
.prefix { color: var(--muted); }
.dash { color: var(--muted); }
.sheet-foot {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg);
}
.btn { height: 52px; border-radius: 14px; font-weight: 800; font-size: 16px; }
.btn.ghost { background: var(--surface-2); font-weight: 600; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); box-shadow: 0 6px 16px rgba(47, 107, 255, .3); }
.btn.grow { flex: 1; }

/* ----- Страница объявления ----- */
.page { position: fixed; inset: 0; z-index: 8; background: var(--bg); overflow-y: auto; padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
.gallery-wrap { position: relative; }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; aspect-ratio: 4 / 5; background: var(--surface-2); }
.gallery::-webkit-scrollbar { display: none; }
.gallery .slide, .gallery .no-photo { flex: none; width: 100%; height: 100%; scroll-snap-align: center; }
.gallery .slide { position: relative; overflow: hidden; }
.gallery .no-photo { display: grid; place-items: center; color: var(--muted); }
.dots { position: absolute; left: 0; right: 0; bottom: 12px; display: flex; justify-content: center; gap: 6px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .5); }
.dots i.on { background: #fff; width: 18px; border-radius: 4px; }
.ad-body { padding: 16px; }
.ad-price { font-size: 28px; font-weight: 900; color: var(--text); }
.ad-title { font-size: 21px; font-weight: 800; margin: 6px 0 10px; line-height: 1.25; }
.ad-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); }
.tag-pill { padding: 5px 10px; border-radius: 10px; background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 13.5px; }
.ad-loc { display: flex; align-items: center; gap: 4px; }
.ad-loc svg { width: 18px; height: 18px; }
.ad-desc { white-space: pre-wrap; margin: 0; font-size: 16px; line-height: 1.45; }
.link-btn { margin-top: 14px; color: var(--accent-2); font-weight: 700; }
.translated-note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.own-note { margin-top: 18px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); color: var(--muted); }
.ad-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; display: flex; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line);
}
.square-btn { width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; }

/* ----- Сообщение ----- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 20;
  padding: 14px 16px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow);
  border: 1px solid var(--line); text-align: center;
}

/* ----- Создание объявления ----- */
.page-head { padding: 14px 0 4px; }
.create-body { padding: 0 16px 24px; }
.photos-head { margin: 6px 0 8px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.photo-tile { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: var(--surface-2); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .remove {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; background: rgba(10, 14, 30, .6);
}
.photo-tile .remove svg { width: 16px; height: 16px; }
.photo-tile .main-badge {
  position: absolute; left: 6px; top: 6px; padding: 2px 7px; border-radius: 8px;
  font-size: 11px; font-weight: 700; color: #fff; background: rgba(10, 14, 30, .6);
}
.photo-tile .main-badge.first { background: var(--accent); }
/* Стрелки порядка */
.photo-arrows { position: absolute; left: 6px; right: 6px; bottom: 6px; display: flex; justify-content: space-between; }
.photo-arrows button { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(10, 14, 30, .6); }
.photo-arrows button:disabled { visibility: hidden; }
.photo-arrows svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.5; }
/* Перетаскивание */
.photo-tile { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: transform .15s; }
.photo-tile.lifted { transform: scale(1.08); box-shadow: 0 10px 24px rgba(0, 0, 0, .35); z-index: 2; }
.photo-tile.drop { outline: 3px solid var(--accent); outline-offset: -3px; }
body.photo-dragging { overflow: hidden; }
.photo-add {
  aspect-ratio: 1; border-radius: 14px; border: 1.5px dashed var(--line); color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-size: 12.5px; font-weight: 600;
}
.field textarea { font-family: inherit; line-height: 1.4; width: 100%; border: 0; outline: 0; background: none; font-size: 16px; resize: none; padding: 2px 0; color: var(--text); }
.field input::placeholder { color: var(--muted); }
.counter { float: right; font-style: normal; }
.range .field.grow { flex: 1; }
.range .field.currency { flex: 0 0 42%; position: relative; padding-right: 40px; }
#cPriceRow { margin-bottom: 12px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); margin-bottom: 12px; }
.segmented button { height: 40px; border-radius: 11px; font-weight: 600; font-size: 14px; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
#cGeo { display: block; margin: -4px 0 14px; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); }
.switch-row > span { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.switch-row small { color: var(--muted); font-size: 13px; }
.switch-row input { display: none; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 15px; background: var(--line); transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(20px); }
.switch-row.disabled { opacity: .6; }
.btn:disabled { opacity: .6; }
.create-done { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.create-done p { white-space: pre-wrap; font-size: 17px; margin: 0 0 12px; }
.create-done .btn { width: 100%; max-width: 320px; }
.done-emoji { font-size: 64px; }

/* ----- Профиль ----- */
.pad { margin-left: 16px; margin-right: 16px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; margin-top: 0; }

/* Правила, жалобы, продление */
#rulesFoot { grid-template-columns: 1fr; }

/* Сохранить поиск */
.subtitle { display: flex; align-items: center; gap: 6px; }
.save-search { margin-left: auto; padding: 6px 12px; border-radius: 12px; background: var(--surface-2); color: var(--accent-2); font-weight: 700; font-size: 13.5px; }
.saved-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.saved-row { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.saved-row .name { flex: 1; font-weight: 600; font-size: 14.5px; text-align: left; color: var(--text); }
.saved-row .del { color: var(--red); font-size: 13px; font-weight: 700; padding: 6px 8px; }

/* Продавец на странице объявления */
.seller-row { display: flex; align-items: center; gap: 12px; width: 100%; margin: 14px 0 4px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); text-align: left; color: var(--text); }
.seller-avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-size: 20px; }
.seller-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.seller-info small { color: var(--muted); font-size: 13px; }
.seller-row svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; opacity: .5; }
.seller-grid { padding: 0; margin-top: 8px; }
.my-actions .sold { color: var(--accent-2); }

/* Подсказки названия */
.suggest-list { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 14px; }
.suggest-list button { padding: 8px 12px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-size: 14px; font-weight: 600; border: 1px solid var(--line); }
.suggest-list button:active { background: var(--accent); color: #fff; }

/* Характеристики авто и недвижимости */
.specs-form:empty { display: none; }
.specs-form { display: flex; flex-direction: column; }
.specs-form .hidden-input { margin-top: -6px; }
.spec-list { margin: 14px 0 4px; border-radius: 14px; background: var(--surface-2); padding: 4px 14px; }
.spec-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.spec-row:last-child { border-bottom: none; }
.spec-row span:first-child { color: var(--muted); }
.spec-row span:last-child { font-weight: 700; text-align: right; }
.card .spec { color: var(--text); font-weight: 600; }
.spec-seg { display: flex; margin-bottom: 14px; }
.segmented.two { grid-template-columns: repeat(2, 1fr); }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
#filterSheet .switch-row { margin-top: 14px; }
.spec-seg button { flex: 1; min-width: 0; height: auto; min-height: 40px; padding: 6px 4px; font-size: 12.5px; line-height: 1.15; white-space: normal; hyphens: auto; }
.specs-form .switch-row { margin: 4px 0 14px; }
.rules-text { white-space: pre-line; line-height: 1.55; font-size: 15px; margin: 4px 0 0; }
.row-btn { display: flex; align-items: center; justify-content: space-between; width: calc(100% - 32px); margin: 14px 16px 0; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 15px; }
.row-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; opacity: .5; }
.report-link { color: var(--muted); font-size: 14px; font-weight: 600; }
.small-link { font-size: 13.5px; font-weight: 600; text-align: left; }
.reason-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
#reportFoot { grid-template-columns: 1fr; }
.report-comment { margin-top: 16px; }
.reason-list button.on { outline: 2px solid var(--accent); outline-offset: -2px; color: var(--accent-2); }
.reason-list button { padding: 15px 16px; border-radius: 14px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 15px; text-align: left; }
.expires { color: var(--muted); font-size: 12.5px; }
.my-actions .renew { grid-column: 1 / -1; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.tab span { font-size: 11px; }

.premium-card {
  margin: 12px 16px 6px; padding: 18px; border-radius: 20px; color: #fff;
  background: linear-gradient(135deg, #1f5bff 0%, #3a8dff 60%, var(--accent-2) 100%);
  box-shadow: 0 10px 24px rgba(31, 91, 255, .35);
}
.premium-card h2 { margin: 0 0 4px; font-size: 21px; font-weight: 900; }
.premium-card .price { font-size: 15px; font-weight: 700; opacity: .95; margin-bottom: 12px; }
.premium-card ul { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 7px; }
.premium-card li { display: flex; gap: 8px; font-size: 14.5px; }
.premium-card li::before { content: "✓"; font-weight: 900; }
.premium-card .note { font-size: 13.5px; opacity: .9; margin: 6px 0 0; }
.premium-card .btn { width: 100%; background: #fff; color: #1f5bff; box-shadow: none; }

.segmented.lang { grid-template-columns: repeat(3, 1fr); }
.segmented.lang button { font-size: 13px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 8px; }
.section-head .group-title { margin-bottom: 8px; }

.my-list { display: grid; gap: 10px; padding: 0 16px; }
.my-row { display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 10px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.my-row .thumb { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; }
.my-row .name { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.my-row .price { font-weight: 700; margin: 2px 0 4px; }
.my-row .row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.status { padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--text); }
.status.approved { background: rgba(51, 194, 122, .18); color: #33c27a; }
.status.pending { background: rgba(255, 176, 32, .18); color: #ffb020; }
.status.rejected { background: rgba(239, 59, 69, .18); color: var(--red); }
.my-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.my-actions button { height: 40px; border-radius: 12px; background: var(--surface-2); font-weight: 600; font-size: 14px; }
.my-actions .danger { color: var(--red); }
