/* Митридат — минимальный стиль, мобильный-фёрст, без фреймворков */
/* Палитра на переменных (M4.12): светлая 004 — значения исходные, тёмная гамма — html[data-theme="dark"] */
:root {
  color-scheme: light;
  --w-portal: 72rem;   /* ширина портальных витрин M4.15 (статья/тред — как было) */
  --c-bg: #faf9f5;
  --c-text: #26221c;
  --c-muted: #8b8577;
  --c-border: #e2ddd0;
  --c-card: #fff;
  --c-accent: #a34a24;
  --c-on-accent: #fff8ee;
  --c-link: #8a5a24;
  --c-soft: #f1ecdf;
  --c-flash: #e7f0d8;
  --c-rail: #d9cfbb;
  --c-dim: #6f6857;
  --c-header: rgba(250,249,245,.95);
  --c-shadow: rgba(38,34,28,.05);
  --c-shadow-hover: rgba(38,34,28,.09);
  --c-shadow-accent: rgba(163,74,36,.25);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --c-bg: #17181a;
  --c-text: #e8e4dc;
  --c-muted: #9a958a;
  --c-border: #34363a;
  --c-card: #212326;
  --c-accent: #a34a24;
  --c-on-accent: #fff8ee;
  --c-link: #c98f55;
  --c-soft: #2a2c30;
  --c-flash: #293317;
  --c-rail: #3a3d42;
  --c-dim: #bdb6a8;
  --c-header: rgba(23,24,26,.95);
  --c-shadow: rgba(0,0,0,.3);
  --c-shadow-hover: rgba(0,0,0,.45);
  --c-shadow-accent: rgba(0,0,0,.4);
}
body {
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.65; margin: 0; padding: 0 1rem;
  background: var(--c-bg); color: var(--c-text);
  /* M4.20: колонка на весь экран — footer прижат к низу вьюпорта */
  min-height: 100vh; display: flex; flex-direction: column;
}
.wrap { width: 100%; max-width: var(--w-portal); margin: 0 auto; box-sizing: border-box; }
/* M4.23: одна ширина со шапкой; width:100% — во flex-теле авто-поля и max-width без явной ширины ужали бы во fit-content */
body > .wrap { flex: 1 0 auto; padding-top: 1.2rem; }  /* flex:1 — подвал прижат к низу (M4.20) */

/* Каркас M4.0: шапка, меню, футер (палитра макета 004) */
header {
  position: sticky; top: 0; z-index: 10;
  background: var(--c-header); border-bottom: 1px solid var(--c-border);
}
.head-in {
  display: flex; justify-content: space-between; align-items: center;
  max-width: var(--w-portal); margin: 0 auto;   /* шапка в портальной ширине M4.15 — не прыгает по страницам */
  gap: .8rem; flex-wrap: wrap; padding: .3rem 1rem;   /* M4.16f-3: компактная вертикаль */
}
/* М4.16f-3: меню центрируется в пространстве между лого и auth; мобайл — раскладка прежняя */
@media (min-width: 721px) { .head-in .menu { flex: 1; justify-content: center; } }
/* Шапка без прыжков M4.5: на десктопе без переноса, «Войти» не рвётся; мобайл может wrap */
.auth { white-space: nowrap; display: flex; align-items: center; gap: .9rem; }
@media (min-width: 721px) { .head-in.nowrap { flex-wrap: nowrap; } }
.brand b { font-size: 1.2rem; letter-spacing: .17em; }   /* M4.15: по-портальному крупнее */
.brand-col { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }   /* M4.16f: колонка справа от лого */
.brand-tag {   /* слоган под названием M4.16f: мелко, muted, uppercase-межбуквенно */
  font-size: .62rem; color: var(--c-muted); margin-top: .1rem;
  white-space: nowrap; text-transform: uppercase; letter-spacing: .12em;
}
header nav { display: flex; gap: .75rem; flex-wrap: wrap; font-size: .85rem; }
header nav a { color: var(--c-muted); text-decoration: none; }
header nav a:hover { color: var(--c-accent); }
/* Активная ветка меню M4.15: 3px лента-подчёркивание accent (тело страницы несёт класс ветки) */
body.home .menu a[href="/"],
body.news .menu a[href="/news"],
body.t-all .menu a[href="/t"],
body.story .menu a[href^="/feed"],
body.branch-gorod .menu a[href="/t/gorod"],
body.branch-turizm .menu a[href="/t/turizm"],
body.branch-istoriya .menu a[href="/t/istoriya"] {
  color: var(--c-text); text-decoration: underline; text-decoration-color: var(--c-accent);
  text-decoration-thickness: 3px; text-underline-offset: .45rem;
}
/* Кнопка-переключатель темы M4.12 — убрана из шапки в M4.16f (ползунок в ЛК, .switch ниже) */
/* Иконочный спрайт M4.12: цвет наследует текст (в тёмной теме инвертируется сам) */
.icon { width: 20px; height: 20px; vertical-align: -4px; fill: none; }
.node-mark .icon { width: 10px; height: 10px; vertical-align: -1px; }   /* пикабу-компакт */
.mark-open { transform: rotate(90deg); }   /* открытый узел — шеврон вниз */
footer { border-top: 1px solid var(--c-border); margin-top: 2.5rem; font-size: .8rem; color: var(--c-muted); }
footer .wrap { padding: 1rem 1rem 2rem; }
/* Сетка M4.0/M4.5: одна сетка main + сайдбар на всех страницах (шапка не прыгает) */
/* M4.23: .wide/.portal .wrap сняты — ширина одна на всех; читаемость держит колонка текста */
.post-main, .post-body, .body { max-width: 68ch; }   /* md-текст колонкой ~68ch, контейнер не ужиляется */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 2rem; align-items: start; }
.layout aside h2 { font-size: 1rem; margin-top: 0; }
@media (max-width: 720px) { .layout { grid-template-columns: 1fr; } }
/* Портальная сетка M4.15: витрины шире (72rem, сайдбар 18rem); M4.23: .wrap уже на var(--w-portal) — переопределения сняты */
.portal .layout { grid-template-columns: minmax(0, 1fr) 18rem; }
@media (max-width: 899px) { .portal .layout { grid-template-columns: 1fr; } }
/* Служебная полоса M4.15: «Керчь · дата» + компакт-погода/поиск над шапкой; на мобиле — дата+поиск */
/* Скрытый спрайт-пустышка M4.16f-3: [hidden] на SVG UA не скрывает (display:inline, 300×150 — 150px пустоты над topline) */
svg[hidden] { display: none; }
.topline { border-bottom: 1px solid var(--c-border); font-size: .82rem; color: var(--c-muted); }
.topline-in { max-width: var(--w-portal); margin: 0 auto; display: flex; justify-content: space-between;
              align-items: center; gap: .8rem; flex-wrap: wrap; padding: .15rem 1rem; }   /* M4.16f-3: компактно */
.tl-date { white-space: nowrap; }
.tl-right { display: flex; align-items: center; gap: .8rem; }
.tl-wx { white-space: nowrap; color: var(--c-text); }
.tl-wx .wicon { width: 16px; height: 16px; vertical-align: -3px; }
@media (max-width: 899px) { .tl-wx { display: none; } }
/* Сайдбар M4.5: блоки «Погода», «Топ-5», «Эксклюзивы» — общий include */
.side-block {
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: 10px;
  padding: .6rem .9rem; margin-bottom: 1rem;
}
.side-list { margin: 0; padding-left: 1.1rem; font-size: .9rem; }
.side-list li { margin: .3rem 0; }
.side-note { margin: .4rem 0 0; font-size: .78rem; color: var(--c-muted); }
.side-block .score { color: var(--c-muted); font-size: .85rem; }

a { color: var(--c-link); }
/* Аватарки-инициалы M4.0: кружок, тёплая палитра по нику, аноним — нейтральный */
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--c-on-accent); font-weight: 700; font-size: .9rem;
}
.av0 { background: #a34a24; } .av1 { background: #a87b2d; }
.av2 { background: #6b7a3a; } .av3 { background: #3a6b7a; }
.av4 { background: #7a4a3a; }
.avatar.anon { background: #b8b2a4; }
img.avatar { object-fit: cover; }   /* картинка вместо инициала: тот же круг */
.chip-av { width: 24px; height: 24px; vertical-align: middle; }
/* M4.18: карточка /u — аватар крупно, чип репы (обе темы на var) */
.u-card { display: flex; align-items: center; gap: 1.2rem; padding: 1.2rem;
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: 10px; }
.u-card h1 { margin: 0; }
.u-av { width: 72px; height: 72px; font-size: 2rem; }
.chip-rep { display: inline-block; padding: .1rem .6rem; border-radius: 999px;
  background: var(--c-accent); color: var(--c-on-accent);
  font-variant-numeric: tabular-nums; font-size: .85rem; }
.post-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
/* Лого в шапке M4.0 (M4.14: блок-ссылка «На главную» — ссылочные стили глушим) */
.brand { display: flex; align-items: center; gap: .55rem; color: inherit; text-decoration: none; flex: none; }
.brand img { height: 28px; width: 28px; border-radius: 50%; display: block; }
/* Карточка профиля в сайдбаре M4.16f-2: вертикальная визитка; гиря — угол карточки (рев. M4.16f) */
.profile-card { position: relative; display: flex; flex-direction: column; gap: .6rem; }
.pc-row { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.pc-main { display: flex; flex-direction: column; gap: .2rem; align-items: flex-start; min-width: 0; }
.pc-line { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; }
.pc-av { width: 40px; height: 40px; font-size: 1.1rem; flex: 0 0 auto; }
.pc-page { font-size: .78rem; }
.pc-nick { font-weight: 700; color: inherit; text-decoration: none; }
.pc-btn { display: block; width: 100%; box-sizing: border-box; text-align: center; }
.pc-gear { position: absolute; top: .55rem; right: .55rem; color: var(--c-muted); }
.pc-gear:hover { color: var(--c-accent); }
/* Hero-баннер M4.14: панорама Керчи (модельный ассет владельца); заголовок в потоке — не накладывается на картинку */
.hero { margin-bottom: 1.4rem; }
.hero img { width: 100%; aspect-ratio: 3 / 1; object-fit: cover; display: block; border-radius: 12px; }
.hero h1 { margin: 0; }
.hero-sub { margin: .1rem 0 .8rem; color: var(--c-muted); }
/* Лента меандра M4.14: разделитель крупных секций главной; url в шаблоне через asset()
   (css не умеет ?v=), крем-фон фиксированный — лента в тёмной теме остаётся тонкой карточкой */
.divider {
  height: 1px; margin: 1.4rem 0; background-color: var(--c-muted);
  opacity: .28;   /* пиксельная полоска-разделитель секций (без графики, ревизия владельца) */
}
/* Иконки-ассеты M4.14: ветки в меню/секциях, бейджи факта и кофе (png-тайлы через asset()) */
.menu-ic { width: 20px; height: 20px; vertical-align: -5px; margin-right: 2px; }
.sec-head { display: flex; align-items: center; gap: .45rem; }
.sec-head h2, .sec-head h1 { margin: 0; font-size: clamp(1.3rem, 1rem + 1vw, 1.6rem); }   /* M4.15: крупные секции */
.sec-head h2 a, .news-grid h2 a { color: inherit; text-decoration: none; }      /* витрина — ведёт в раздел */
.sec-head h2 a:hover, .news-grid h2 a:hover { color: var(--c-accent); }
.sec-ic { width: 24px; height: 24px; flex: none; }
.badge-fact, .badge-coffee { width: 16px; height: 16px; vertical-align: -3px; margin-left: .35rem; }
.wicon { width: 20px; height: 20px; vertical-align: -5px; }
/* Погода виджетом (M4.15): крупная цифра, детали строкой ниже; tabular-nums для всех чисел */
.wx-big { margin: 0 0 .3rem; font-size: 2rem; font-weight: 650; line-height: 1.2;
          display: flex; align-items: center; gap: .45rem; }
.wx-big .wicon { width: 28px; height: 28px; vertical-align: 0; }
.wx-big, .tl-wx, .meta, .ago, .score { font-variant-numeric: tabular-nums; }
.cover { width: 100%; height: auto; border-radius: 10px; margin: .5rem 0 1rem; display: block; }
/* Галерея-заглушка M4.0: сетка, zoom на hover (без JS) */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1rem 0 1.4rem; }
.gallery img {
  width: 100%; height: 8rem; object-fit: cover; border-radius: 8px;
  transition: transform .15s ease;
}
.gallery img:hover { transform: scale(1.03); }
.gallery-note { grid-column: 1 / -1; margin: 0; font-size: .8rem; color: var(--c-muted); }
@media (max-width: 720px) { .gallery { grid-template-columns: 1fr; } }
/* Лайтбокс M4.0: оверлей поверх всего, картинка по центру (position:fixed — в потоке ничего не меняет) */
img.zoomable { cursor: zoom-in; }
.lightbox {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(38, 34, 28, .85); padding: 2rem;
}
.lightbox[hidden] { display: none; }   /* display:flex перебивает атрибут hidden — без этого страница затемнена */
.lightbox img { max-width: 92vw; max-height: 90vh; border-radius: 8px; }
.lightbox-close {
  position: absolute; top: .8rem; right: 1rem; font-size: 2rem; line-height: 1;
  background: none; border: none; color: #fff; cursor: pointer; padding: .5rem;
}
/* Лента-карточки M4.0: миниатюра слева, белая поверхность, hover-подъём */
.feed-item {
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: 10px;
  padding: .7rem 1rem; margin: .8rem 0; overflow: hidden;
  box-shadow: 0 1px 2px var(--c-shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.feed-item:hover { transform: translateY(-1px); box-shadow: 0 3px 10px var(--c-shadow-hover); }
.feed-thumb {
  float: left; width: 96px; height: 96px; object-fit: cover;
  border-radius: 8px; margin: 0 .8rem .4rem 0;
}
.feed-head { display: flex; align-items: center; gap: .5rem; }
.feed-item .feed-head { margin-bottom: .4rem; }
.feed-item .author { font-weight: 600; }
/* M4.10 Reddit-паттерны: рельс-голос слева, мета-строка, пилюли, дерево с рейками */
.feed-item { display: flex; gap: .6rem; }
@media (max-width: 899px) { .feed-item { flex-wrap: wrap; } }   /* на мобиле лента перестраивается в столбик, а не хлестает за край */
.feed-main { flex: 1; min-width: 0; }
.vote.rail {
  display: flex; flex-direction: column; align-items: center;
  gap: .1rem; flex-shrink: 0;
}
.vote.rail button { padding: .2rem .7rem; min-width: 44px; }
.vote.rail .score { font-weight: 600; color: var(--c-accent); }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem;
        margin: 0 0 .2rem; color: var(--c-dim); font-size: .85rem; }
.meta .ago, .ago { color: var(--c-muted); }
.meta a { margin-left: 0; }
.mod-btns { display: inline-flex; gap: 2px; align-items: center; margin-left: 3px; }
.nico, .nico button { background: none; border: 0; padding: 1px 2px; line-height: 0; color: var(--c-muted); cursor: pointer; }
.nico-i { width: 12px !important; height: 12px !important; vertical-align: -1px; opacity: .55; transition: opacity .15s; }
.nico:hover .nico-i, .nico:hover { opacity: 1; }
/* Тред-узлы: details/summary, сворачивание ветки, рейка вложенности */
.post-tree[id], .feed-item[id] { scroll-margin-top: 72px; }  /* хеш-переход к комменту не под шапку */
.post-tree { margin: .5rem 0; }
.post-tree > summary {
  display: flex; align-items: center; gap: .3rem; cursor: pointer;
  list-style: none; color: var(--c-dim); font-size: .82rem;   /* мета одной строкой, компакт */
}
.post-tree > summary::-webkit-details-marker { display: none; }
.post-tree > summary .author { font-weight: 600; color: var(--c-text); }
.node-mark { font-size: .82rem; }
.post-tree > summary .avatar { width: 24px; height: 24px; }   /* пикабу: мелкий аватар */
/* M4.16c: пикабу-пилюля голосов в строке комментария (рельс в треде снят, лента не тронута) */
.v-pill {
  display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0;
  padding: 2px 6px; border-radius: 999px; background: var(--c-soft); line-height: 1;
}
.v-pill button {
  position: relative; min-height: 0; min-width: 0; padding: 3px 4px;
  border: 0; background: none; color: var(--c-dim); transition: background .15s ease;
}
.v-pill button::after { content: ""; position: absolute; inset: -10px -2px; }   /* тап-зона ≥40px по высоте */
.v-pill button:hover {
  background: color-mix(in srgb, var(--c-accent) 10%, transparent);
  color: var(--c-accent); transform: none; box-shadow: none;
}
.v-pill button:active { color: var(--c-accent); background: none; }
.v-pill .icon { width: 14px; height: 14px; vertical-align: 0; }
.v-score {
  font-variant-numeric: tabular-nums; min-width: 1ch;
  font-weight: 600; color: var(--c-accent); font-size: .78rem;
}
.v-score.zero { color: var(--c-muted); }
/* M4.16d: ряд эмодзи-реакций под телом поста (пилюли, тап-зоны как у .v-pill) */
.reactions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: .35rem 0 .1rem; }
.reactions button {
  position: relative; min-height: 0; min-width: 0; padding: 7px 10px;
  border: 1px solid var(--c-border); border-radius: 999px;
  background: var(--c-card); color: var(--c-text); font-size: .88rem; line-height: 1;
  cursor: pointer; transition: background .15s ease;
}
.reactions button::after { content: ""; position: absolute; inset: -8px 0; }   /* тап-зона ≥40px */
.reactions button:hover { background: color-mix(in srgb, var(--c-accent) 10%, var(--c-card)); }
.reactions button.mine {
  border-color: var(--c-accent);
  background: color-mix(in srgb, var(--c-accent) 14%, var(--c-card));
}
.r-count { font-size: .75rem; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.reactions button.mine .r-count { color: var(--c-accent); font-weight: 600; }
.react-quick { display: inline-flex; gap: 2px; }
.react-quick button { border-color: transparent; background: none; opacity: .55; }
.react-quick button::after { inset: -8px 2px; }
.react-quick button:hover { background: none; opacity: 1; }
/* M4.16e: стак реакций — нейтральная капсула, полный ряд absolute-панелью (layout не прыгает) */
.reactions { position: relative; }
.reactions-stack {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px;
  border: 1px dashed var(--c-border); border-radius: 999px; color: var(--c-muted);
  cursor: pointer; line-height: 1.4;
}
.reactions-stack:hover { color: var(--c-text); border-color: var(--c-muted); }
.reactions-stack:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 1px; }
.stack-hint { font-size: .9rem; opacity: .8; }
.stack-sum { font-size: .75rem; font-variant-numeric: tabular-nums; }
.reactions-stack .react { padding: 2px 8px; font-size: .78rem; }             /* мини-пилюля своя */
.react-full {
  position: absolute; top: 0; left: 0; z-index: 5; max-width: 100%;
  display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px;
  padding: 7px 10px; border: 1px solid var(--c-border); border-radius: 12px;
  background: var(--c-bg); box-shadow: 0 2px 10px color-mix(in srgb, var(--c-text) 12%, transparent);
  opacity: 0; visibility: hidden; transition: opacity .15s ease, visibility .15s ease;
}
.reactions:hover .react-full,
.reactions:focus-within .react-full,
.reactions.open .react-full { opacity: 1; visibility: visible; }
.post-tree[open] > summary .mark-shut { display: none; }
.post-tree:not([open]) > summary .mark-open { display: none; }
.post-node { display: flex; gap: .5rem; margin-top: .25rem; }
.post-main { flex: 1; min-width: 0; }
.post-kids { margin-left: 14px; border-left: 1px solid var(--c-rail); padding-left: 14px; }   /* рейка 1px, отступ 14px/уровень */
/* M4.23 Task 8: «Ответить» у узла — компактная пилюля (форма внутри details, по открытию); главная форма внизу страницы всегда открыта */
.reply-toggle, .reply-box > summary {
  display: inline-block; padding: .35rem .9rem; margin: .3rem 0; border: 1px solid var(--c-border);
  border-radius: 999px; color: var(--c-accent); cursor: pointer; font-size: .82rem;
  background: var(--c-soft);   /* M5-E UX: заметная кнопка ответа — не путать с большой формой внизу */
}
.reply-toggle:hover, .reply-box > summary:hover { border-color: var(--c-accent); }
.reply-box > summary::-webkit-details-marker { display: none; }
/* Пилюли вкладок сортировки (Reddit-паттерн) */
.tabs { display: flex; gap: .4rem; margin: .6rem 0; }
.pill {
  display: inline-block; padding: .55rem 1.1rem; border-radius: 999px;
  border: 1px solid var(--c-accent); color: var(--c-accent); text-decoration: none; font-size: .9rem;
}
.pill:hover { text-decoration: underline; }
.pill.active { background: var(--c-accent); color: var(--c-on-accent); }
.pill.active:hover { text-decoration: none; }
span.pill { cursor: default; }
/* Кнопки M4.0: высота ≥44px, hover/active, плавный переход */
button, .btn {
  min-height: 44px; padding: .4rem 1.1rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--c-accent); background: var(--c-card); color: var(--c-accent);
  transition: background .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}
button:hover, .btn:hover {
  background: var(--c-accent); color: var(--c-on-accent);
  transform: translateY(-1px); box-shadow: 0 2px 6px var(--c-shadow-accent);
}
button:active, .btn:active { transform: translateY(0); box-shadow: none; }
.vote { display: inline-flex; gap: .3rem; }
.vote button { padding: .2rem .5rem; min-width: 44px; }
h1 { font-size: 1.55rem; line-height: 1.25; }
h2 { font-size: 1.2rem; }
.checked { color: var(--c-muted); font-size: 0.85rem; }
.facts { background: var(--c-soft); border-radius: 10px; padding: 0.4rem 1rem; }
.facts dl { margin: 0.6rem 0; }
.facts dt { font-weight: 600; margin-top: 0.5rem; }
.facts dd { margin: 0; }
.facts a { font-size: 0.8rem; }
.post-body p { margin: 0.4rem 0; }
.post-body img, .body img { max-width: 100%; border-radius: 8px; background: var(--c-soft); }   /* M4.23: фон-плейсхолдер до загрузки */
form textarea { width: 100%; min-height: 5rem; box-sizing: border-box; }
/* Инпуты согласованы с темой явно — не полагаемся на системный color-scheme (ревью /me) */
input, textarea, select {
  background: var(--c-card); color: var(--c-text);
  border: 1px solid var(--c-border); border-radius: 8px; padding: .45rem .6rem;
}
input[readonly] { color: var(--c-muted); }
/* Ползунок темы M4.16f: ЛК-переключатель, checked = тёмная; track/thumb оба на var(--c-*) */
.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative;
  width: 2.6rem; height: 1.5rem; margin: 0; padding: 0; border: 0;
  border-radius: 1rem; background: var(--c-muted); transition: background .15s;
}
.switch input::before {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: calc(1.5rem - 4px); height: calc(1.5rem - 4px); border-radius: 50%;
  background: var(--c-card); transition: transform .15s;
}
.switch input:checked { background: var(--c-accent); }
.switch input:checked::before { transform: translateX(1.1rem); }
/* Формы .stack: подпись над полем, кнопка после (образец login/register, ревью /me) */
/* Поиск в шапке M4.13: узкое поле + иконка-кнопка */
.search-box { display: inline-flex; align-items: center; gap: .3rem; }
.search-box input[type=search] { width: 9rem; padding: .35rem .6rem; }
.search-box button { min-height: 0; width: 2.2rem; height: 2.2rem; padding: 0;
                     display: inline-flex; align-items: center; justify-content: center; }
.search-form { display: flex; gap: .5rem; margin: .8rem 0 1rem; }
.search-form input[type=search] { flex: 1; max-width: 28rem; }
/* Кнопка «Написать пост» M4.13: акцентная, правее чипа ЛК */
.post-btn {
  background: var(--c-accent); color: var(--c-on-accent); border-radius: 8px;
  padding: .4rem 1rem; white-space: nowrap; font-weight: 700;   /* M4.15: заметно акцентнее */
}
.post-btn:hover { color: var(--c-on-accent); filter: brightness(1.08); }
.stack label { display: block; margin: .5rem 0 .2rem; font-size: .92rem; }
.stack label input, .stack label textarea {
  display: block; width: 100%; max-width: 28rem; box-sizing: border-box; margin-top: .2rem;
}
.stack textarea { min-height: 5.5rem; }
.stack > button { display: block; margin-top: .8rem; }
.pager { margin: 1rem 0; }
.invite { font-style: italic; color: var(--c-dim); }
nav a, .topnav { margin-right: 1rem; }
.flash { background: var(--c-flash); border-radius: 8px; padding: 0.5rem 1rem; }
/* News-grid M4.15: новости 2 колонки, первые с превью — широкие на весь ряд; секции main — card-grid */
.news-grid, .card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.news-grid .feed-item, .card-grid .feed-item { margin: 0; }
.card-grid .feed-item, .news-grid .news-card { display: block; }   /* без рельсы: превью/заголовок/аннотация стопкой */
.news-grid h2 { margin: 0; }   /* заголовок секции внутри grid-контейнера */
.news-grid h2, .news-grid .side-note, .card-grid .sec-head { grid-column: 1 / -1; }
.news-grid .news-lead, .card-grid .news-lead { grid-column: 1 / -1; }
.news-pic { width: 100%; height: 9rem; object-fit: cover; border-radius: 8px; margin: 0 0 .5rem; display: block; }
.news-lead .news-pic { height: 16rem; }
@media (max-width: 899px) { .news-grid, .card-grid { grid-template-columns: 1fr; } }
.branch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 720px) { .branch-grid { grid-template-columns: 1fr; } }
/* Фото дня M4.6: картинка-заглушка в сайдбаре */
.photo-day { width: 100%; border-radius: 8px; display: block; }
/* Форма поста M4.7: заголовок+текст над лентой, карточка-заголовок */
.new-post { background: var(--c-card); border: 1px solid var(--c-border); border-radius: 10px; padding: .8rem 1rem; margin: 1rem 0; }
.new-post input[type=text] { width: 100%; box-sizing: border-box; margin-bottom: .5rem; font-size: 1.05rem; }
.new-post .EasyMDEContainer, .new-post textarea { margin-top: .35rem; }  /* зазор заголовок↔поле (EasyMDE обёртка обнуляет) */
.feed-title { margin: 0 0 .4rem; }
.sort-nav { margin: .2rem 0 .6rem; }
/* Композер M4.12 (по образцу Пикабу): дропзона картинок, предпросмотр */
.dropzone {
  border: 2px dashed var(--c-border); border-radius: 8px;
  padding: .55rem; text-align: center; color: var(--c-muted);
  font-size: .85rem; margin: .5rem 0; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone.over, .dropzone.busy { border-color: var(--c-accent); background: var(--c-soft); }
.preview { background: var(--c-card); border: 1px solid var(--c-border); border-radius: 10px; padding: .8rem 1rem; margin: .6rem 0; }
/* M4.16d: ряд частых эмодзи в композере (28px кнопки, тап ≥40px) */
.emoji-row { display: flex; flex-wrap: wrap; gap: 2px; margin: .3rem 0; }
.emoji-row button {
  position: relative; width: 28px; height: 28px; padding: 0; border: 0;
  background: none; font-size: 1.05rem; line-height: 28px; cursor: pointer; border-radius: 6px;
}
.emoji-row button::after { content: ""; position: absolute; inset: -6px; }   /* тап-зона ≥40px */
.emoji-row button:hover { background: color-mix(in srgb, var(--c-accent) 10%, transparent); }
.composer-actions { display: flex; gap: .6rem; }
.composer-actions button { flex: 1; }

/* M4.16: графика по темам — divider через var, иконки light/dark парами */
:root { --img-divider: url("img/divider-strip.png"); }
html[data-theme="dark"] { --img-divider: url("img/divider-strip-dark.png"); }
/* divider: пиксельная полоска без картинки (ревизия владельца, var --img-divider больше не юзается)*/
.only-dark { display: none; }
html[data-theme="dark"] .only-dark { display: inline-block; }
html[data-theme="dark"] .only-light { display: none; }

/* M4.16: пользовательские ветки — карточки на /t, счётчик чипа */
.branch-card .sec-ic { vertical-align: -4px; margin-right: 3px; }
.topic-count { color: var(--c-muted); font-variant-numeric: tabular-nums; }
.branch-card { display: block; border: 1px solid var(--c-border); border-radius: 10px; padding: .8rem 1rem; }

/* M4.20: виза мод-очереди — кнопки в один ряд (перенос только на узких 390px) */
.queue-item form.mod, .queue-actions form.mod { display: flex; flex-wrap: nowrap; gap: .5rem; margin: .5rem 0 .2rem; }
.queue-item form.mod button, .queue-actions form.mod button { flex: 0 1 auto; padding: .35rem .8rem; font-size: .85rem; min-height: 0; }
@media (max-width: 390px) { .queue-item form.mod, .queue-actions form.mod { flex-wrap: wrap; } }

/* M4.21: карточка статьи в очереди — титул → обложка → текст (clamp) → мета справа → полоса кнопок */
.queue-card { display: flex; flex-direction: column; gap: .4rem; border: 1px solid var(--c-border); border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; }   /* M4.22: зазор между соседними карточками очереди */
.queue-card .queue-title { margin: 0; font-size: 1.15rem; }
.queue-card .queue-title a { text-decoration: none; }
.queue-card .queue-cover { margin: 0; }
.queue-excerpt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.queue-card .queue-meta { margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; align-items: baseline; font-size: .85rem; color: var(--c-muted); }
.queue-card .queue-meta a { text-decoration: none; }.queue-actions { border-top: 1px solid var(--c-border); margin-top: .3rem; padding-top: .5rem; }
.queue-actions form.mod { margin: 0; }

/* M4.20: обложка статьи — на странице и маленькая в превью мод-очереди; M4.23: каркас — 16/9 место резервировано до загрузки (без layout-shift) */
.anchor-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--c-soft); border-radius: 10px; border: 1px solid var(--c-border); }
.queue-cover { width: 100%; aspect-ratio: 16 / 9; max-height: 10rem; object-fit: cover; background: var(--c-soft); border-radius: 8px; border: 1px solid var(--c-border); margin: .4rem 0; }

/* M4.21 Task 3: ЛК — сетка разделов-карточек (2 колонки, 1 на 720px и ниже) */
.me-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; align-items: start; }
.me-section { border: 1px solid var(--c-border); border-radius: 10px; padding: .8rem 1rem; }
@media (max-width: 720px) { .me-grid { grid-template-columns: 1fr; } }

/* M4.21 Task 1: поле обложки виз-формы — url + кнопка файла, мини-превью */
.cover-row { display: flex; gap: .4rem; }
.cover-row .cover-url { flex: 1; min-width: 0; }
.cover-row .cover-btn { flex: 0 0 auto; padding: .35rem .6rem; min-height: 0; }
.cover-preview { width: 100%; max-height: 6rem; object-fit: cover; border-radius: 8px; border: 1px solid var(--c-border); margin: .2rem 0; }

/* M4.20: md-панель редакторов + модалка предпросмотра (вар(--c-*) как тулбар) */
.md-toolbar { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0; }
.md-toolbar button { padding: .3rem .6rem; min-height: 0; }
.md-toolbar .icon { width: 18px; height: 18px; vertical-align: middle; }
.md-toolbar .md-preview-btn { margin-left: auto; }
.md-preview-modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; }
.md-preview-modal .md-preview-body { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(40rem, 92vw); max-height: 80vh; overflow: auto; }
.md-preview-modal .md-preview-close { position: absolute; top: .8rem; right: 1rem; padding: .3rem .7rem; }

/* M4.22: пост-страница с окружением — крумб раздела и соседи ветки */
.crumb { color: var(--c-muted); font-size: .85rem; margin: 0 0 .4rem; }
.crumb a { color: var(--c-link); }

/* M4.23: плавные переходы — hover-интерактив и смена темы; только неломающие свойства (layout не анимируем) */
body, header, footer,
button, .btn, .pill, .post-btn, .dropzone, .switch input,
.feed-item, .side-block, .queue-card, .u-card, .branch-card, .new-post,
header nav a, .menu a, .author, .crumb a, .meta a, .reply-box > summary,
.reactions-stack, .v-pill button, .reactions button, .gallery img {
  transition: color .15s ease, background-color .15s ease, border-color .15s ease,
              opacity .15s ease, transform .15s ease, box-shadow .15s ease;
}
/* M4.23: движение — не принуждаем: reduced-motion отрубает все переходы */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Плавающая мета-плашка на /p (M4.26-хвост): липнет ПОД шапкой с зазором — линия шапки не прилипает вплотную */
.post-top {
  position: sticky; top: 4.2rem; z-index: 9;
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: 10px;
  padding: .45rem .7rem; box-shadow: 0 2px 10px var(--c-shadow);
  margin-bottom: 1rem;
}
@media (max-width: 899px) { .post-top { top: 5.4rem; } }   /* шапка на мобиле в два ряда — выше зазор */

/* Карточки обсуждения на главной (M4.27-хвост): компактная строка без фейковых превью */
.thread-card { display: block; }
.thread-card .meta { font-size: .78rem; color: var(--c-muted); margin: 0 0 .15rem; display: flex; align-items: center; gap: .35rem; white-space: nowrap; overflow: hidden; }
.thread-card .meta .avatar { width: 20px; height: 20px; font-size: .7rem; flex: 0 0 auto; }
.thread-card h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.thread-card .thread-foot { margin: .3rem 0 0; font-size: .85rem; }
.thread-card .thread-foot a { color: var(--c-accent); }

/* EasyMDE (M4.28-хвост): тёмная тема редактора через переменные сайта; светлая — родная */
html[data-theme="dark"] .CodeMirror { background: var(--c-card); color: var(--c-text); caret-color: var(--c-text); }
html[data-theme="dark"] .cm-s-easymde .cm-s-1, html[data-theme="dark"] .cm-s-easymde { color: var(--c-text); }
html[data-theme="dark"] .CodeMirror-cursor { border-left-color: var(--c-text); }
html[data-theme="dark"] .editor-preview, html[data-theme="dark"] .editor-preview-side { background: var(--c-bg); color: var(--c-text); }
html[data-theme="dark"] .editor-toolbar { border-color: var(--c-border); background: var(--c-card); }
html[data-theme="dark"] .editor-toolbar > *, html[data-theme="dark"] .editor-statusbar { color: var(--c-muted); }
html[data-theme="dark"] .editor-toolbar .active, html[data-theme="dark"] .editor-toolbar > :hover {
  background: var(--c-card); color: var(--c-text); border-color: var(--c-accent); }
html[data-theme="dark"] .editor-toolbar i.separator { background: var(--c-border); }
html[data-theme="dark"] .easymde-dropdown-content, html[data-theme="dark"] .CodeMirror-gutters { background: var(--c-card); border-color: var(--c-border); }

/* Раздача роли модератора (M4.28-хвост): тихий контрол в карточке, не боевая кнопка */
.u-card .umoder button { font-size: .75rem; padding: .2rem .55rem; font-weight: 400; background: transparent;
  border: 1px solid var(--c-muted); color: var(--c-muted); border-radius: 999px; cursor: pointer; }
.u-card .umoder button:hover { color: var(--c-accent); border-color: var(--c-accent); }

/* «Править» — в шапке статьи справа, тихий чип (виден только модераторам) */
.post-head .edit-top { margin-left: auto; font-size: .8rem; color: var(--c-muted); text-decoration: none;
  border: 1px solid var(--c-muted); padding: .15rem .55rem; border-radius: 999px; flex: none; }
.post-head .edit-top:hover { color: var(--c-accent); border-color: var(--c-accent); }
.post-head .del-top { margin-left: .35rem; }                /* M5-G: удалить по соседству с правкой */
.post-head .del-top, .post-head .del-top button { background: none; border: 0; padding: 1px 2px;
  cursor: pointer; color: var(--c-muted); }
.post-head .del-top:hover button { color: #d04040; }

/* Рубрика статьи (M4.28-хвост): видно откуда материал, тёплый тон истории */
.rubric { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; color: var(--c-muted);
  border: 1px solid var(--c-muted); border-radius: 999px; padding: .12rem .55rem; text-decoration: none; flex: none; }
.rubric:hover { color: var(--c-accent); border-color: var(--c-accent); }
.rubric-history { color: #c09a4e; border-color: color-mix(in srgb, #c09a4e 55%, transparent); }
.rubric-story { color: var(--c-accent); border-color: color-mix(in srgb, var(--c-accent) 45%, transparent); }

/* Тон страницы статьи по разделу (M4.28-хвост): мягкая заливка сверху, обе темы */
body.art-history { background-image: linear-gradient(180deg, rgba(192,154,78,.10), rgba(192,154,78,0) 360px); background-repeat: no-repeat; }
body.art-story { background-image: linear-gradient(180deg, color-mix(in srgb, var(--c-accent) 9%, transparent), transparent 360px); background-repeat: no-repeat; }
body.art-faq, body.art-place { background-image: linear-gradient(180deg, color-mix(in srgb, var(--c-text) 4%, transparent), transparent 320px); background-repeat: no-repeat; }

/* Тонус категорий (M4.28-хвост): витрина раздела красится тем же цветом, что её статьи —
   переход «категория → статья» один цвет нигде не меняет */
body.portal.news { background-image: linear-gradient(180deg, color-mix(in srgb, var(--c-accent) 9%, transparent), transparent 360px); background-repeat: no-repeat; }
body.portal.branch-istoriya { background-image: linear-gradient(180deg, rgba(192,154,78,.10), rgba(192,154,78,0) 360px); background-repeat: no-repeat; }
body.portal.branch-gorod { background-image: linear-gradient(180deg, rgba(96,148,66,.09), rgba(96,148,66,0) 360px); background-repeat: no-repeat; }
body.portal.branch-turizm { background-image: linear-gradient(180deg, rgba(46,138,168,.10), rgba(46,138,168,0) 360px); background-repeat: no-repeat; }
body.art-faq { background-image: linear-gradient(180deg, rgba(96,148,66,.09), transparent 360px); background-repeat: no-repeat; }
body.art-place { background-image: linear-gradient(180deg, rgba(46,138,168,.10), transparent 360px); background-repeat: no-repeat; }
.rubric-gorod { color: #6c9c48; border-color: color-mix(in srgb, #6c9c48 55%, transparent); }
.rubric-turizm { color: #3e9ab8; border-color: color-mix(in srgb, #3e9ab8 55%, transparent); }
body.art-faq, body.art-place { background-repeat: no-repeat; }

/* Текстовые иконки тулбара EasyMDE: без Font Awesome/CDN, оффлайн-безопасно */
.editor-toolbar a { font-size: .95rem; }
/* Ховер тулбара (ревизия владельца): сплошная акцентная плашка, контрастный глиф.
   Селектор на button — EasyMDE 2.20 рендерит тулбар кнопками, не ссылками */
.editor-toolbar button:hover, .editor-toolbar button.active,
.editor-toolbar a:hover, .editor-toolbar a.active { background: var(--c-accent) !important;
  border-color: var(--c-accent) !important; color: var(--c-on-accent) !important; }

/* M5-E: AJAX-вставка комментария — вспышка узла и плашка ответа в reply-box */
.flash-new { animation: flash-new 1.5s ease-out; }
@keyframes flash-new { from { background: var(--c-soft); } to { background: transparent; } }
.reply-plaque { font-size: .85rem; color: var(--c-accent); margin: .3rem 0 0; }
