/*
 * Доска СБ — вид для компьютера. Раскладка привычная для досок объявлений:
 * шапка с поиском, слева категории, справа сетка карточек.
 *
 * Мобильные страницы этот файл не трогает: он подключается только
 * страницами раздела для больших экранов.
 */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f2f3f5;
  --text: #0f1419;
  --text-muted: #70757a;
  --line: #e4e6eb;
  --accent: #04a981;
  --accent-dark: #038a6a;
  --danger: #ed4956;
  --shadow: 0 1px 2px rgba(15, 20, 25, .06), 0 4px 16px rgba(15, 20, 25, .06);
  --radius: 14px;
  --header-h: 68px;
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f11;
    --surface: #17191c;
    --surface-2: #1f2226;
    --text: #f2f3f5;
    --text-muted: #9aa0a6;
    --line: #2a2e33;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 18px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }

.wrap { width: min(1440px, 100% - 48px); margin: 0 auto; }

/* ── Шапка ──────────────────────────────────────────────────────────── */

/* Шапку рисует общий модуль внутрь #top. Без display:contents прилипание
   работало бы только в пределах этой обёртки — то есть почти никак. */
#top { display: contents; }

.header {
  position: sticky; top: 0; z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.header-in {
  height: var(--header-h);
  display: flex; align-items: center; gap: 22px;
}

.logo { display: flex; align-items: center; flex: 0 0 auto; }
/* Значок приложения: ярлык в скруглённом квадрате, без подписи. */
.logo-mark { width: 46px; height: 46px; border-radius: 12px; display: block; }

.search { flex: 1 1 auto; min-width: 0; display: flex; gap: 8px; }
.search-field {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 12px;
  transition: border-color .15s ease, background .15s ease;
}
.search-field:focus-within { border-color: var(--accent); background: var(--surface); }
.search-field svg { flex: 0 0 auto; margin-left: 14px; color: var(--text-muted); }
.search-field input {
  flex: 1 1 auto; min-width: 0; border: 0; background: none; color: inherit;
  padding: 12px 14px; font: inherit; font-size: .97rem; outline: none;
}
.search-field select {
  flex: 0 0 auto; max-width: 210px; border: 0; border-left: 1px solid var(--line);
  background: none; color: var(--text-muted); font: inherit; font-size: .9rem;
  padding: 12px 14px; outline: none; cursor: pointer; border-radius: 0 12px 12px 0;
}
.search-go {
  flex: 0 0 auto; border: 0; border-radius: 12px; background: var(--accent); color: #fff;
  font-weight: 700; font-size: .95rem; padding: 0 26px; cursor: pointer;
  transition: background .15s ease;
}
.search-go:hover { background: var(--accent-dark); }

.header-side { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.hbtn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 12px; border-radius: 10px; border: 0; background: none; color: var(--text-muted);
  font-size: .72rem; cursor: pointer; text-align: center; min-width: 74px;
  transition: background .15s ease, color .15s ease;
}
.hbtn:hover { background: var(--surface-2); color: var(--text); }
.hbtn .dot {
  position: absolute; margin: -4px 0 0 18px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}
.hbtn .ava {
  width: 26px; height: 26px; border-radius: 50%; overflow: hidden; background: var(--surface-2);
  display: grid; place-items: center; font-size: .72rem; font-weight: 700; color: var(--text-muted);
}
.hbtn .ava img { width: 100%; height: 100%; object-fit: cover; display: block; }

.new-ad {
  flex: 0 0 auto; border: 0; border-radius: 12px; background: var(--text); color: var(--bg);
  font-weight: 700; font-size: .92rem; padding: 12px 20px; cursor: pointer; white-space: nowrap;
}
.new-ad:hover { opacity: .88; }

/* ── Раскладка страницы ─────────────────────────────────────────────── */

.page { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 28px; padding: 26px 0 60px; }
.page-body { min-width: 0; }
/* Формы внутри общей раскладки не растягиваем на всю ширину. */
.page-body.narrow { width: min(760px, 100%); }
.page-body.mid { width: min(900px, 100%); }

.side { position: sticky; top: calc(var(--header-h) + 22px); align-self: start; }
.side h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 10px 12px; }
.side ul { list-style: none; margin: 0; padding: 0; }
/* Ссылка и кнопка выглядят одинаково: на ленте это кнопки (переключают
   на месте), на остальных страницах — ссылки на ленту. */
.side button, .side a {
  display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text);
  padding: 9px 12px; border-radius: 10px; cursor: pointer; font: inherit; font-size: .93rem; line-height: 1.25;
  transition: background .12s ease;
}
.side button:hover, .side a:hover { background: var(--surface-2); }
.side button.on, .side a.on { background: var(--accent); color: #fff; font-weight: 700; }

/* Согласие под кнопкой входа: мелко, но читаемо — оно должно быть на виду. */
.consent { color: var(--text-muted); font-size: .78rem; line-height: 1.5; margin: 12px 0 0; text-align: center; }
.consent a { color: inherit; text-decoration: underline; }

/* Документы под категориями: нужны редко, поэтому тише и мельче. */
.side-docs { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.side-docs a { color: var(--text-muted); font-size: .84rem; padding: 6px 12px; }
.side-docs a:hover { color: var(--text); }

.toolbar { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.toolbar h1 { margin: 0; font-size: 1.55rem; letter-spacing: -.02em; }
.toolbar .count { color: var(--text-muted); font-size: .9rem; }
.toolbar .views { margin-left: auto; display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.toolbar .views button { border: 0; background: none; color: var(--text-muted); padding: 6px 9px; border-radius: 8px; cursor: pointer; line-height: 0; }
.toolbar .views button.on { background: var(--surface-2); color: var(--text); }

/* ── Карточки ───────────────────────────────────────────────────────── */

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 1320px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1040px) { .page { grid-template-columns: 1fr; } .side { position: static; } .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card {
  display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .14s ease, box-shadow .14s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(15,20,25,.08), 0 10px 26px rgba(15,20,25,.12); }
/* flex: 0 0 auto — иначе в ряду с высокой карточкой фото растягивается. */
.card .ph { position: relative; flex: 0 0 auto; aspect-ratio: 4 / 3; background: var(--surface-2); }
/* Снимок кладём поверх рамки: иначе своей высотой он растянул бы её
   и заданное соотношение сторон перестало бы действовать. */
.card .ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.card .ph .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-muted); font-size: .85rem; }
.card .shots {
  position: absolute; left: 10px; bottom: 10px; padding: 3px 8px; border-radius: 999px;
  background: rgba(0,0,0,.55); color: #fff; font-size: .74rem; font-weight: 600;
}
.fav {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.92); color: #0f1419; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.18); transition: transform .12s ease;
}
.fav:hover { transform: scale(1.08); }
.fav.on { color: var(--danger); }
.fav svg { pointer-events: none; }

.card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 5px; flex: 1 1 auto; }
.card .price { font-size: 1.18rem; font-weight: 800; letter-spacing: -.02em; }
.card .title { font-size: .95rem; line-height: 1.3; }
.card .desc {
  font-size: .85rem; color: var(--text-muted); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .foot {
  margin-top: auto; padding-top: 8px; display: flex; gap: 8px; align-items: center;
  color: var(--text-muted); font-size: .78rem; white-space: nowrap;
}
.card .foot .sep { opacity: .5; }
.card .foot span:last-child { overflow: hidden; text-overflow: ellipsis; }

/* ── Состояния и кнопки ─────────────────────────────────────────────── */

.state { padding: 60px 0; text-align: center; color: var(--text-muted); }
.more-wrap { display: flex; justify-content: center; padding: 30px 0 10px; }
.more {
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 12px;
  padding: 13px 34px; font-weight: 700; cursor: pointer;
}
.more:hover { background: var(--surface-2); }

.sk { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.sk .ph { aspect-ratio: 4 / 3; }
.sk .line { height: 12px; margin: 12px 14px 0; border-radius: 6px; }
.sk .line.short { width: 45%; }
.sk .line.last { margin-bottom: 16px; width: 70%; }
.shimmer {
  background: linear-gradient(100deg, var(--surface-2) 30%, rgba(255,255,255,.55) 50%, var(--surface-2) 70%);
  background-size: 240% 100%; animation: shimmer 1.3s linear infinite;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shimmer {
    background: linear-gradient(100deg, var(--surface-2) 30%, rgba(255,255,255,.08) 50%, var(--surface-2) 70%);
    background-size: 240% 100%;
  }
}
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -40% 0; } }

/* ── Страница объявления ────────────────────────────────────────────── */

.crumbs { display: flex; gap: 8px; align-items: center; color: var(--text-muted); font-size: .85rem; padding: 20px 0 14px; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }

.ad { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; align-items: start; padding-bottom: 70px; }
@media (max-width: 1040px) { .ad { grid-template-columns: 1fr; } }

.ad h1 { margin: 0 0 14px; font-size: 1.8rem; line-height: 1.2; letter-spacing: -.02em; }
.ad-meta { display: flex; gap: 10px; color: var(--text-muted); font-size: .85rem; margin-bottom: 18px; }

.gallery { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
/* Высоту задаём прямо: снимок вписывается целиком, а карточка не занимает
   пол-экрана чёрными полями, как было бы при жёстком соотношении сторон. */
.shot { position: relative; height: min(58vh, 520px); background: #101215; }
.shot img, .shot video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; background: #0b0c0d; }
.shot .nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 0;
  border-radius: 50%; background: rgba(255,255,255,.9); color: #0f1419; cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 2px 10px rgba(0,0,0,.2);
}
.shot .nav.prev { left: 14px; }
.shot .nav.next { right: 14px; }
.thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; }
.thumbs button { flex: 0 0 auto; width: 76px; height: 60px; border: 2px solid transparent; border-radius: 10px; overflow: hidden; padding: 0; background: var(--surface-2); cursor: pointer; }
.thumbs button.on { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

.block { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-top: 18px; }
.block h2 { margin: 0 0 12px; font-size: 1.1rem; }
.block p { margin: 0; line-height: 1.55; white-space: pre-wrap; }
.props { display: grid; gap: 10px; margin: 0; }
.props div { display: flex; gap: 10px; align-items: baseline; }
.props dt { color: var(--text-muted); font-size: .9rem; min-width: 150px; }
.props dd { margin: 0; font-size: .94rem; }

.aside { position: sticky; top: calc(var(--header-h) + 22px); display: grid; gap: 18px; }
.buy { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.buy .price { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; }
.buy .actions { display: grid; gap: 10px; margin-top: 18px; }
.btn {
  border: 0; border-radius: 12px; padding: 14px; font-weight: 700; font-size: .96rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.ghost:hover { background: var(--line); }

.seller { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.seller .who { display: flex; gap: 12px; align-items: center; }
.seller .ava { width: 52px; height: 52px; border-radius: 50%; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; color: var(--text-muted); }
.seller .ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Имя и число объявлений — в столбик: span'ы строчные, поэтому без
   display:block они вставали в одну строку. */
.seller .who > span:last-child { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.seller .nm, .seller .sub { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seller .nm { font-weight: 700; }
.seller .sub { color: var(--text-muted); font-size: .84rem; margin-top: 3px; }
.seller a.all { display: block; margin-top: 14px; color: var(--accent); font-weight: 600; font-size: .9rem; }

.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #0f1419; color: #fff; padding: 12px 20px; border-radius: 12px; font-size: .9rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 90;
}

/* Полоса «это предпросмотр» — уберётся, когда вид включим по-настоящему. */
.preview-bar {
  background: #1f2937; color: #e5e7eb; font-size: .82rem; text-align: center; padding: 7px 16px;
}
.preview-bar b { color: #fff; }
.preview-bar a { color: #fff; text-decoration: underline; }

.hbtn.on { color: var(--text); background: var(--surface-2); }

/* ── Окна поверх страницы ───────────────────────────────────────────── */

.modal-back {
  position: fixed; inset: 0; z-index: 80; background: rgba(15, 20, 25, .55);
  display: grid; place-items: center; padding: 24px;
}
.modal {
  width: min(520px, 100%); max-height: 86vh; overflow: auto; background: var(--surface);
  border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; }
.modal-head b { font-size: 1.05rem; margin-right: auto; }
.modal-x { border: 0; background: none; color: var(--text-muted); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-body { padding: 0 20px 20px; display: grid; gap: 14px; }

/* Карточка объявления в окне «написать по объявлению». */
.ad-dm {
  display: flex; gap: 14px; align-items: center; padding: 12px;
  background: var(--surface-2); border-radius: 14px;
}
.ad-dm img, .ad-dm .no-ph { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--line); flex: 0 0 auto; }
.ad-dm > div { flex: 1 1 auto; min-width: 0; }
/* Длинное название прячем после второй строки, а не выпускаем за окно. */
.ad-dm .t {
  font-weight: 700; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ad-dm .u { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-dm .p { font-weight: 800; margin-top: 2px; }
.ad-dm .u { color: var(--text-muted); font-size: .84rem; margin-top: 2px; }

.reasons { display: flex; flex-wrap: wrap; gap: 8px; }
.reason {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: 9px 14px; font-size: .88rem; cursor: pointer;
}
.reason.on { background: var(--text); color: var(--surface); border-color: transparent; font-weight: 700; }
.reason-text {
  width: 100%; min-height: 90px; resize: vertical; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface-2); color: var(--text); padding: 12px 14px; font: inherit; outline: none;
}
.reason-text:focus { border-color: var(--accent); }

/* ── Формы ──────────────────────────────────────────────────────────── */

.form-page { width: min(760px, 100%); margin: 0 auto; padding: 26px 0 70px; }
.form-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; }
.form-card h1 { margin: 0 0 4px; font-size: 1.5rem; letter-spacing: -.02em; }
.form-card .lead { color: var(--text-muted); font-size: .92rem; margin-bottom: 20px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span, .field > label { font-size: .84rem; color: var(--text-muted); font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font: inherit; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); background: var(--surface); }
.field textarea { min-height: 130px; resize: vertical; }
.field .hint { font-size: .8rem; color: var(--text-muted); min-height: 1.1em; }
.field .hint.free { color: #0a7d32; font-weight: 600; }
.field .hint.busy { color: var(--danger); font-weight: 600; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } }

.banner { padding: 12px 14px; border-radius: 12px; font-size: .9rem; margin-bottom: 16px; }
.banner.err { background: rgba(237, 73, 86, .12); color: var(--danger); }
.banner.ok { background: rgba(4, 169, 129, .12); color: var(--accent-dark); }

.btn.wide { width: 100%; }
.btn.danger { background: rgba(237, 73, 86, .12); color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; }

/* Снимки в форме объявления. */
.shots { display: flex; flex-wrap: wrap; gap: 12px; }
.shot-item {
  position: relative; width: 132px; height: 132px; border-radius: 12px; overflow: hidden;
  background: var(--surface-2);
}
.shot-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-item .x {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .65); color: #fff; cursor: pointer; line-height: 1; display: grid; place-items: center;
}
.shot-add {
  width: 132px; height: 132px; border: 2px dashed var(--line); border-radius: 12px; background: none;
  color: var(--text-muted); cursor: pointer; display: grid; place-items: center; gap: 4px; font-size: .84rem;
}
.shot-add:hover { border-color: var(--accent); color: var(--accent); }

/* Переключатель «дублировать на почту». */
.switch { display: flex; align-items: center; gap: 16px; padding: 4px 0 18px; }
.switch-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.switch-text b { font-size: .96rem; }
.switch-text span { font-size: .84rem; color: var(--text-muted); line-height: 1.4; }
.toggle { flex: 0 0 auto; position: relative; width: 50px; height: 30px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.knob { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .18s ease; pointer-events: none; }
.knob:after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .18s ease;
}
.toggle input:checked + .knob { background: var(--accent); }
.toggle input:checked + .knob:after { transform: translateX(20px); }

/* ── Профиль ────────────────────────────────────────────────────────── */

.profile { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; margin-bottom: 24px; }
.profile-top { display: flex; gap: 22px; align-items: center; }
/* Кружок с фотографией. Не привязан к странице профиля: тот же блок стоит
   и в настройках — без общих правил снимок вылезал за рамку на всю ширину. */
.ava-big {
  width: 104px; height: 104px; border-radius: 50%; overflow: hidden; background: var(--surface-2);
  display: grid; place-items: center; font-weight: 800; font-size: 2rem; color: var(--text-muted); flex: 0 0 auto;
}
.ava-big img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile .who { flex: 1; min-width: 0; }
.profile .nm { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.profile .un { color: var(--text-muted); margin-top: 2px; }
.profile .bio { margin-top: 10px; line-height: 1.5; white-space: pre-wrap; }
.profile .stats { display: flex; gap: 26px; margin-top: 14px; color: var(--text-muted); font-size: .9rem; }
.profile .stats b { color: var(--text); font-size: 1.05rem; }
.profile .acts { display: flex; gap: 10px; flex: 0 0 auto; flex-direction: column; min-width: 190px; }
.profile .acts .btn { padding: 12px 18px; }
@media (max-width: 720px) { .profile-top { flex-direction: column; align-items: flex-start; } .profile .acts { flex-direction: row; width: 100%; } }

.section-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 16px; }
.section-head h2 { margin: 0; font-size: 1.25rem; letter-spacing: -.01em; }
.section-head .count { color: var(--text-muted); font-size: .88rem; }

/* ── Переписка ──────────────────────────────────────────────────────── */

.dm { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 0; height: calc(100vh - var(--header-h) - 30px - 68px); }
.dm-list { background: var(--surface); border-radius: var(--radius) 0 0 var(--radius); border-right: 1px solid var(--line); overflow-y: auto; box-shadow: var(--shadow); }
.dm-search-wrap { padding: 14px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.dm-search-wrap input {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font: inherit; outline: none;
}
.dm-row {
  display: flex; gap: 12px; align-items: center; width: 100%; padding: 12px 16px;
  border: 0; background: none; color: inherit; text-align: left; cursor: pointer; font: inherit;
  border-bottom: 1px solid var(--line);
}
.dm-row:hover { background: var(--surface-2); }
.dm-row.on { background: var(--surface-2); }
.dm-row .ava { width: 48px; height: 48px; border-radius: 50%; overflow: hidden; background: var(--bg); display: grid; place-items: center; font-weight: 700; color: var(--text-muted); flex: 0 0 auto; }
.dm-row .ava img { width: 100%; height: 100%; object-fit: cover; }
.dm-row .meta { flex: 1; min-width: 0; }
.dm-row .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.dm-row .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-row .time { color: var(--text-muted); font-size: 12px; flex: 0 0 auto; }
.dm-row .last { font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.dm-row.unread .nm, .dm-row.unread .last { color: var(--text); font-weight: 700; }
.dm-count {
  flex: 0 0 auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--text); color: var(--surface); font-size: 12px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}

.dm-pane { background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; display: flex; flex-direction: column; min-width: 0; box-shadow: var(--shadow); }
.dm-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.dm-head .ava { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--text-muted); }
.dm-head .ava img { width: 100%; height: 100%; object-fit: cover; }
.dm-head .nm { font-weight: 700; }
.dm-thread { flex: 1; min-height: 0; overflow-y: auto; overflow-anchor: none; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.dm-welcome { margin: auto; width: min(340px, 100%); padding: 18px 20px; border-radius: 16px; background: var(--surface-2); text-align: center; display: grid; gap: 6px; }
.dm-welcome b { font-size: .98rem; }
.dm-welcome span { font-size: .86rem; color: var(--text-muted); line-height: 1.4; }
.bubble-wrap { display: flex; flex-direction: column; max-width: 68%; }
.bubble-wrap.mine { align-self: flex-end; align-items: flex-end; }
.bubble-wrap.theirs { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 10px 14px; border-radius: 16px; font-size: .95rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.bubble.mine { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.bubble.theirs { background: var(--surface-2); color: var(--text); border-bottom-left-radius: 5px; }
.bubble-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.bubble-media { display: flex; flex-wrap: wrap; gap: 6px; max-width: 320px; }
.bubble-media img, .bubble-media video { width: 154px; height: 154px; object-fit: cover; border-radius: 12px; display: block; background: var(--surface-2); cursor: pointer; }
.bubble-post {
  display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); margin-bottom: 4px; width: min(260px, 100%);
}
.bubble-post img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; background: var(--surface-2); }
/* Длинное название не должно вылезать за карточку: колонка сжимаемая,
   строки — блочные, иначе обрезка по ширине не сработает. */
.bubble-post > span { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.bubble-post .t, .bubble-post .p { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble-post .t { font-size: .86rem; font-weight: 600; }
.bubble-post .p { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }

.dm-compose { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 14px 20px; display: flex; gap: 10px; align-items: center; }
.dm-compose input[type="text"] {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 22px; padding: 12px 16px; font: inherit; outline: none;
}
.dm-compose input[type="text"]:focus { border-color: var(--accent); background: var(--surface); }
.dm-compose .icon-btn { width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--text); cursor: pointer; display: grid; place-items: center; }
.dm-compose .icon-btn:hover { background: var(--line); }
.dm-send { border: 0; border-radius: 22px; background: var(--accent); color: #fff; font-weight: 700; padding: 12px 24px; cursor: pointer; }
.dm-send:disabled { opacity: .45; cursor: default; }
.dm-attach { display: flex; gap: 8px; padding: 0 20px 10px; flex-wrap: wrap; }
.dm-attach .thumb { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.dm-attach .thumb img, .dm-attach .thumb video { width: 100%; height: 100%; object-fit: cover; }
.dm-attach .thumb button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; line-height: 1; }
.dm-empty { margin: auto; text-align: center; color: var(--text-muted); }

@media (max-width: 1040px) { .dm { grid-template-columns: 1fr; height: auto; } .dm-list { border-radius: var(--radius); border-right: 0; max-height: 50vh; } .dm-pane { border-radius: var(--radius); margin-top: 16px; min-height: 70vh; } }

/* Просмотр снимка из переписки. */
.viewer { position: fixed; inset: 0; z-index: 95; background: rgba(0,0,0,.92); display: grid; place-items: center; }
.viewer img, .viewer video { max-width: 92vw; max-height: 92vh; display: block; }
.viewer .x { position: absolute; top: 20px; right: 26px; border: 0; background: none; color: #fff; font-size: 2rem; cursor: pointer; line-height: 1; }

/* ── Модерация ──────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tabs button {
  border: 1px solid var(--line); background: var(--surface); color: var(--text-muted);
  border-radius: 999px; padding: 9px 18px; cursor: pointer; font-weight: 600;
}
.tabs button.on { background: var(--text); color: var(--surface); border-color: transparent; }
.item { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 12px; }
.item .muted { color: var(--text-muted); font-size: .84rem; }
.item .reason { margin-top: 6px; line-height: 1.45; }
.item .quote { margin-top: 8px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; font-size: .9rem; }
.item .btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.item .btns a, .item .btns button {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 10px;
  padding: 8px 14px; font-size: .88rem; cursor: pointer; font-weight: 600;
}
.item .btns .danger { color: var(--danger); }
.row-user { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 10px; }
.row-user .ava { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--text-muted); }
.row-user .ava img { width: 100%; height: 100%; object-fit: cover; }
.row-user .who { flex: 1; min-width: 0; }
.row-user .nm { font-weight: 600; }
.row-user button { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
