/* Экран «Тема»: DiscussionHero, лента постов (CommentPost), реакции, опрос, ответ — поверх фундамента style.css
   По мотивам Flarum 2 (MIT, Stichting Flarum / Toby Zerner): DiscussionPage.less, Post.less,
   Scrubber.less, UserCard.less, Composer.less, TextEditor.less, likes/mentions forum.less. */

/* ============================ DiscussionHero ============================== */
.th-hero__badges { margin-right: 8px; vertical-align: 3px; }
.th-hero__badges .ibadge { --size: 20px; }
/* TagLabel в DiscussionHero: приглушённая подложка цвета раздела, текст — обычный */
.th-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--border-radius);
  background: color-mix(in srgb, var(--tag-c, var(--control-bg-light)) 22%, var(--body-bg));
  color: var(--text-color);
  font-size: var(--font-size);
  font-weight: 600;
  line-height: 20px;
  text-decoration: none;
  transition: color var(--transition);
}
.th-tag .ic { width: 14px; height: 14px; color: currentColor; }
.th-tag:hover { color: var(--link-color); }
.th-hero .hero__label .chip { font-size: var(--font-size-sm); padding: 2px 8px; line-height: 20px; }
/* Префикс в hero вторичен: без заливки, цвет — только точкой */
.th-hero .hero__label .chip--prefix { --tag-bg: transparent; --tag-color: var(--muted-color-light); padding-inline: 4px; }
.th-hero .chip--prefix::before { content: ""; width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--c, var(--muted-color)); }

/* ============================ DiscussionPage ============================== */
.th-page {
  --aside-width: 190px;
  --avatar-column-width: 85px;
  --post-padding: 20px;
}
.th-stream { font-size: var(--font-size); }
.th-stream > .pag { margin: 0 0 10px; }
/* Первый пост начинается на одной линии с кнопкой «Ответить» справа */
.th-posts > .th-post:first-child { padding-top: 0; }
.th-posts + .pag { margin: 10px 0 0; }

@media (min-width: 768px) {
  .page.th-page {
    grid-template-columns: minmax(0, 1fr) var(--aside-width);
    grid-template-areas: "content aside";
    column-gap: 40px;
  }
  .th-page > .page__aside { margin-top: 0; }
}
@media (min-width: 1100px) {
  /* Ширина колонки и зазор — общие для всех .page (фундамент): 210px и 40px */
  .th-page { --aside-width: var(--sidebar-width); }
  .page.th-page { column-gap: var(--page-gap); }
  .th-stream { max-width: calc(var(--discussion-content-max-width) + var(--avatar-column-width)); }
}

/* ============================== CommentPost =============================== */
.th-post {
  position: relative;
  display: grid;
  grid-template-columns: var(--avatar-column-width) minmax(0, 1fr);
  min-height: 104px;
  padding: var(--post-padding) var(--post-padding) 10px 0;
}
/* Лента без линий между постами — как PostStream у Flarum: посты разделяет только воздух */
.th-post__side { position: relative; align-self: start; width: 64px; min-width: 0; }
.th-post__av { display: block; border-radius: 50%; line-height: 0; }
.th-post__av .av { width: 64px; height: 64px; }
/* Значок группы на углу аватара (Flarum PostUser-badges): только нижняя правая четверть */
.th-post__badges { position: absolute; top: 42px; right: -8px; display: flex; flex-direction: column; gap: 3px; line-height: 0; }
.th-post__badges .badge--icon { width: 24px; height: 24px; box-shadow: 0 0 0 2px var(--body-bg); }
.th-post__badges .badge--icon .ic { width: 13px; height: 13px; }
.th-post__main { min-width: 0; }

/* Post-header */
.th-post__hd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-bottom: 12px;
  min-height: 24px;
  color: var(--muted-color);
  font-size: var(--font-size);
  line-height: 20px;
}
.th-post__who { position: relative; display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
/* Flarum UserOnline: зелёная точка после имени, а не на аватаре */
.th-post__online { display: inline-block; flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--online-user-circle-color); }
.th-post__name {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--font-size);
  font-weight: 700;
  line-height: 20px;
  cursor: pointer;
  overflow-wrap: anywhere;
  text-align: left;
}
.th-post__name:hover { text-decoration: underline; }
.th-post__hd a { color: var(--muted-color); }
.th-post__hd a:hover { color: var(--link-color); }
.th-post__time { white-space: nowrap; }
.th-post__time:hover { text-decoration: underline; }
.th-post__op { font-size: var(--font-size-sm); color: var(--muted-color); }
.th-post__edited { font-size: var(--font-size-sm); color: var(--muted-more-color); cursor: default; }
.th-post__reply-to { display: inline-flex; align-items: center; gap: 3px; font-size: var(--font-size-sm); }
.th-post__reply-to .ic { width: 12px; height: 12px; }
.th-post__hd a.th-post__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  margin-left: auto;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted-more-color);
  font-variant-numeric: tabular-nums;
}
.th-post__hd a.th-post__num:hover { color: var(--link-color); }

/* Ярлыки поста (best answer, скрыто) */
.th-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: var(--border-radius);
  background: var(--control-bg);
  color: var(--muted-color-light);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}
.th-label .ic { width: 12px; height: 12px; }
.th-label--solved,
.th-label--solved .ic { color: var(--online-user-circle-color); }   /* #7fba00: ≈7.6 : 1 на control-bg */
.th-label--deleted { background: var(--control-danger-bg); color: var(--control-danger-color); }

/* Post-body */
.th-post__body {
  max-width: var(--discussion-content-max-width);
  font-size: var(--font-size-post);
  line-height: var(--line-height-post);
  color: var(--text-color);
}
.th-post__reason { margin: 8px 0 0; font-size: var(--font-size-sm); color: var(--muted-more-color); }

/* Скрытое сообщение (Post--hidden) — для модераторов */
.post--deleted .th-post__name,
.post--deleted .th-post__hd { color: var(--muted-more-color) !important; }
.post--deleted .th-post__body,
.post--deleted .th-post__body strong,
.post--deleted .th-post__sig { color: var(--muted-more-color); }  /* без opacity: контраст ≥ 4.5 */
.post--deleted .th-post__likes,
.post--deleted .th-post__side { opacity: .5; }

/* Подпись — как у NodeBB Harmony: мелкий приглушённый текст под тонкой линией */
.th-post__sig {
  margin-top: 15px;
  padding-top: 8px;
  border-top: 1px solid var(--control-bg);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--muted-color);
  max-height: 120px;
  overflow: hidden;
}
.th-post__sig .bb-img { max-height: 60px; }

/* Post-footer + Post-actions */
.th-post__ft {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 10px;
  min-height: 28px;
}
.th-post__ft:not(:has(.th-post__acts)):not(:has(.react)) { display: none; }
/* Flarum Likes: одна строка «🧠🔥 AlexShadow и ещё 2 оценили» — эмодзи-кнопки без плашек и счётчиков
   (число — в title/aria-label и в самой фразе), без сердечка перед фразой */
.th-post__likes { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.th-post__likedby {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--muted-color);
}
.th-post__likedby a { color: var(--muted-color); font-weight: 600; }
.th-post__likedby a:hover { color: var(--link-color); text-decoration: underline; }

.th-post__acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin: 0 -8px 0 auto;
  padding: 0;
  list-style: none;
}
.th-post__acts > li { position: relative; }
.th-act.btn {
  min-height: 28px;
  padding: 4px 8px;
  gap: 5px;
  color: var(--muted-more-color);
  font-size: 13px;
}
.th-act.btn .ic { width: 14px; height: 14px; }
.th-act.btn--icon { width: 28px; padding: 4px 0; }
.th-post:hover .th-act.btn,
.th-post:focus-within .th-act.btn { color: var(--muted-color); }
/* Flarum: действия поста появляются при наведении/фокусе. Остаются в DOM и доступны с клавиатуры;
   видны, пока открыто меню или выбор реакции. На тач-экранах — всегда видны. */
@media (hover: hover) and (pointer: fine) and (min-width: 768px) {
  /* Ровный ритм ленты: у поста без реакций строка действий не занимает места в потоке —
     она лежит в нижнем отступе поста. Отступ одинаков у всех постов, поэтому расстояние
     от последней видимой строки (текст или реакции) до следующего поста всегда одно. */
  .th-post { padding-bottom: 30px; }
  .th-post__ft:not(:has(.react)) {
    position: absolute;
    right: var(--post-padding);
    bottom: 1px;
    left: var(--avatar-column-width);
    margin: 0;
    pointer-events: none;
  }
  .th-post__ft:not(:has(.react)) .th-post__acts { pointer-events: auto; }
  .th-post__acts { opacity: 0; transition: opacity var(--transition); }
  .th-post:hover .th-post__acts,
  .th-post:focus-within .th-post__acts,
  .th-post:has(.react-pop.open) .th-post__acts,
  .th-post:has(.th-post__acts [aria-expanded="true"]) .th-post__acts { opacity: 1; }
}
.th-post .th-act.btn:hover,
.th-post .th-act.btn:focus-visible,
.th-post .th-act.btn[aria-expanded="true"] { color: var(--link-color); }
.th-post__menu .drop { min-width: 210px; }

/* Реакции: компактные кнопки (Flarum Likes / fof-reactions) */
.reacts { display: flex; flex-wrap: wrap; align-items: center; gap: 0; }
.reacts:not(:has(.react)) { display: none; }
.th-post__likes:not(:has(.react)) { display: none; }
.react {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  min-height: 24px;
  padding: 0 2px;
  border: 0;
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--control-color);
  font: inherit;
  font-size: 0;            /* счётчик (текстовый узел) скрыт визуально, но читается скринридером */
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--transition);
}
.react em { font-style: normal; font-size: 15px; line-height: 1; }
.react:hover:not([disabled]) { background: var(--control-bg); }
.react.on { background: color-mix(in srgb, var(--primary-color) 14%, var(--body-bg)); }
.react.on:hover { background: color-mix(in srgb, var(--primary-color) 20%, var(--body-bg)); }
.react[disabled] { cursor: default; }

.react-add { position: relative; }
.react-pop {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  z-index: var(--zindex-dropdown);
  display: none;
  gap: 2px;
  padding: 4px;
  border-radius: var(--border-radius);
  background: var(--body-bg);
  box-shadow: 0 2px 6px var(--shadow-color);
  white-space: nowrap;
}
.react-pop.open { display: flex; }
.react-pop button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--border-radius);
  background: none;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.react-pop button:hover,
.react-pop button:focus-visible { background: var(--control-bg); }

/* ================================ Опрос =================================== */
.th-poll {
  max-width: var(--discussion-content-max-width);
  margin: 15px 0 0;
  padding: 15px 20px;
  border-radius: var(--border-radius);
  background: var(--control-bg);
  color: var(--control-color);
}
.th-stream__top .th-poll,
.th-stream__top .th-solution { margin: 10px 0 5px; }
.th-poll__q {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--heading-color);
}
.th-poll__q .ic { color: var(--muted-color); }
.th-poll__results { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.th-poll__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.th-poll__text { display: inline-flex; align-items: center; gap: 5px; color: var(--text-color); min-width: 0; }
.th-poll__text .ic { color: var(--link-color); }
.th-poll__num { font-size: var(--font-size-sm); font-weight: 700; color: var(--text-color); white-space: nowrap; font-variant-numeric: tabular-nums; }
.th-poll__bar { height: 6px; overflow: hidden; border-radius: 3px; background: var(--body-bg); }
.th-poll__bar > span { display: block; height: 100%; border-radius: 3px; background: var(--muted-more-color); }
.th-poll__opt.is-mine .th-poll__bar > span { background: var(--primary-color); }
.th-poll__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 12px;
  margin: 12px 0 0;
  font-size: var(--font-size-sm);
  color: var(--muted-color);
}
.th-poll__choices { margin: 0; padding: 0; border: 0; display: grid; gap: 2px; }
.th-poll__choices .check { color: var(--text-color); }

/* ========================= Решение (best answer) ========================== */
.th-solution {
  max-width: var(--discussion-content-max-width);
  margin: 15px 0 0;
  padding: 10px 15px;
  border-radius: var(--border-radius);
  background: var(--control-bg);
  color: var(--control-color);
  font-size: var(--font-size);
}
.th-solution__hd { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px; }
.th-solution__hd b { color: var(--text-color); }
.th-solution .th-label { background: var(--body-bg); }
.th-solution__go { margin-left: auto; color: var(--link-color); font-weight: 600; }
.th-solution__go:hover { text-decoration: underline; }

/* ===================== Карточка автора (UserCard--popover) ================ */
.th-card.hovercard {
  --usercard-bg: color-mix(in srgb, var(--card-c, var(--secondary-color)) 14%, var(--control-bg));
  --muted-color: var(--muted-color-light);
  width: 420px;
  padding: 20px;
  color: var(--text-color);
  font-weight: 400;
}
.th-card__profile { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 18px; }
.th-card__av .av { width: 72px; height: 72px; box-shadow: 0 0 0 3px var(--body-bg); }
.th-card__identity { margin: 0; font-size: 20px; font-weight: 400; line-height: 1.3; overflow-wrap: anywhere; }
.th-card__identity a { color: var(--heading-color); }
.th-card__identity a:hover { text-decoration: underline; }
.th-card__badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.th-card__title { margin: 6px 0 0; font-size: var(--font-size-sm); color: var(--muted-color); }
.th-card__info {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--font-size-sm);
  color: var(--muted-color);
}
.th-card__info li { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.th-card__info .ic { width: 14px; height: 14px; }
.th-card__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--online-user-circle-color); }
.th-card__medals { margin-top: 12px; }
.th-card__open.btn { margin-top: 15px; width: 100%; --button-bg: var(--body-bg); --button-color: var(--text-color); }

/* ============================ Composer (ответ) ============================ */
.th-reply-anchor { scroll-margin-top: calc(var(--header-height) + 20px); }
.th-composer {
  display: grid;
  grid-template-columns: var(--avatar-column-width) minmax(0, 1fr);
  margin-top: 30px;
  padding-right: var(--post-padding);
}
.th-composer__av .av { width: 64px; height: 64px; }
.th-composer__body { min-width: 0; }
.th-composer__hd {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  min-width: 0;
  font-size: var(--font-size);
  font-weight: 400;
  line-height: 24px;
  color: var(--control-color);
}
.th-composer__hd > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-composer__topic { color: var(--text-color); }

.th-placeholder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin: 30px var(--post-padding) 0 var(--avatar-column-width);
  padding: 15px 20px;
  border-radius: var(--border-radius);
  background: var(--control-bg);
  color: var(--control-color);
}
.th-placeholder p { margin: 0; }
.th-placeholder b { color: var(--text-color); }
.th-placeholder .actions { margin-left: auto; }
.th-placeholder a { color: var(--link-color); font-weight: 600; }
.th-placeholder a:hover { text-decoration: underline; }

/* ============================ TextEditor ================================== */
/* partials/editor: поле → строка управления (отправка, панель, предпросмотр) → подвал */
.editor {
  position: relative;
  border-radius: var(--border-radius);
  background: var(--control-bg);
}
.editor:focus-within { outline: 2px solid var(--primary-color); outline-offset: -2px; }
.editor textarea {
  display: block;
  width: 100%;
  min-height: 190px;
  padding: 15px 20px 10px;
  border: 0;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  background: transparent;
  color: var(--text-color);
  font-size: var(--font-size-post);
  line-height: var(--line-height-post);
  resize: none;
}
.editor textarea:focus { outline: none; }
.editor textarea::placeholder { color: var(--control-color); opacity: 1; }

.editor .editor__bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 8px 10px 8px 20px;
  border-top: 1px solid var(--body-bg);
  border-bottom: 0;
}
.editor .editor__bar .btn { display: inline-flex; flex-shrink: 0; background: var(--button-bg); color: var(--button-color); }
.editor .editor__bar .btn:hover,
.editor .editor__bar .btn:focus-visible { background: var(--button-bg-hover); color: var(--button-color); }
.editor .editor__bar .btn:active { background: var(--button-bg-active); }
/* «Отмена» — текстовая кнопка сразу за отправкой (Flarum: Button--link) */
.editor .editor__bar .editor__cancel.btn { min-height: 36px; margin-left: -4px; padding: 8px; color: var(--muted-color); font-weight: 400; }
.editor .editor__bar .editor__cancel.btn:hover,
.editor .editor__bar .editor__cancel.btn:focus-visible { color: var(--link-color); }
/* Панель никогда не прокручивается вбок: в узком контейнере переносится на новые строки */
.editor__tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.editor__group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0; }
.editor__group + .editor__group { margin-left: 3px; padding-left: 3px; border-left: 1px solid var(--body-bg); }
.editor .editor__bar button.editor__tool {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  width: 28px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--control-color);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.editor .editor__bar button.editor__tool:hover,
.editor .editor__bar button.editor__tool:focus-visible { background: transparent; color: var(--link-color); }
.editor .editor__bar button.editor__tool[aria-expanded="true"] { color: var(--link-color); }
.editor__tool .ic { width: 16px; height: 16px; }
.editor__glyph { font-family: var(--font-family); font-size: 15px; line-height: 1; }
.editor__glyph--b { font-weight: 800; }
.editor__glyph--i { font-style: italic; font-weight: 600; font-family: Georgia, "Times New Roman", serif; font-size: 16px; }
.editor__glyph--u { text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.editor__glyph--s { text-decoration: line-through; font-weight: 600; }
.editor__glyph--color { font-weight: 700; padding-bottom: 1px; box-shadow: inset 0 -2px 0 currentColor; }

.editor .editor__bar .editor__pv.btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-height: 36px;
  margin-left: auto;
  padding: 0;
  color: var(--control-color);
}
.editor .editor__bar .editor__pv.btn:hover,
.editor .editor__bar .editor__pv.on { color: var(--link-color); }
.editor .editor__bar .editor__submit.btn { width: auto; height: auto; min-height: 36px; padding: 8px 16px; font-size: var(--font-size); font-weight: 700; }

/* Узкий редактор (колонка диалога ЛС, телефон, планшет): отправка, «Отмена» и предпросмотр —
   первой строкой, панель BBCode — ниже во всю ширину и переносится по одной кнопке.
   У каждой кнопки слева 4px «щель»; у первой кнопки группы в щели нарисован разделитель.
   Панель сдвинута влево на ширину щели и срезана clip-path — поэтому строки выровнены
   по левому краю и ни одна не начинается с черты. Без горизонтальной прокрутки. */
.editor { container: editor / inline-size; }
/* ≥992px (мышь): у любого композера — ответ, новая тема, правка, ЛС — одна строка
   [отправка][Отмена] панель … [предпросмотр]. Панель сжимается и переносится только внутри себя. */
@media (min-width: 992px) and (pointer: fine) {
  .editor .editor__bar { flex-wrap: nowrap; }
  .editor__tools { flex: 1 1 auto; row-gap: 2px; }
}
@media (max-width: 991.98px) {
@container editor (max-width: 799.98px) {
  .editor .editor__bar { padding-left: 10px; }
  .editor__tools { flex: 1 1 0; margin-left: -4px; clip-path: inset(-8px -8px -8px 4px); }
  .editor--submit .editor__tools { order: 3; flex: 1 0 calc(100% + 4px); }
  .editor--submit .editor__pv { order: 2; }
  .editor__group { display: contents; }
  .editor .editor__bar button.editor__tool { margin-left: 4px; }
  .editor .editor__bar button.editor__tool:focus-visible { outline-offset: -2px; }
  .editor__group + .editor__group > .editor__tool:first-child::before {
    content: "";
    position: absolute;
    top: 25%;
    bottom: 25%;
    left: -3px;
    width: 1px;
    background: var(--body-bg);
  }
}
@container editor (max-width: 899.98px) {
  .editor--cancel .editor__bar { padding-left: 10px; }
  .editor--cancel .editor__tools { order: 3; flex: 1 0 calc(100% + 4px); margin-left: -4px; clip-path: inset(-8px -8px -8px 4px); }
  .editor--cancel .editor__pv { order: 2; }
  .editor--cancel .editor__group { display: contents; }
  .editor--cancel .editor__bar button.editor__tool { margin-left: 4px; }
  .editor--cancel .editor__bar button.editor__tool:focus-visible { outline-offset: -2px; }
  .editor--cancel .editor__group + .editor__group > .editor__tool:first-child::before {
    content: "";
    position: absolute;
    top: 25%;
    bottom: 25%;
    left: -3px;
    width: 1px;
    background: var(--body-bg);
  }
}
}
@media (pointer: coarse) {
  /* Кнопки панели 44px на любом телефоне и планшете — одной строкой они не помещаются никогда */
  @container editor (min-width: 0px) {
    .editor .editor__bar { padding-left: 10px; }
    .editor__tools { flex: 1 1 0; margin-left: -4px; clip-path: inset(-8px -8px -8px 4px); }
    .editor--submit .editor__tools { order: 3; flex: 1 0 calc(100% + 4px); }
    .editor--submit .editor__pv { order: 2; }
    .editor__group { display: contents; }
    .editor .editor__bar button.editor__tool { margin-left: 4px; }
    .editor__group + .editor__group > .editor__tool:first-child::before {
      content: ""; position: absolute; top: 25%; bottom: 25%; left: -3px; width: 1px; background: var(--body-bg);
    }
  }
}

.editor .editor__ft {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 8px 20px;
  border-top: 1px solid var(--body-bg);
  font-size: var(--font-size-sm);
  color: var(--muted-color);
}
.editor__ft b { color: var(--text-color); font-weight: 600; }
.editor__ft a { color: var(--muted-color); text-decoration: underline; text-underline-offset: 2px; }
.editor__ft a:hover { color: var(--link-color); }
.editor__hint kbd {
  display: inline-block;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--body-bg);
  color: var(--muted-color-light);
  font-family: var(--font-family);
  font-size: 11px;
  line-height: 16px;
}
.editor .editor__preview { display: none; max-height: 480px; overflow-y: auto; padding: 15px 20px; border-top: 1px solid var(--body-bg); background: var(--body-bg); }
.editor .editor__preview.on { display: block; }
.editor__preview .bb { font-size: var(--font-size-post); line-height: var(--line-height-post); }
.editor .emoji-pop { padding: 6px 15px; border-top: 1px solid var(--body-bg); }

/* ==================== BBCode в тексте сообщений (Post-body) ================ */
.bb { overflow-wrap: break-word; }
.bb p, .bb ul, .bb ol, .bb blockquote { margin: 0 0 1em; }
.bb strong { font-weight: 700; color: var(--heading-color); }
/* Цитата — Flarum blockquote */
.bb .bb-quote {
  margin: 1em 0;
  padding: 8px 15px;
  border-radius: var(--border-radius);
  background: var(--control-bg);
  color: var(--control-color);
  overflow: visible;
}
.bb .bb-quote-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  padding: 0 0 4px;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--muted-color);
}
.bb .bb-quote-head b {
  padding: 1px 5px;
  border-radius: var(--border-radius);
  background: var(--body-bg);
  color: var(--control-color);
  font-weight: 600;
}
.bb .bb-quote-head .q-jump { margin-left: auto; color: var(--muted-color); font-weight: 400; }
.bb .bb-quote-head .q-jump:hover { color: var(--link-color); text-decoration: underline; }
.bb .bb-quote-body { padding: 0; }
.bb .bb-quote-body > :last-child { margin-bottom: 0; }
.bb .bb-quote .bb-quote { background: var(--body-bg); }
.bb .bb-quote .bb-mention { background: var(--body-bg); }
/* Упоминание — Flarum UserMention */
.bb .bb-mention {
  display: inline;
  padding: 2px 5px;
  border-radius: var(--border-radius);
  background: var(--control-bg);
  color: var(--control-color);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.bb .bb-mention:hover { color: var(--link-color); }
/* Инлайн-код и блоки кода */
.bb code { padding: 1px 3px; border-radius: var(--border-radius); background: var(--code-bg); color: var(--code-color); font-family: var(--font-family-mono); font-size: 90%; line-height: 1.3; }
.bb .bb-code { margin: 1em 0; border-radius: var(--border-radius); background: var(--code-bg); }
.bb .bb-code-head { border-bottom: 1px solid var(--body-bg); color: var(--muted-color); font-size: var(--font-size-sm); }
.bb .bb-code pre { margin: 0; padding: 1em; overflow-x: auto; max-height: max(50vh, 250px); }
.bb .bb-code pre code { padding: 0; background: none; font-size: 13px; line-height: 1.6; }
/* Врезка и спойлер — поверхности тоном */
.bb .bb-banner { padding: 12px 18px; background: var(--control-bg); }
.bb .bb-banner__t { font-size: var(--font-size-md); }
.bb .bb-spoiler { background: var(--control-bg); }
.bb .bb-spoiler > summary { min-height: 36px; padding: 7px 15px; font-size: var(--font-size); }
.bb .bb-list { padding-left: 1.6em; margin-bottom: .25em; }
.bb .bb-list:last-child { margin-bottom: 0; }
.bb .bb-list li + li { margin-top: 2px; }
.bb .bb-list li::marker { color: var(--muted-color); }
.bb .bb-hr { border-top: 1px solid var(--control-bg-light); }
.bb .bb-kbd { padding: 1px 6px; border-radius: var(--border-radius); background: var(--control-bg-light); box-shadow: inset 0 -1px 0 var(--body-bg); color: var(--text-color); font-size: 88%; }
.bb .bb-img { border-radius: var(--border-radius); }
.bb .bb-table { font-size: var(--font-size); }
/* [glow] — просто цветной текст (цвет задаёт bbcode.js), [grad] — полужирный текст */
.bb .bb-grad { color: var(--heading-color); }
.bb .bb-server { background: var(--control-bg); }

/* ========================= Правая колонка (nav) =========================== */
.th-nav__list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.th-nav__primary .btn-group { display: flex; width: 100%; }
.th-nav__primary .btn-group > .btn:first-child { flex: 1; min-width: 0; }
.th-nav__primary .btn-group > .btn[aria-disabled="true"] { opacity: .65; cursor: not-allowed; }
.th-nav__caret.btn { flex-shrink: 0; width: 36px; padding-inline: 0; }
.th-nav__primary .drop { right: 0; min-width: 230px; }
.th-nav__follow.is-following { color: var(--text-color); }
.th-nav__follow.is-following .ic { color: var(--link-color); }

/* Scrubber: положение текущей страницы в теме */
.th-scrub { margin-top: 20px; }
.th-scrub__edge.btn {
  display: flex;
  justify-content: flex-start;
  min-height: 28px;
  padding: 4px 0;
  gap: 8px;
  color: var(--muted-color);
  font-size: 13px;
}
.th-scrub__edge .ic { width: 14px; height: 14px; }
.th-flip { transform: rotate(180deg); }
.th-scrub__track {
  position: relative;
  height: 180px;
  margin: 6px 0 6px 6px;
  border-left: 1px solid var(--control-bg-light);
}
.th-scrub__handle {
  position: absolute;
  left: -3px;
  right: 0;
  top: var(--top);
  height: var(--h);
  min-height: 24px;
}
.th-scrub__bar { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; border-radius: 4px; background: var(--primary-color); }
.th-scrub__info {
  position: absolute;
  top: 50%;
  left: 18px;
  right: 0;
  margin: 0;
  transform: translateY(-50%);
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted-color);
}
.th-scrub__info strong { display: block; color: var(--text-color); font-weight: 700; }
/* Вся тема на одной странице: листать нечего — короткая тихая линия */
.th-scrub--whole .th-scrub__track { height: 64px; }
.th-scrub--whole .th-scrub__bar { left: 1px; width: 3px; background: var(--control-bg-light); }
.th-scrub__info span::first-letter { text-transform: uppercase; }

/* Участники, сведения, похожие — тихие списки */
.th-side { margin-top: 30px; display: grid; gap: 25px; }
/* Заголовки блоков — как .panel-title фундамента: 15/600, иконка приглушённая */
.th-side__hd { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: var(--font-size-md); font-weight: 600; line-height: 1.4; color: var(--heading-color); }
.th-people { margin: 0; padding: 0; list-style: none; }
.th-people a {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 0;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.th-people a:hover .th-people__name { text-decoration: underline; }
.th-people__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-people__cnt { margin-left: auto; font-size: var(--font-size-sm); font-weight: 700; color: var(--muted-more-color); font-variant-numeric: tabular-nums; }
.th-info { display: grid; gap: 4px; margin: 0; font-size: 13px; }
.th-info > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.th-info dt { color: var(--muted-color); }
.th-info dd { margin: 0; min-width: 0; text-align: right; color: var(--text-color); white-space: nowrap; font-variant-numeric: tabular-nums; }
.th-info dd a { color: var(--text-color); font-weight: 600; }
.th-info dd a:hover { color: var(--link-color); text-decoration: underline; }
.th-similar { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; font-size: 13px; line-height: 1.4; }
.th-similar li { display: flex; align-items: baseline; gap: 8px; }
.th-similar a { min-width: 0; color: var(--discussion-title-color); }
.th-similar a:hover { color: var(--link-color); text-decoration: underline; }
.th-similar__cnt { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; font-size: var(--font-size-sm); color: var(--muted-more-color); white-space: nowrap; }
.th-similar__cnt .ic { width: 12px; height: 12px; }

/* ======================= Планшет и телефон ================================ */
@media (min-width: 768px) and (max-width: 991.98px) {
  .th-page { --avatar-column-width: 70px; }
  .th-post__side { width: 52px; }
  .th-post__av .av, .th-composer__av .av { width: 52px; height: 52px; }
  .th-post__badges { top: 30px; }
}

@media (max-width: 767.98px) {
  /* Flarum на телефоне: действия темы — строкой над лентой, колонка — под лентой */
  .page.th-page { grid-template-areas: "nav" "content" "side"; }
  .th-page > .th-aside { display: contents; }
  .th-nav { grid-area: nav; margin: 0 calc(-1 * var(--container-padding)) 5px; padding: 12px var(--container-padding); border-bottom: 1px solid var(--control-bg); }
  .th-nav__list { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
  .th-nav__list > li:not(.th-nav__primary):not(.th-scrub) .btn__label { display: none; }
  .th-nav__follow.btn { width: 44px; padding-inline: 0; }
  .th-scrub { display: none; }
  .th-side { display: none; }   /* как Flarum: на телефоне только действия темы, без колонки сведений */

  .th-hero .hero__in { padding-top: 18px; padding-bottom: 18px; }
  .th-hero__badges { display: flex; justify-content: center; margin: 0 0 6px; }
  .th-stream > .pag { margin-top: 5px; }

  .th-post { display: block; padding: 20px 0; min-height: 0; }
  .th-posts > .th-post:first-child { padding-top: 5px; }
  .th-post__side { position: absolute; top: 20px; left: 0; }
  .th-posts > .th-post:first-child .th-post__side { top: 5px; }
  .th-post__side { width: 32px; }
  .th-post__av .av { width: 32px; height: 32px; }
  /* Маленький значок в самом углу: голова Minecraft в 32px остаётся видна почти целиком */
  .th-post__badges { top: 22px; right: -7px; }
  .th-post__badges .badge--icon { width: 12px; height: 12px; box-shadow: 0 0 0 2px var(--body-bg); }
  .th-post__badges .badge--icon .ic { width: 8px; height: 8px; }
  .th-post__hd { min-height: 32px; padding-left: 42px; gap: 2px 8px; margin-bottom: 10px; }
  .th-post__hd .badge--donate { display: none; }
  .th-post__acts { margin-right: -8px; }
  .th-card.hovercard { width: calc(100vw - 20px); }
  .th-card__profile { grid-template-columns: 56px minmax(0, 1fr); gap: 14px; }
  .th-card__av .av { width: 56px; height: 56px; }

  .th-poll, .th-solution { padding: 12px 15px; }

  .th-composer { display: block; padding-right: 0; }
  .th-composer__av { display: none; }
  .th-placeholder { margin-left: 0; margin-right: 0; }
  .th-placeholder .actions { margin-left: 0; }

  .editor textarea { padding: 12px 15px; font-size: 16px; }
  .editor .editor__ft { padding: 8px 15px; }
  .editor__hint { display: none; }
}

@media (pointer: coarse) {
  .th-act.btn { min-height: 44px; }
  .th-act.btn--icon { width: 44px; }
  .react { min-width: 44px; min-height: 44px; }
  .react-pop button { width: 44px; height: 44px; }
  .th-post__name { min-height: 44px; }
  .th-post__time, .th-post__hd a.th-post__num, .th-post__reply-to { display: inline-flex; align-items: center; min-height: 44px; }
  .th-post__hd a.th-post__num { min-width: 44px; justify-content: flex-end; }
  .th-people a { min-height: 44px; }
  .th-similar a, .th-info dd a { display: inline-flex; align-items: center; min-height: 44px; }
  .th-scrub__edge.btn { min-height: 44px; }
  .th-tag { min-height: 44px; }
  .editor .editor__bar button.editor__tool { width: 44px; min-width: 44px; height: 44px; }
  .editor .editor__bar .editor__pv.btn { width: 44px; height: 44px; min-height: 44px; }
  .editor__ft a { display: inline-flex; align-items: center; min-height: 44px; }
  .th-solution__go { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ========================== Справка BBCode ================================ */
.bbhelp .tbl td { vertical-align: top; }
.bbhelp__code {
  display: inline-block;
  padding: 2px 6px;
  border-radius: var(--border-radius);
  background: var(--code-bg);
  color: var(--code-color);
  font-family: var(--font-family-mono);
  font-size: 12px;
  line-height: 1.5;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: normal;
  word-break: normal;
}
/* Тег целиком не рвётся: переносы — только между тегами (<wbr>) и по пробелам */
.bbhelp__tag { white-space: nowrap; }
.bbhelp__res { font-size: var(--font-size); line-height: 1.6; }
.bbhelp__res .bb-quote, .bbhelp__res .bb-spoiler, .bbhelp__res .bb-banner, .bbhelp__res .bb-code, .bbhelp__res .bb-table-wrap { margin: 0; }
.bbhelp__res .bb-quote, .bbhelp__res .bb-spoiler, .bbhelp__res .bb-banner, .bbhelp__res .bb-table { background: var(--body-bg); }
.bbhelp__res .bb-mention, .bbhelp__res .bb-kbd, .bbhelp__res .bb-server { background: var(--body-bg); }
.bbhelp__res .bb-list { margin: 0; }
.bbhelp__res .bb-hr { margin: 10px 0; border-top-color: var(--muted-more-color); }
.bbhelp__descr { color: var(--muted-color); font-size: 13px; }
/* Заглушка для [img]/[youtube]: реальную картинку по выдуманной ссылке не грузим */
.bbhelp__media { display: inline-flex; align-items: center; gap: 10px; }
.bbhelp__media-box { display: grid; place-items: center; flex-shrink: 0; width: 96px; height: 54px; border-radius: var(--border-radius); background: var(--control-bg-light); color: var(--muted-color); }
.bbhelp__media-box .ic { width: 20px; height: 20px; }
.bbhelp__media-text { font-size: var(--font-size-sm); color: var(--muted-color); }
.bbhelp__sec + .bbhelp__sec { margin-top: 30px; }
.bbhelp__hd { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: var(--font-size-md); font-weight: 600; line-height: 1.4; color: var(--heading-color); }
.bbhelp__hd .ic { width: 16px; height: 16px; color: var(--muted-color); }
.bbhelp__emoji { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 2px 10px; margin: 0; padding: 15px 20px; list-style: none; border-radius: var(--border-radius); background: var(--control-bg); }
.bbhelp__emoji li { display: flex; align-items: center; gap: 8px; min-height: 30px; font-size: 13px; color: var(--muted-color); }
.bbhelp__emoji span { font-size: 18px; line-height: 1; }
.bbhelp__emoji code { font-family: var(--font-family-mono); font-size: 12px; color: var(--text-color); }
.bbhelp__example { padding: 15px; border-radius: var(--border-radius); background: var(--control-bg); font-size: 14px; line-height: 1.6; }
.bbhelp__example .bb-quote, .bbhelp__example .bb-spoiler, .bbhelp__example .bb-kbd { background: var(--body-bg); }
.bbhelp__rules { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.6; color: var(--muted-color); }
.bbhelp__rules li + li { margin-top: 6px; }
.bbhelp__rules code { padding: 1px 4px; border-radius: 3px; background: var(--code-bg); color: var(--code-color); font-family: var(--font-family-mono); font-size: 12px; }
@media (max-width: 767.98px) {
  .bbhelp .tbl thead { display: none; }
  .bbhelp .tbl, .bbhelp .tbl tbody, .bbhelp .tbl tr, .bbhelp .tbl td { display: block; width: 100%; }
  .bbhelp .tbl tr { padding: 10px 15px; border-bottom: 1px solid var(--body-bg); }
  .bbhelp .tbl tr:last-child { border-bottom: 0; }
  .bbhelp .tbl td { padding: 3px 0; border: 0; }
}

/* ========================= Редактирование сообщения ======================= */
/* Та же форма, что у ответа (.th-composer) и новой темы: аватар слева, строка-заголовок, поле */
.editpost { --avatar-column-width: 85px; }
.editpost .th-composer { margin-top: 0; padding-right: 0; }
.editpost__hd { margin-bottom: 0; }
.editpost__hd .th-composer__topic:hover { color: var(--link-color); text-decoration: underline; }
.editpost__meta { margin: 0 0 12px 20px; font-size: var(--font-size-sm); color: var(--muted-color); }
.editpost__form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.editpost__form .field { margin: 0; }
.editpost__form .field label .dim { font-weight: 400; color: var(--muted-color); }
.editpost__title .inp { height: 44px; font-size: 18px; color: var(--heading-color); }
.editpost__title .inp::placeholder { color: var(--muted-color); }
/* Предупреждение модератору — тихая врезка внутри формы, а не жёлтый тост */
.editpost__warn.alert { --alert-bg: var(--control-bg); --alert-color: var(--control-color); margin-bottom: 10px; }
.editpost__warn.alert > .ic { color: var(--warn); }
.editpost__warn b { color: var(--text-color); }
.editpost-aside__block + .editpost-aside__block { margin-top: 30px; }
.editpost-aside__list { margin: 0 0 8px; padding-left: 18px; color: var(--muted-color); }
.editpost-aside__list li + li { margin-top: 6px; }
.editpost-aside__text { margin: 0 0 8px; color: var(--muted-color); }
.editpost-aside__link.btn { display: flex; justify-content: flex-start; padding-inline: 0; }
@media (max-width: 767.98px) {
  .editpost__meta { margin-left: 0; }
  .editpost__title .inp { font-size: 16px; }
}
