/* ==========================================================================
   BLASTIX FORUM — фундамент интерфейса

   Правила перенесены и адаптированы из открытых шаблонов (лицензия MIT):

   Flarum — https://github.com/flarum/framework
     core/less/common/* (scaffolding, Button, Dropdown, Modal, FormControl,
     Select, Checkbox, Avatar, Badge, Tooltip, Pagination, Alert, AlertManager,
     Table, Tabs, Placeholder, sideNav) и core/less/forum/* (PageStructure,
     Hero, App, HeaderDropdown, HeaderList, UserCard, Post), tags/less (TagLabel)
     Copyright (c) 2019-2024 Stichting Flarum (Flarum Foundation)
     Copyright (c) 2014-2019 Toby Zerner

   NodeBB Harmony theme — https://github.com/NodeBB/nodebb-theme-harmony
     (главная-доска разделов и виджеты; сами правила — в screens/index.css)
     Copyright (c) 2013-present NodeBB Inc., Julian Lam, Barış Soner Uşaklı

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software and associated documentation files (the "Software"), to deal
   in the Software without restriction, including without limitation the rights
   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   copies of the Software, and to permit persons to whom the Software is
   furnished to do so, subject to the following conditions: The above copyright
   notice and this permission notice shall be included in all copies or
   substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS",
   WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED.
   Полные тексты лицензий — THIRD_PARTY_NOTICES.md в корне проекта.

   Токены — tokens.css. Стили экранов — screens/*.css.
   ========================================================================== */

/* ============================== 1. Scaffolding ============================ */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-height) + 15px);
}

body {
  margin: 0;
  background: var(--body-bg);
  color: var(--text-color);
  font-family: var(--font-family);
  font-size: var(--font-size);
  line-height: var(--line-height);
  overflow-y: scroll;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  line-height: 1.3;
  color: var(--heading-color);
}
h1 { font-size: 22px; font-weight: 400; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 700; }
h5, h6 { font-size: 13px; font-weight: 700; }

p { margin: 0 0 10px; }
b, strong { font-weight: 700; }
small { font-size: 85%; }
img { max-width: 100%; height: auto; }
svg { flex-shrink: 0; }

a { color: inherit; text-decoration: none; cursor: pointer; }

hr {
  margin: 15px 0;
  border: 0;
  border-top: 2px solid var(--control-bg);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}
button { cursor: pointer; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
legend { padding: 0; }
input[type="search"] { -webkit-appearance: none; }

code, kbd, pre, samp { font-family: var(--font-family-mono); }

mark {
  background: var(--highlight-color);
  color: var(--text-on-light);
  padding: 1px;
  border-radius: var(--border-radius);
}

blockquote { margin: 0; }
blockquote p:last-child, blockquote ul:last-child, blockquote ol:last-child { margin-bottom: 0; }

::selection { background: var(--primary-color); color: var(--button-primary-color); }

/* Видимый фокус — акцентом, на любой поверхности */
:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.sr-only,
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: absolute;
  left: 10px;
  top: -100px;
  z-index: calc(var(--zindex-header) + 1);
  padding: 8px 13px;
  border-radius: var(--border-radius);
  background: var(--button-primary-bg);
  color: var(--button-primary-color);
  font-weight: 700;
}
.skip-link:focus { top: 8px; }

/* Контраст текста на цветном фоне (Flarum text-contrast) */
.text-contrast--dark { --contrast-color: var(--text-on-light); }
.text-contrast--light { --contrast-color: var(--text-on-dark); }

/* ======================== 2. Каркас страницы (App) ======================== */
/* Ширина контейнера — одна на всех страницах: шапка, hero и подвал не «прыгают»
   при переходе с главной (3 колонки) в тему. 1300px с 1100px, 1500px с 2000px. */
@media (min-width: 1100px) { :root { --container-width: var(--container-xl); } }
@media (min-width: 2000px) { :root { --container-width: var(--container-xxl); } }

.container,
.wrap {
  width: min(var(--container-width), 100%);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

/* Основная область. Прямые дети выстраиваются по ширине контейнера,
   .hero и .full-bleed растягиваются на всю ширину окна. */
.App-content:focus { outline: none; }
.App-content {
  display: block;
  border-top: 1px solid var(--control-bg);
  padding-bottom: var(--app-bottom-padding);
  min-height: calc(100vh - var(--header-height) - 120px);
}
.App-container {
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--container-padding), 1fr)
    [content-start] minmax(0, calc(min(var(--container-width), 100%) - 2 * var(--container-padding)))
    [content-end] minmax(var(--container-padding), 1fr)
    [full-end];
  align-content: start;
}
.App-container > * { grid-column: content; min-width: 0; }
.App-container > .hero,
.App-container > .full-bleed { grid-column: full; }
.App-container > :not(.hero):first-child,
.App-container > .hero + :not(.hero) { margin-top: 30px; }

/* ================================ 2b. Кнопки ============================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  min-height: 36px;
  padding: 8px 13px;
  border: 0;
  border-radius: var(--border-radius);
  background: var(--button-bg);
  color: var(--button-color);
  font: inherit;
  font-size: var(--font-size);
  font-weight: 400;
  line-height: 20px;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color var(--transition), color var(--transition);
}
.btn:hover,
.btn:focus-visible { background-color: var(--button-bg-hover); text-decoration: none; }
.btn:active,
.btn.active,
.btn[aria-expanded="true"] { background-color: var(--button-bg-active); }
.btn .ic { width: 16px; height: 16px; }
.btn__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.btn__caret { margin-left: 0; width: 14px; height: 14px; }
.btn.disabled,
.btn[disabled],
.btn[aria-disabled="true"],
fieldset[disabled] .btn {
  opacity: .65;
  cursor: default;
  background: var(--button-bg-disabled);
}
a.btn.disabled, a.btn[aria-disabled="true"] { pointer-events: none; }

.btn--pri,
.btn--primary {
  --button-color: var(--button-primary-color);
  --button-bg: var(--button-primary-bg);
  --button-bg-hover: var(--button-primary-bg-hover);
  --button-bg-active: var(--button-primary-bg-active);
  --button-bg-disabled: var(--button-primary-bg-disabled);
  font-weight: 700;
  padding-inline: 20px;
}
.btn--danger {
  --button-color: var(--control-danger-color);
  --button-bg: var(--control-danger-bg);
  --button-bg-hover: var(--control-danger-bg-hover);
  --button-bg-active: var(--control-danger-bg-active);
  --button-bg-disabled: var(--control-danger-bg-disabled);
}
.btn--inverted {
  --button-color: var(--button-inverted-color);
  --button-bg: var(--button-inverted-bg);
  --button-bg-hover: var(--button-inverted-bg-hover);
  --button-bg-active: var(--button-inverted-bg-active);
}
/* Прозрачная, при наведении — цвет ссылки */
.btn--link { background: transparent !important; }
.btn--link:hover,
.btn--link:focus-visible,
.btn--link:active,
.btn--link.active,
.btn--link[aria-expanded="true"] { background: transparent !important; color: var(--link-color); }
/* Прозрачная, при наведении — фон кнопки */
.btn--flat,
.btn--ghost { background: transparent; }
.btn--flat { border-radius: 18px; }
/* Кнопка-текст внутри строки */
.btn--text {
  min-height: 0;
  padding: 0;
  background: transparent !important;
  color: inherit;
  line-height: inherit;
  vertical-align: baseline;
}
.btn--text:hover { text-decoration: underline; }
.btn--icon { width: 36px; padding: 8px 0; }
.btn--icon .btn__label { display: none; }
.btn--sm,
.btn--compact { min-height: 28px; padding: 4px 10px; font-size: 13px; }
.btn--sm.btn--icon { width: 28px; padding: 4px 0; }
.btn--lg { min-height: 44px; padding: 12px 20px; font-size: var(--font-size-md); }
.btn--rounded { border-radius: 18px; }
.btn--block { display: flex; width: 100%; }
.btn .bubble { top: 1px; left: 19px; }

.btn-group { position: relative; display: inline-flex; gap: 1px; max-width: 100%; }
.btn-group > .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.btn-group > .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group--block { display: flex; width: 100%; }
.btn-group--block > .btn:first-child { flex: 1; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }

/* ============================ 3. Шапка (App-header) ======================= */
.hd {
  position: sticky;
  top: 0;
  z-index: var(--zindex-header);
  height: var(--header-height);
  background: var(--header-bg);
}
.hd__in {
  display: flex;
  align-items: center;
  gap: 15px;
  height: 100%;
}

.hd__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 36px;
  border-radius: var(--border-radius);
}
.hd__logo img { display: block; height: 32px; width: auto; }

/* Header-primary: ссылки как Button--link с иконкой */
.hd__nav {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}
.hd__nav .btn { --button-color: var(--header-control-color); padding-inline: 8px; }
/* Подсказка нужна, только когда подписи скрыты */
@media (min-width: 1140px) {
  .hd__nav:not(.is-compact) .tip[data-tip]::after,
  .hd__nav:not(.is-compact) .tip[data-tip]::before { display: none; }
}
/* Подписи не помещаются (класс ставит app.js) — остаются иконки */
.hd__nav.is-compact .btn__label { display: none; }
.hd__nav.is-compact .btn { width: 36px; padding-inline: 0; }
.hd__nav .btn:focus-visible { outline-offset: -2px; }
.hd__nav .btn.on,
.hd__nav .btn[aria-current="page"] { color: var(--link-color); }

/* Header-secondary */
.hd__secondary {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex-shrink: 0;
}
.hd__item { position: relative; }
.hd__icon { position: relative; --button-color: var(--header-control-color); }
.hd__icon.has-new { color: var(--header-color); }

/* Поиск: FormControl с иконкой, раскрывается при фокусе (Flarum Search) */
.hd__search { position: relative; margin-right: 8px; }
.hd__search > .ic {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--control-color);
  pointer-events: none;
  z-index: 1;
}
.hd__search .inp { width: 200px; padding-left: 34px; }
.hd__search .inp:focus { width: 300px; }

/* Счётчик-пузырёк (Flarum Bubble) */
.bubble {
  position: absolute;
  top: 2px;
  left: 18px;
  min-width: 16px;
  height: 16px;
  padding: 2px 4px 3px;
  border-radius: 10px;
  background: var(--bubble-bg);
  color: var(--bubble-color);
  box-shadow: 0 0 0 1px var(--bubble-shadow-color);
  font-size: var(--font-size-xs);
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.bubble--primary { --bubble-bg: var(--primary-color); --bubble-color: var(--button-primary-color); }
.bubble--static { position: static; display: inline-flex; }

/* Меню пользователя (Flarum SessionDropdown) */
.session__btn { border-radius: 18px; }
.session__btn .av { width: 24px; height: 24px; margin: -2px 0 -2px -6px; }
.session__name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }

.hd__burger.btn { display: none; }

/* Мобильное меню-шторка (Flarum App-drawer) */
.drawer,
.drawer-backdrop { display: none; }

/* Баннер-объявление: полоса Flarum Alert под шапкой */
.announce {
  background: var(--alert-bg);
  color: var(--alert-color);
  font-size: var(--font-size);
}
.announce__in {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding-block: 4px;
}
.announce__text { grid-column: 2; text-align: center; }
.announce a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.announce__x.btn { grid-column: 3; --button-color: var(--alert-color); }
.announce__x.btn:hover,
.announce__x.btn:focus-visible { color: var(--alert-color); background: rgba(0, 0, 0, .08) !important; }
.announce__x.btn:focus-visible { outline-color: var(--alert-color); }

@media (max-width: 1199.98px) {
  .hd__search .inp { width: 180px; }
  .hd__search .inp:focus { width: 260px; }
}
@media (max-width: 1139.98px) {
  .hd__nav .btn__label { display: none; }
  .hd__nav .btn { padding-inline: 0; width: 36px; }
}
@media (max-width: 1099.98px) {
  .session__name, .session__btn .btn__caret { display: none; }
  .session__btn .av { margin: -2px; }
  .session__btn { padding-inline: 8px; }
}
@media (min-width: 768px) and (max-width: 991.98px) {
  .hd__search { width: 36px; height: 36px; }
  .hd__search .inp { position: absolute; right: 0; top: 0; width: 36px; padding-right: 0; color: transparent; cursor: pointer; }
  .hd__search .inp::placeholder { color: transparent; }
  .hd__search .inp:focus { width: 260px; padding-right: 11px; color: var(--text-color); cursor: text; z-index: 0; }
  .hd__search .inp:focus::placeholder { color: var(--control-color); }
}
@media (max-width: 767.98px) {
  html { overflow-x: hidden; scroll-padding-top: calc(var(--header-height-phone) + 10px); }
  .hd { height: var(--header-height-phone); }
  .hd__in { gap: 4px; padding-inline: 4px; }
  .hd__burger.btn { display: inline-flex; }
  .hd__logo img { height: 26px; }
  .hd__nav, .hd__search, .hd__guest-extra.btn { display: none; }
  .hd .drop {
    position: fixed;
    top: var(--header-height-phone);
    left: 0;
    right: 0;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: calc(100vh - var(--header-height-phone));
    margin: 0;
    border-radius: 0;
  }

  .drawer {
    display: block;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: var(--zindex-modal);
    width: var(--drawer-width);
    max-width: 85vw;
    padding-bottom: 20px;
    overflow-y: auto;
    background: var(--header-bg);
    box-shadow: 0 2px 6px var(--shadow-color);
    transform: translateX(calc(-100% - 6px));
    visibility: hidden;
  }
  .drawer.open { transform: none; visibility: visible; }
  .drawer-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: var(--zindex-modal-background);
    background: var(--overlay-bg);
  }
  body.drawer-open { overflow: hidden; }
}
.drawer__hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height-phone);
  padding: 0 4px 0 15px;
}
.drawer__hd img { height: 26px; width: auto; display: block; }
.drawer__search { position: relative; padding: 5px 10px 10px; }
.drawer__search > .ic { position: absolute; left: 21px; top: 50%; transform: translateY(calc(-50% - 2px)); color: var(--control-color); pointer-events: none; }
.drawer__search .inp { padding-left: 34px; }
.drawer .btn:not(.btn--icon) {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  padding-inline: 15px;
  border-radius: 0;
}
.drawer__sep { height: 1px; margin: 8px 0; background: var(--control-bg); }
.drawer__label { padding: 10px 15px 4px; font-size: var(--font-size-sm); font-weight: 700; color: var(--muted-more-color); }

/* ================================ 4. Hero ================================= */
.hero {
  --hero-accent: var(--secondary-color);
  position: relative;
  background: var(--hero-bg);
  color: var(--contrast-color, var(--hero-color));
  text-align: center;
}
.hero__in {
  position: relative;
  width: min(var(--container-width), 100%);
  margin-inline: auto;
  padding: 20px var(--container-padding);
}
.hero__title {
  margin: 0;
  /* Фирменный Robochyi Sans — единственное место, где он используется: заголовки hero
     на всех страницах одинаково (раньше часть hero была на Inter — выглядело как два дизайна) */
  font-family: var(--font-family-brand);
  font-size: 20px;   /* у Robochyi маленький x-height: 16px на телефоне не отличался от подзаголовка */
  font-weight: 600;
  line-height: 1.4;
  color: var(--contrast-color, var(--heading-color));
  overflow-wrap: anywhere;
}
.hero__sub {
  max-width: 75ch;
  margin: 8px auto 0;
  line-height: 1.5;
  color: var(--contrast-color, var(--hero-color));
}
.hero__sub:last-child { margin-bottom: 0; }
.hero__label { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.hero__label .chip,
.hero__label .badge { font-size: 14px; padding: 2px 8px; }
.hero__meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 15px; margin-top: 10px; font-size: var(--font-size-sm); }
.hero__acts { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; margin-top: 15px; }
.hero__close.btn { position: absolute; right: 5px; top: 5px; --button-color: var(--hero-color); }
/* Цвет раздела — только очень приглушённо */
.hero--colored {
  /* Смешиваем в oklab и слабее: тёплые цвета (жёлтый, оранжевый) в srgb давали грязно-оливковый фон */
  --hero-bg: color-mix(in oklab, var(--hero-accent) 10%, var(--control-bg));
  /* На тонированном фоне muted проседает до 3.9:1 — берём светлее: ≥ 4.96:1 для любого цвета, даже белого */
  --hero-color: var(--muted-color-light);
  --muted-color: var(--muted-color-light);
  --muted-more-color: var(--muted-color-light);
}
.hero--left { text-align: left; }
.hero--left .hero__sub { margin-inline: 0; }
.hero--left .hero__label, .hero--left .hero__meta, .hero--left .hero__acts { justify-content: flex-start; }

@media (min-width: 768px) {
  .hero__in { padding-top: 40px; padding-bottom: 30px; }
  .hero__title { font-size: var(--font-size-hero); }
  .hero__sub { font-size: var(--font-size-md); }
}

/* ===================== 5. Раскладки страниц (PageStructure) =============== */
/* .page            — sideNav + контент (IndexPage)
   .page--aside     — контент + правая колонка (DiscussionPage)
   .page--3col      — sideNav + контент + правая колонка (главная)
   Ниже 1100px правая колонка уходит под контент,
   768–991px sideNav становится горизонтальной лентой,
   ниже 768px — выпадающей кнопкой. */
.page {
  --page-gap: 50px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "nav" "content" "aside";
  column-gap: var(--page-gap);
  align-items: start;
  padding-bottom: var(--page-bottom-padding);
}
.page--aside { grid-template-areas: "content" "aside"; }
.page__nav { grid-area: nav; min-width: 0; margin-bottom: 15px; }
.page__content { grid-area: content; min-width: 0; }
.page__aside { grid-area: aside; min-width: 0; margin-top: 30px; }
.page__aside:empty { display: none; }

@media (min-width: 992px) {
  .page {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-areas: "nav content" "nav aside";
  }
  .page--aside {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "content" "aside";
  }
  .page__nav { margin-bottom: 0; }
  .page__nav > .sidenav {
    position: sticky;
    top: calc(var(--header-height) + 30px);
    max-height: calc(100vh - var(--header-height) - 45px);
    margin: -3px;
    padding: 3px;
    overflow-y: auto;
    scrollbar-width: thin;
  }
}
@media (min-width: 1100px) {
  /* Одна ширина боковой навигации на всех страницах (2 и 3 колонки) —
     иначе контент прыгает при переходе между разделами */
  .page { --sidebar-width: 210px; --page-gap: 40px; }
  .page--3col {
    --aside-width: 280px;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--aside-width);
    grid-template-areas: "nav content aside";
  }
  .page--aside {
    grid-template-columns: minmax(0, 1fr) var(--aside-width);
    grid-template-areas: "content aside";
  }
  .page--3col > .page__aside,
  .page--aside > .page__aside { margin-top: 0; }
}

/* Старые раскладки (контент + колонка) — ведут себя как .page--aside */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 30px 50px; align-items: start; }
.layout--wide { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) var(--aside-width); }
  .layout--rev { grid-template-columns: var(--aside-width) minmax(0, 1fr); }
  .layout--wide { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1099.98px) {
  .side-col { order: 2; }
}
.sticky { position: sticky; top: calc(var(--header-height) + 15px); }

/* ============================ 6. sideNav ================================== */
.sidenav { position: relative; min-width: 0; }
.sidenav__primary.btn { display: flex; width: 100%; margin-bottom: 20px; }
.sidenav__select { position: relative; }
.sidenav__toggle.btn { display: none; }
.sidenav__list { list-style: none; margin: 0; padding: 0; }

@media (min-width: 768px) {
  /* Dropdown--select раскрыт в обычный список */
  .sidenav .sidenav__list.drop {
    position: static;
    display: block;
    min-width: 0;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow: visible;
    background: none;
    box-shadow: none;
    border-radius: 0;
  }
}
.sidenav .sidenav__list > li > a {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 8px 15px 8px 0;
  border-radius: 0;
  background: none;
  color: var(--sidenav-color, var(--muted-color));
  font-size: var(--font-size);
  font-weight: 400;
  line-height: 20px;
  /* Длинные названия разделов переносятся на вторую строку, а не режутся многоточием */
  white-space: normal;
  text-decoration: none;
  transition: color var(--transition);
}
.sidenav .sidenav__list > li > a > .ic,
.sidenav .sidenav__list > li > a > .sidenav__ic { align-self: flex-start; margin-top: 2px; }
.sidenav .sidenav__list > li > a:hover { background: none; color: var(--link-color); }
.sidenav .sidenav__list > li > a:focus-visible { outline-offset: -2px; }
.sidenav .sidenav__list > li.active > a,
.sidenav .sidenav__list > li > a.on,
.sidenav .sidenav__list > li > a[aria-current="page"] {
  background: none;
  color: var(--primary-color);
  font-weight: 700;
}
.sidenav__list .ic { width: 16px; height: 16px; flex-shrink: 0; color: inherit; }
.sidenav__ic { display: inline-flex; flex-shrink: 0; }
.sidenav__label { min-width: 0; overflow-wrap: break-word; }
.sidenav__count { margin-left: auto; font-size: var(--font-size-sm); font-weight: 700; color: var(--muted-more-color); }
.sidenav__list > li.active .sidenav__count { color: inherit; }
.sidenav__sep { height: 1px; margin: 8px 0; background: none; }
.sidenav__hd {
  padding: 14px 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted-more-color);
}

@media (min-width: 768px) and (max-width: 991.98px) {
  /* Горизонтальная лента (sideNav--horizontal) */
  .sidenav {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--control-bg);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
  }
  .sidenav__primary.btn { width: auto; margin: 0; flex-shrink: 0; }
  .sidenav .sidenav__list.drop { display: flex; gap: 20px; }
  .sidenav .sidenav__list > li > a { gap: 8px; padding-right: 0; white-space: nowrap; }
  .sidenav__hd, .sidenav__sep { display: none; }
}
@media (max-width: 767.98px) {
  .sidenav { display: flex; align-items: flex-start; gap: 5px; }
  .sidenav__select { flex: 1 1 auto; min-width: 0; }
  .sidenav__toggle.btn { display: flex; width: 100%; justify-content: flex-start; }
  .sidenav__toggle .btn__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: left; }
  .sidenav__primary.btn { order: 2; width: auto; margin: 0; flex-shrink: 0; }
  .sidenav .sidenav__list.drop { left: 0; right: auto; min-width: 100%; max-width: calc(100vw - 30px); }
  /* На телефоне список — обычное выпадающее меню Flarum Dropdown--select */
  .sidenav .sidenav__list > li > a { padding: 8px 15px; gap: 9px; color: var(--text-color); }
  .sidenav .sidenav__list > li > a:hover { background: var(--control-bg); color: var(--text-color); }
  .sidenav__hd { padding: 10px 15px 4px; }
}

/* ================================ 8. Формы ================================ */
.field { margin-bottom: 18px; }
.field > label,
.field__label {
  display: block;
  margin-bottom: 8px;
  font-size: var(--font-size);
  font-weight: 700;
  color: var(--text-color);
}
.hint,
.field .hint {
  margin: 6px 0 0;
  font-size: var(--font-size-sm);
  line-height: 1.5;
  color: var(--muted-color);
}
.field__error { margin: 6px 0 0; font-size: var(--font-size-sm); color: var(--error-color); }

.inp,
.sel,
.txa {
  display: block;
  width: 100%;
  height: 36px;
  margin: 0;
  padding: 6px 11px;
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  background-color: var(--form-control-bg, var(--control-bg));
  color: var(--form-control-color, var(--control-color));
  font-size: var(--font-size);
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}
.inp:focus,
.sel:focus,
.txa:focus {
  background-color: var(--body-bg);
  color: var(--text-color);
  border-color: var(--primary-color);
  outline: none;
}
.inp::placeholder,
.txa::placeholder { color: var(--control-color); opacity: 1; }
.inp[disabled], .sel[disabled], .txa[disabled],
.inp[readonly], .txa[readonly],
fieldset[disabled] .inp { opacity: .5; }
.inp[disabled], .sel[disabled], .txa[disabled] { cursor: not-allowed; }
.inp[aria-invalid="true"], .txa[aria-invalid="true"], .inp.is-invalid { border-color: var(--validation-error-color); }
.txa,
textarea.inp { height: auto; min-height: 110px; resize: vertical; line-height: 1.6; }
.inp[type="color"] { padding: 2px; cursor: pointer; }
.inp[type="file"] { height: auto; padding: 4px; cursor: pointer; }
.inp[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 4px 10px;
  border: 0;
  border-radius: var(--border-radius);
  background: var(--control-bg-light);
  color: var(--text-color);
  font: inherit;
  cursor: pointer;
}

.sel {
  padding-right: 32px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23909dad' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.sel[multiple], .sel[size] { height: auto; padding-right: 11px; background-image: none; }
.sel option { background: var(--body-bg); color: var(--text-color); }

/* Поле с иконкой слева (Input--withPrefix) */
.inp-icon { position: relative; }
.inp-icon > .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--control-color); pointer-events: none; }
.inp-icon > .inp { padding-left: 34px; }

/* Поля внутри поверхности control-bg получают фон страницы (как Modal-body) */
.card--filled .inp, .card--filled .sel, .card--filled .txa,
.modal__bd .inp, .modal__bd .sel, .modal__bd .txa {
  --form-control-bg: var(--body-bg);
  --form-control-color: var(--text-color);
}

/* Чекбокс */
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 5px 0;
  cursor: pointer;
  color: var(--text-color);
}
.check input[type="checkbox"],
.check input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: var(--primary-color);
  cursor: pointer;
}
.check > span { min-width: 0; }
.check b { display: block; font-weight: 700; }
.check .hint { margin-top: 2px; }

/* Переключатель (Checkbox--switch) */
.switch { position: relative; display: flex; align-items: flex-start; gap: 15px; padding: 5px 0; cursor: pointer; }
.switch > input {
  position: absolute;
  left: 0;
  top: 5px;
  z-index: 1;
  width: 50px;
  height: 28px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch__track {
  position: relative;
  flex-shrink: 0;
  width: 50px;
  height: 28px;
  border-radius: 14px;
  background: var(--control-bg-light);
  transition: background-color var(--transition);
}
.switch__track::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--body-bg);
  box-shadow: 0 2px 4px var(--shadow-color);
}
/* Выключенный трек почти сливается с фоном — даём контур ≥3:1 (WCAG 1.4.11) */
.switch > input:not(:checked) + .switch__track { box-shadow: inset 0 0 0 1px var(--muted-more-color); }
.switch > input:checked + .switch__track { background: var(--switch-on-color); }
.switch > input:checked + .switch__track::before { left: 25px; }
.switch > input:focus-visible + .switch__track { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.switch > input:disabled + .switch__track { opacity: .6; }
.switch__text { padding-top: 3px; min-width: 0; }
.modal__bd .switch__track, .card--filled .switch__track { background: var(--muted-more-color); }

/* Группа полей */
.fieldset { margin: 0 0 30px; }
.fieldset > legend,
.fieldset__label {
  display: block;
  margin-bottom: 10px;
  font-size: var(--font-size);
  font-weight: 700;
  color: var(--text-color);
}
.fieldset__items { display: flex; flex-direction: column; gap: 5px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }

@media (max-width: 767.98px) {
  .inp, .sel, .txa { font-size: 16px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

/* =========================== 9. Выпадающее меню =========================== */
.drop {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: var(--zindex-dropdown);
  display: none;
  min-width: 180px;
  max-height: 75vh;
  margin: 7px 0;
  padding: 8px 0;
  overflow-y: auto;
  list-style: none;
  background: var(--body-bg);
  border-radius: var(--border-radius);
  box-shadow: 0 2px 6px var(--shadow-color);
  color: var(--text-color);
  font-size: var(--font-size);
  line-height: 1.5;
  text-align: left;
}
.drop.open { display: block; }
.drop--left { left: 0; right: auto; }
.drop--up { top: auto; bottom: 100%; }
.drop--wide { min-width: 320px; }

/* Пункты меню. Списки sideNav — тоже .drop (на телефоне это Dropdown--select),
   но на широких экранах у них свой вид, поэтому исключаем их явно. */
.drop:not(.sidenav__list) a:not(.btn):not(.drop__link),
.drop .dropitem {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 15px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--text-color);
  font: inherit;
  font-size: var(--font-size);
  font-weight: 400;
  line-height: 20px;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.drop:not(.sidenav__list) a:not(.btn):not(.drop__link):hover,
.drop .dropitem:hover,
.drop:not(.sidenav__list) a:not(.btn):not(.drop__link):focus-visible,
.drop .dropitem:focus-visible { background: var(--control-bg); outline-offset: -2px; }
.drop:not(.sidenav__list) li.active > a,
.drop:not(.sidenav__list) a.active { background: var(--control-bg); }
.drop:not(.sidenav__list) .ic { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted-color); }
.drop .danger:hover,
.drop .danger:focus-visible { background: var(--control-danger-bg); color: var(--control-danger-color); }
.drop .danger:hover .ic { color: inherit; }
.drop form { margin: 0; }
.drop > li { margin: 0; }
.drop__sep { height: 1px; margin: 8px 0; background: var(--control-bg); }
.drop__header {
  padding: 10px 15px 4px;
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--muted-color);
  white-space: nowrap;
}
.drop__meta { padding: 8px 15px; font-size: var(--font-size-sm); color: var(--muted-color); }
.drop__hd { margin: -8px 0 8px; padding: 12px 15px; border-bottom: 1px solid var(--control-bg); }
.drop__link { color: var(--link-color); }
.drop__link:hover { text-decoration: underline; }

/* Список в шапке (HeaderList) — уведомления */
.drop--list { width: 425px; max-width: calc(100vw - 20px); padding: 0; overflow: hidden; }
.drop__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--control-bg);
}
.drop__head h4 { margin: 0; font-size: var(--font-size-sm); font-weight: 700; color: var(--muted-color); }
.drop__body { max-height: min(70vh, 800px); overflow-y: auto; }
.drop__empty { padding: 50px 15px; text-align: center; color: var(--muted-color); font-size: var(--font-size-lg); }

.hl-item {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 10px;
  align-items: start !important;
  padding: 8px 16px !important;
  white-space: normal !important;
  color: var(--muted-color) !important;
}
.hl-item:hover, .hl-item:focus-visible { background: var(--control-bg-shaded) !important; }
.hl-item.unread { background: var(--control-bg); box-shadow: inset 3px 0 0 var(--primary-color); }
.hl-item > .av { margin-top: 1px; }
.hl-item__ic {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--control-bg-light);
  color: var(--muted-color);
}
.hl-item__title { display: block; color: var(--text-color); line-height: 19px; overflow: hidden; text-overflow: ellipsis; }
.hl-item__time { display: block; font-size: var(--font-size-xs); line-height: 19px; font-weight: 700; color: var(--muted-color); }
.hl-item__excerpt { display: block; font-size: var(--font-size-sm); color: var(--muted-more-color); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================== 10. Модалки =============================== */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: var(--zindex-modal);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 120px 10px 30px;
  overflow-y: auto;
  background: var(--overlay-bg);
}
.modal-back.open { display: flex; }
body.modal-open { overflow: hidden; }
.modal {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--body-bg);
  border-radius: var(--border-radius);
  box-shadow: 0 7px 15px var(--shadow-color);
}
.modal--sm { max-width: 375px; }
.modal--lg { max-width: 800px; }
.modal__hd { position: relative; padding: 25px 50px; text-align: center; }
.modal__hd h2,
.modal__hd h3 { margin: 0; font-size: var(--font-size-xl); font-weight: 400; color: var(--heading-color); }
.modal__close,
.modal__hd > button {
  position: absolute;
  right: 10px;
  top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--control-color);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.modal__close:hover,
.modal__hd > button:hover { color: var(--link-color); }
.modal__bd { padding: 25px 30px; background: var(--control-bg); color: var(--control-color); }
.modal__bd label, .modal__bd .field > label { color: var(--text-color); }
.modal__ft {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  padding: 15px 30px;
  background: var(--control-bg);
  color: var(--muted-color);
}
.modal__bd + .modal__ft { padding-top: 0; }
.modal__note { padding: 20px; text-align: center; color: var(--muted-color); }

@media (max-width: 767.98px) {
  .modal-back { padding: 0; }
  .modal { max-width: 100%; min-height: 100dvh; border-radius: 0; box-shadow: none; }
  .modal__bd { padding: 15px; }
  .modal__ft { padding-inline: 15px; }
  .modal__hd { padding: 13px 50px; }
  .modal__hd h2, .modal__hd h3 { font-size: var(--font-size-lg); }
  .modal__close, .modal__hd > button { top: 5px; right: 5px; }
}

/* ============================== 11. Алерты ================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 15px;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  background: var(--alert-bg);
  color: var(--alert-color);
  font-size: var(--font-size);
  line-height: 1.5;
}
.alert--err { --alert-bg: var(--alert-error-bg); --alert-color: var(--alert-error-color); }
.alert--ok { --alert-bg: var(--alert-success-bg); --alert-color: var(--alert-success-color); }
.alert--warn { --alert-bg: #fff2ae; --alert-color: #8a5600; }
.alert--info { --alert-bg: var(--control-bg); --alert-color: var(--text-color); }
.alert a, .alert .btn--text { color: inherit; text-decoration: underline; font-weight: 700; }
.alert > .ic { flex-shrink: 0; width: 16px; height: 16px; margin-top: 2px; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { margin-bottom: 4px; font-weight: 700; }
.alert ul { margin: 0; padding-left: 18px; }
.alert p:last-child { margin-bottom: 0; }
.alert__x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: -8px -10px -8px 4px;
  border: 0;
  border-radius: var(--border-radius);
  background: transparent;
  color: inherit;
  flex-shrink: 0;
  cursor: pointer;
}
.alert__x:hover { background: rgba(0, 0, 0, .1); }
.alert__x:focus-visible { outline-color: currentColor; }

/* AlertManager: всплывающие алерты снизу слева */
.flash-wrap {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: var(--zindex-alerts);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  max-width: min(480px, calc(100vw - 40px));
}
.flash-wrap .alert {
  margin: 0;
  align-items: center;
  box-shadow: 0 2px 6px var(--shadow-color);
}
.flash-wrap .alert.is-leaving { opacity: 0; transition: opacity var(--transition); }
@media (max-width: 767.98px) {
  .flash-wrap { left: 10px; right: 10px; bottom: 10px; max-width: none; }
  .flash-wrap .alert { width: 100%; }
}

/* ============================== 12. Аватары =============================== */
.av {
  display: inline-block;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: top;
  background-color: var(--avatar-bg);
  image-rendering: pixelated;
}
.av--16 { width: 16px; height: 16px; }
.av--20 { width: 20px; height: 20px; }
.av--24 { width: 24px; height: 24px; }
.av--28 { width: 28px; height: 28px; }
.av--32 { width: 32px; height: 32px; }
.av--36 { width: 36px; height: 36px; }
.av--40 { width: 40px; height: 40px; }
.av--48 { width: 48px; height: 48px; }
.av--56 { width: 56px; height: 56px; }
.av--64 { width: 64px; height: 64px; }
.av--72 { width: 72px; height: 72px; }
.av--96 { width: 96px; height: 96px; }
.av--128 { width: 128px; height: 128px; }
.av--round { border-radius: 50%; }
.av-wrap { position: relative; display: inline-block; flex-shrink: 0; line-height: 0; vertical-align: top; }
.dot-on {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--online-user-circle-color);
  box-shadow: 0 0 0 2px var(--body-bg);
}
.uname { font-weight: 700; color: var(--heading-color); }
a.uname:hover { text-decoration: underline; }

/* ================== 13. Ярлыки, значки, медали (Badge/TagLabel) =========== */
/* Ярлык группы — как цветной TagLabel Flarum. Цвет и контраст текста
   выставляет h.groupBadge(): style="--tag-bg:#..." + text-contrast--dark|light */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 1px 6px;
  border-radius: var(--border-radius);
  background: var(--tag-bg);
  color: var(--contrast-color, var(--tag-color));
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  vertical-align: middle;
  text-decoration: none;
}
.badge .ic { width: 12px; height: 12px; }
.badge > span { overflow: hidden; text-overflow: ellipsis; }
.badge--sm { padding: 0 5px; font-size: var(--font-size-xs); line-height: 16px; }
.badge--sm .ic { width: 11px; height: 11px; }
/* Маленький ярлык группы рядом с ником: ник уже в цвете группы,
   поэтому ярлык нейтральный, цвет группы — только у иконки */
.badge--soft { background: var(--control-bg); color: var(--muted-color); font-weight: 500; }
.badge--soft .ic { color: var(--tag-bg); }
/* Значок группы только иконкой — круг 20px, как .Badge в PostUser Flarum */
.badge--icon {
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  line-height: 1;
}
.badge--icon .ic { width: 12px; height: 12px; }
/* Косметический ранг: нейтральный ярлык с цветной меткой */
.badge--donate { --tag-bg: var(--control-bg); --contrast-color: var(--control-color); }
.badge__dot,
.chip__dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 2px;
  background: var(--dot-color, currentColor);
}

/* Ярлык общего назначения (TagLabel) */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 1px 6px;
  border-radius: var(--border-radius);
  background: var(--tag-bg);
  color: var(--tag-color);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  vertical-align: middle;
}
.chip .ic { width: 12px; height: 12px; }
.chip--prefix { --tag-bg: var(--c, var(--control-bg)); --tag-color: var(--text-on-light); }
.chip--status { --dot-color: var(--c); }
.chip--dim { --tag-bg: transparent; --tag-color: var(--muted-more-color); padding-inline: 0; }
.chip--outline { --tag-bg: transparent; box-shadow: inset 0 0 0 1px var(--control-bg-light); }
.cnt { font-size: var(--font-size-sm); font-weight: 700; color: var(--muted-more-color); }

/* Круглый значок-иконка (Flarum Badge: закреплено, закрыто, скрыто) */
.ibadge {
  --size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--size);
  height: var(--size);
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--badge-bg);
  color: var(--badge-color);
}
.ibadge .ic { width: calc(var(--size) * .56); height: calc(var(--size) * .56); }
.ibadge--pinned { --badge-bg: #d13e32; --badge-color: #fff; }   /* значок, не текст: 4.8 : 1 */
.ibadge--locked { --badge-bg: #888; --badge-color: #000; }      /* 5.9 : 1 */
.ibadge--hidden { --badge-bg: var(--badge-hidden-bg); --badge-color: #000; }
.ibadge--solved { --badge-bg: var(--switch-on-color); --badge-color: #fff; }
.ibadges { display: inline-flex; gap: 2px; list-style: none; margin: 0; padding: 0; }

/* Медаль достижения — круглый значок цвета медали (h.medal()) */
.medal {
  --ms: 48px;
  --medal-color: var(--muted-color);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ms);
  height: var(--ms);
  flex-shrink: 0;
  border-radius: 50%;
  /* Цвет медали — метка, а не заливка: тёмный круг, тонкое кольцо и иконка цвета медали */
  background: color-mix(in srgb, var(--medal-color) 14%, var(--control-bg-light));
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--medal-color) 55%, transparent);
  line-height: 1;
  vertical-align: middle;
}
.medal__face { display: inline-flex; color: var(--medal-color); line-height: 1; }
.medal__face .ic { width: calc(var(--ms) * .46); height: calc(var(--ms) * .46); stroke-width: 2; }
.medal--locked { background: var(--control-bg-light); box-shadow: none; }
.medal--locked .medal__face { color: var(--muted-color); }
.medal-row { display: flex; flex-wrap: wrap; gap: 5px; }

/* ============================== 14. Тултип ================================ */
/* <span class="tip" data-tip="Текст"> — появляется при наведении и фокусе */
.tip { position: relative; }
.tip[data-tip]::after,
.tip[data-tip]::before {
  position: absolute;
  left: 50%;
  z-index: var(--zindex-tooltip);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-fast) linear, visibility var(--transition-fast);
}
.tip[data-tip]::after {
  content: attr(data-tip);
  bottom: calc(100% + 5px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 200px;
  padding: 7px 12px;
  border-radius: var(--border-radius);
  background: var(--tooltip-bg);
  color: var(--tooltip-color);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  text-align: center;
  text-transform: none;
  white-space: normal;
  overflow-wrap: break-word;
}
.tip[data-tip]::before {
  content: '';
  bottom: 100%;
  margin-left: -5px;
  border: 5px solid transparent;
  border-bottom-width: 0;
  border-top-color: var(--tooltip-bg);
}
.tip--bottom[data-tip]::after { bottom: auto; top: calc(100% + 5px); }
.tip--bottom[data-tip]::before { bottom: auto; top: 100%; border-width: 0 5px 5px; border-color: transparent transparent var(--tooltip-bg); }
.tip[data-tip]:hover::after, .tip[data-tip]:hover::before,
.tip[data-tip]:focus-visible::after, .tip[data-tip]:focus-visible::before { opacity: 1; visibility: visible; }
@media (hover: none) {
  .tip[data-tip]:hover::after, .tip[data-tip]:hover::before { opacity: 0; visibility: hidden; }
}

/* ============================== 15. Вкладки =============================== */
.tabs {
  display: flex;
  column-gap: 4px;
  margin-bottom: 20px;
  overflow-x: auto;
  border-bottom: 1px solid var(--control-bg);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs > a,
.tabs > button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: -1px;
  padding: 11px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--button-color);
  font: inherit;
  font-size: var(--font-size-md);
  line-height: 20px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition);
}
.tabs > a:hover,
.tabs > button:hover { color: var(--link-color); }
.tabs > a:focus-visible,
.tabs > button:focus-visible { outline-offset: -2px; }
.tabs > .on,
.tabs > [aria-selected="true"],
.tabs > [aria-current="page"] {
  color: var(--text-color);
  border-bottom-color: var(--primary-color);
  font-weight: 700;
}
.tabs .ic { width: 16px; height: 16px; }
.tabs .cnt { margin-left: 3px; }
[data-tab-panel][hidden] { display: none !important; }

/* ============================== 16. Таблица =============================== */
.tbl-wrap { position: relative; max-width: 100%; overflow-x: auto; border-radius: var(--border-radius); }
.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  background: var(--control-bg);
  border-radius: var(--border-radius);
  font-size: var(--font-size);
}
.tbl caption { padding: 0 0 8px; text-align: start; color: var(--muted-color); }
.tbl th,
.tbl td {
  padding: 10px 15px;
  border-bottom: 1px solid var(--body-bg);
  text-align: left;
  vertical-align: middle;
}
.tbl th { color: var(--control-color); font-size: var(--font-size-sm); font-weight: 700; white-space: nowrap; }
.tbl td { color: var(--text-color); }
.tbl tr:last-child > td { border-bottom: 0; }
.tbl tbody tr:hover > td { background: var(--control-bg-shaded); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }


/* ============================ 17. Пагинация =============================== */
/* Компактная группа по центру; первой/предыдущей на первой странице
   (и следующей/последней на последней) нет вовсе — см. partials/pag.ejs */
.pag {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  margin-top: 16px;
}
.pag__num { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 0; margin-inline: 5px; color: var(--muted-color); }
.pag__form { display: contents; }
.pag__label { display: inline-flex; align-items: center; }
@media (max-width: 479.98px) {
  .pag__word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .pag { gap: 4px; }
}
.pag__dbl { gap: 0; }
.pag__dbl .ic + .ic { margin-left: -9px; }
.pag__input.inp { display: inline-block; width: 70px; margin: 0 8px; text-align: center; -moz-appearance: textfield; }
.pag__input::-webkit-outer-spin-button,
.pag__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ============================ 18. Пустое состояние ======================== */
.empty { padding: 40px 15px; text-align: center; color: var(--muted-more-color); }
.empty__ic { display: block; margin: 0 auto 12px; color: var(--muted-more-color); }
.empty .empty__title,
.empty h3 { margin: 0 0 6px; font-size: 1.4em; font-weight: 400; line-height: 1.4; color: var(--muted-more-color); }
.empty__text,
.empty p:not(.empty__title) { max-width: 55ch; margin: 0 auto 12px; font-size: var(--font-size); color: var(--muted-more-color); }
.empty__acts { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; margin-top: 15px; }

/* ===================== 19. Заголовки, навигация, панели =================== */
.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-bottom: 15px;
  font-size: 13px;
  color: var(--muted-more-color);
}
.crumbs a { color: var(--muted-color); }
.crumbs a:hover { color: var(--link-color); text-decoration: underline; }
.crumbs .ic { width: 12px; height: 12px; color: var(--muted-more-color); }

.page-hd { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 15px; margin-bottom: 20px; }
.page-hd h1 { font-size: var(--font-size-xl); font-weight: 400; }
.page-hd p { margin: 4px 0 0; font-size: var(--font-size); color: var(--muted-color); }
.page-hd__acts { display: flex; flex-wrap: wrap; gap: 5px; margin-left: auto; }
/* На узком экране действия переносятся под заголовок — там они выравниваются влево */
@media (max-width: 767.98px) { .page-hd__acts { margin-left: 0; width: 100%; } }

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  font-size: var(--font-size-md);   /* общий заголовок секции/виджета — как Harmony widget: 15/600 */
  font-weight: 600;
  line-height: 1.4;
  color: var(--heading-color);
}
.panel-title .ic { width: 16px; height: 16px; color: var(--muted-color); }
.panel-title a { margin-left: auto; font-size: var(--font-size-sm); font-weight: 400; color: var(--link-color); }

/* Секция без «карточки»: разделение тоном, а не рамкой */
.card { position: relative; min-width: 0; border-radius: var(--border-radius); }
.card--filled { background: var(--control-bg); }
.card--pad { padding: 20px; }
.card__hd { display: flex; align-items: center; gap: 10px; padding: 0 0 10px; }
.card__hd h2, .card__hd h3 { font-size: var(--font-size-md); font-weight: 700; }
.card__hd .ic { color: var(--muted-color); }
.card__bd { padding: 0; }
.card__ft { padding: 10px 0 0; }
.card--filled > .card__hd { padding: 15px 20px 0; }
.card--filled > .card__bd { padding: 15px 20px 20px; }
.card--filled > .card__ft { padding: 12px 20px; border-top: 1px solid var(--body-bg); }
.card + .card { margin-top: 20px; }

.kv { display: grid; grid-template-columns: minmax(100px, 140px) minmax(0, 1fr); gap: 6px 15px; margin: 0; font-size: var(--font-size); }
.kv dt { color: var(--muted-color); }
.kv dd { margin: 0; color: var(--text-color); min-width: 0; overflow-wrap: anywhere; }

/* Раскрывающаяся секция */
.acc { margin-bottom: 5px; border-radius: var(--border-radius); background: var(--control-bg); }
.acc > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 8px 15px;
  list-style: none;
  font-weight: 700;
  color: var(--text-color);
  cursor: pointer;
}
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after {
  content: '';
  margin-left: auto;
  width: 7px;
  height: 7px;
  border: solid var(--muted-color);
  border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
}
.acc[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.acc > summary:hover { color: var(--link-color); }
.acc__bd { padding: 5px 15px 15px; }

/* Обратный отсчёт — обычный текст (app.js обновляет [data-countdown]) */
.countdown,
[data-countdown] { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Прогресс */
.prog { height: 4px; margin-top: 8px; overflow: hidden; border-radius: 2px; background: var(--control-bg-light); }
.prog__fill { height: 100%; background: var(--m1, var(--primary-color)); }
.prog--thin { height: 3px; }

/* Панель фильтров над списком (IndexPage-toolbar) */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 15px; }
.filters .sel, .filters .inp { width: auto; min-width: 140px; }

/* Загрузка */
.skel { display: block; border-radius: var(--border-radius); background: var(--control-bg); }
.skel--text { height: 10px; margin-bottom: 8px; }
.skel--title { height: 16px; width: 60%; margin-bottom: 10px; }
.skel--av { width: 36px; height: 36px; border-radius: 50%; }
.loading {
  --size: 24px;
  display: block;
  width: var(--size);
  height: var(--size);
  margin: 20px auto;
  border: 2px solid var(--loading-indicator-color);
  border-top-color: transparent;
  border-radius: 50%;
  animation: bx-spin .75s linear infinite;
}
.loading--sm { --size: 18px; margin: 0; display: inline-block; vertical-align: middle; }
@keyframes bx-spin { to { transform: rotate(1turn); } }

/* Карточка пользователя по клику на ник (UserCard--popover).
   Позицию выставляет app.js; внутренности — в стилях экрана. */
.hovercard {
  position: absolute;
  z-index: var(--zindex-dropdown);
  display: none;
  width: 400px;
  max-width: calc(100vw - 20px);
  padding: 20px;
  border-radius: var(--border-radius);
  background: var(--usercard-bg);
  box-shadow: 0 2px 6px var(--shadow-color);
  color: var(--text-color);
  text-align: left;
}
.hovercard.open { display: block; }

/* =================== 20. Редактор (TextEditor) и BBCode =================== */
.editor { border-radius: var(--border-radius); background: var(--control-bg); }
.editor:focus-within { outline: 2px solid var(--primary-color); outline-offset: -2px; }
.editor__bar { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; padding: 5px; border-bottom: 1px solid var(--body-bg); }
.editor__bar button {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--control-color);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
}
.editor__bar button:hover { background: var(--body-bg); color: var(--text-color); }
.editor__bar button.on { color: var(--link-color); }
.editor__bar .ic { width: 15px; height: 15px; }
.editor__sep { width: 1px; height: 18px; margin: 0 4px; background: var(--control-bg-light); }
.editor textarea {
  display: block;
  width: 100%;
  min-height: 190px;
  padding: 12px 15px;
  border: 0;
  background: transparent;
  color: var(--text-color);
  font-size: var(--font-size-post);
  line-height: var(--line-height-post);
  resize: vertical;
}
.editor textarea:focus { outline: none; }
.editor textarea::placeholder { color: var(--control-color); }
.editor__ft {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 12px;
  padding: 8px 15px;
  border-top: 1px solid var(--body-bg);
  font-size: var(--font-size-sm);
  color: var(--muted-color);
}
.editor__ft a { color: var(--muted-color); text-decoration: underline; }
.editor__ft a:hover { color: var(--link-color); }
.editor__preview { display: none; padding: 15px; border-top: 1px solid var(--body-bg); background: var(--body-bg); }
.editor__preview.on { display: block; }
.emoji-pop { display: none; flex-wrap: wrap; gap: 2px; padding: 5px; border-top: 1px solid var(--body-bg); }
.emoji-pop.on { display: flex; }
.emoji-pop button { width: 34px; height: 34px; border: 0; border-radius: var(--border-radius); background: transparent; font-size: 18px; cursor: pointer; }
.emoji-pop button:hover { background: var(--body-bg); }

/* Текст сообщения (Post-body) */
.bb { overflow-wrap: break-word; word-wrap: break-word; }
.bb p, .bb ul, .bb ol, .bb blockquote { margin: 0 0 1em; }
.bb > :last-child { margin-bottom: 0; }
.bb > :first-child { margin-top: 0; }
.bb img, .bb iframe { max-width: 100%; }
.bb h1, .bb h2, .bb h3, .bb h4 { margin: 1em 0 16px; font-weight: 700; }

/* Ссылки в тексте отличаются не только цветом (WCAG 1.4.1) */
a.link,
.bb a.bb-link,
.hint a,
.kv dd a,
p a:not([class]) {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--link-color) 45%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.bb a.bb-link { font-weight: 600; }
a.link:hover,
.bb a.bb-link:hover,
.hint a:hover,
.kv dd a:hover,
p a:not([class]):hover { text-decoration-color: currentColor; }

.bb .bb-mention {
  display: inline-block;
  padding: 0 5px;
  border-radius: var(--border-radius);
  background: var(--control-bg);
  color: var(--control-color);
  font-weight: 600;
}
.bb .bb-mention:hover { color: var(--link-color); }

.bb-quote {
  margin: 1em 0;
  overflow: hidden;
  border-radius: var(--border-radius);
  background: var(--control-bg);
  color: var(--control-color);
}
.bb-quote-head { display: flex; align-items: center; gap: 6px; padding: 8px 15px 0; font-size: var(--font-size-sm); color: var(--muted-color); }
.bb-quote-head b { color: var(--text-color); }
.bb-quote-head .q-jump { margin-left: auto; color: var(--muted-color); }
.bb-quote-head .q-jump:hover { color: var(--link-color); text-decoration: underline; }
.bb-quote-body { padding: 8px 15px; }
.bb-quote-body > :last-child { margin-bottom: 0; }
.bb-quote .bb-quote { background: var(--control-bg-light); }

.bb-banner { margin: 1em 0; padding: 15px 20px; border-radius: var(--border-radius); background: var(--control-bg); }
.bb-banner__t { margin-bottom: 6px; font-size: var(--font-size-lg); font-weight: 700; color: var(--heading-color); }
.bb-banner__b > :last-child { margin-bottom: 0; }

.bb code { padding: 1px 3px; border-radius: var(--border-radius); background: var(--code-bg); color: var(--code-color); font-size: 90%; line-height: 1.3; }
.bb-code { margin: 1em 0; overflow: hidden; border-radius: var(--border-radius); background: var(--code-bg); }
.bb-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 2px 15px;
  border-bottom: 1px solid var(--body-bg);
  font-size: var(--font-size-sm);
  color: var(--muted-color);
}
.bb-code-head button { min-height: 28px; padding: 4px 8px; border: 0; border-radius: var(--border-radius); background: none; color: var(--muted-color); font: inherit; cursor: pointer; }
.bb-code-head button:hover { color: var(--link-color); }
.bb-code pre { margin: 0; padding: 1em; overflow-x: auto; max-height: max(50vh, 250px); }
.bb-code pre code { padding: 0; background: none; font-size: 13px; line-height: 1.6; }

.bb-spoiler { margin: 1em 0; border-radius: var(--border-radius); background: var(--control-bg); }
.bb-spoiler > summary { min-height: var(--tap); padding: 8px 15px; font-weight: 600; color: var(--control-color); cursor: pointer; }
.bb-spoiler > summary:hover { color: var(--link-color); }
.bb-spoiler-body { padding: 0 15px 12px; }
.bb-hide { margin: 1em 0; padding: 10px 15px; border-radius: var(--border-radius); background: var(--control-bg); filter: blur(4px); cursor: pointer; }
.bb-hide:hover, .bb-hide:focus-within { filter: none; }

.bb-img { max-height: 520px; width: auto; border-radius: var(--border-radius); }
.bb-img-link { display: inline-block; margin: 5px 0; }
.bb-video { position: relative; max-width: 680px; margin: 1em 0; padding-bottom: 56.25%; overflow: hidden; border-radius: var(--border-radius); }
.bb-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.bb-list { margin: 0 0 1em; padding-left: 24px; }
.bb-list li { margin: 2px 0; }
.bb-center { text-align: center; }
.bb-right { text-align: right; }
.bb-hr { margin: 15px 0; border: 0; border-top: 2px solid var(--control-bg); }
.bb-mark, .bb .hl { padding: 0 2px; border-radius: 2px; background: var(--highlight-color); color: var(--text-on-light); }
.bb-kbd { display: inline-block; padding: 0 6px; border-radius: var(--border-radius); background: var(--control-bg); color: var(--text-color); font-family: var(--font-family-mono); font-size: 90%; }
.bb-glow { font-weight: 600; }
.bb-grad { font-weight: 700; }
.bb-table-wrap { margin: 1em 0; overflow-x: auto; }
.bb-table { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; border-radius: var(--border-radius); background: var(--control-bg); font-size: var(--font-size); }
.bb-table th, .bb-table td { padding: 8px 12px; border-bottom: 1px solid var(--body-bg); text-align: left; }
.bb-table th { font-weight: 700; color: var(--heading-color); }

/* Адрес сервера — обычная кнопка копирования */
.bb-server,
.srv__ip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--border-radius);
  background: var(--control-bg);
  color: var(--text-color);
  font-family: var(--font-family-mono);
  font-size: var(--font-size);
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  transition: background-color var(--transition);
}
.bb-server:hover, .srv__ip:hover { background: var(--control-bg-light); }
.bb-server .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--online-user-circle-color); }
/* Индикатор статуса сервера для [data-srv-status] */
.srv__pulse { display: inline-block; flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--muted-more-color); }
.srv__pulse.on { background: var(--online-user-circle-color); }
.bb-server .cp, .srv__ip .cp { font-family: var(--font-family); font-size: var(--font-size-sm); font-weight: 400; color: var(--muted-color); }
.is-copied .cp { color: var(--text-color); }

/* ================================ 21. Подвал =============================== */
.ft {
  padding: 20px 0 30px;
  border-top: 1px solid var(--control-bg);
  color: var(--muted-more-color);
  font-size: var(--font-size-sm);
  line-height: 1.6;
}
/* Две строки, как у Flarum: ссылки; затем приглушённая строка © и служебной информации */
.ft__row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 16px; margin: 0; padding: 0; list-style: none; }
.ft__nav { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; }
.ft__nav + .ft__legal { margin-top: 10px; }
.ft__legal { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 16px; margin: 0; }
.ft__legal > p { margin: 0; }
.ft__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 16px; margin: 0; padding: 0; list-style: none; }
@media (max-width: 767.98px) {
  .ft__legal { flex-direction: column; align-items: flex-start; }
}
/* В админке и модерации подвала форума нет (как во Flarum admin) */
body:has(.adm) > .ft { display: none; }
.ft a { color: var(--muted-color); }
.ft a:hover { color: var(--link-color); text-decoration: underline; }
.ft .btn--text { color: var(--muted-color); font-size: inherit; }
.ft__copy { font-family: var(--font-family-mono); }

/* ================================ 22. Утилиты ============================= */
.row { display: flex; align-items: center; gap: 10px; }
.row--wrap { flex-wrap: wrap; }
.row--top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 15px; }
.stack--sm { gap: 5px; }
.spacer { flex: 1; }
.dim { color: var(--muted-more-color); }
.muted { color: var(--muted-color); }
.text { color: var(--text-color); }
.danger-text { color: var(--error-color); }
.small { font-size: 13px; }
.tiny { font-size: var(--font-size-sm); }
.mono { font-family: var(--font-family-mono); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }
.ic { flex-shrink: 0; vertical-align: middle; }
.g { color: var(--primary-color); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 15px; } .mt-3 { margin-top: 25px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 15px; } .mb-3 { margin-bottom: 25px; }
@media (max-width: 767.98px) { .hide-xs { display: none !important; } }
@media (min-width: 768px) { .show-xs { display: none !important; } }
@media (max-width: 991.98px) { .hide-sm { display: none !important; } }
@media (max-width: 1099.98px) { .hide-md { display: none !important; } }

/* Режимы из настроек профиля */
body.no-avatars .App-content .av:not(.av--keep),
body.no-avatars .App-content .av-wrap:not(.av--keep) { display: none; }
body.compact .bb { line-height: 1.55; }

/* ======================= 23. Сенсорные экраны ============================= */
@media (pointer: coarse) {
  .btn:not(.btn--text) { min-height: 44px; }
  .btn--icon { width: 44px; }
  .btn--sm.btn--icon { width: 44px; }
  .inp, .sel { height: 44px; }
  .drop:not(.sidenav__list) a:not(.btn):not(.drop__link), .drop .dropitem { min-height: 44px; }
  .sidenav .sidenav__list > li > a { min-height: 44px; }
  .tabs > a, .tabs > button { min-height: 44px; }
  .check, .switch { min-height: 44px; align-items: center; }
  .check input[type="checkbox"], .check input[type="radio"] { width: 20px; height: 20px; margin-top: 0; }
  .editor__bar button { min-width: 44px; height: 44px; }
  .emoji-pop button { width: 44px; height: 44px; }
  .alert__x, .modal__close, .modal__hd > button { width: 44px; height: 44px; }
  .ft a, .ft .btn--text, .crumbs a { display: inline-flex; align-items: center; min-height: 44px; }
  .bb-code-head button { min-height: 44px; }
}

/* ======================= 24. Настройки движения =========================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
