/* ============================================================
   userui — пользовательский интерфейс tghub.
   Мобайл-фёрст: нижние табы → верхнее меню (920px) → постоянная
   колонка каналов (1120px). Светлая база, тёмная — по явному выбору.
   Все цвета/радиусы/тени — только токены :root. Прямые hex запрещены
   (исключение — градиенты аватарок av-*).
   ============================================================ */
:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1a2330;
    --muted: #68737f;
    --faint: #98a2ad;
    --line: #e3e8ed;
    --accent: #0088cc;
    --accent-ink: #ffffff;
    --accent-soft: rgba(0, 136, 204, .09);
    --ok: #2f9e63;
    --ok-soft: rgba(47, 158, 99, .12);
    /* warn — тревожный оранжево-кирпичный (не горчичный): предупреждение
       обязано цеплять взгляд. Отличим от --danger, контраст на своей
       подложке 4.2:1. */
    --warn: #c2410c;
    --warn-soft: rgba(194, 65, 12, .12);
    --danger: #d64545;
    --danger-soft: rgba(214, 69, 69, .09);
    --shadow: 0 1px 2px rgba(16, 24, 32, .05), 0 4px 16px rgba(16, 24, 32, .05);
    --shadow-pop: 0 4px 24px rgba(16, 24, 32, .16);
    --stage-w: 640px;
    --chatlist-w: 316px;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #0e1621;
    --card: #17212b;
    --text: #e9eef3;
    --muted: #8b98a5;
    --faint: #64717e;
    --line: #232f3b;
    --accent: #3aa5dc;
    --accent-ink: #08141d;
    --accent-soft: rgba(58, 165, 220, .13);
    --ok: #4fc182;
    --ok-soft: rgba(79, 193, 130, .14);
    --warn: #fb923c;
    --warn-soft: rgba(251, 146, 60, .16);
    --danger: #e06c6c;
    --danger-soft: rgba(224, 108, 108, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 4px 16px rgba(0, 0, 0, .22);
    --shadow-pop: 0 6px 28px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
/* overflow-x: clip (не hidden) гасит любой остаточный горизонтальный вылет,
   не ломая sticky-топбар и не растягивая фиксированные нижние табы по ширине
   документа (иначе панель «скачет» при инерционном скролле на телефоне). */
html, body { overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 15.5px; line-height: 1.55;
    background: var(--bg); color: var(--text);
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.icon {
    width: 22px; height: 22px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.7;
    stroke-linecap: round; stroke-linejoin: round;
}
.icon-s { width: 17px; height: 17px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
/* Форма-обёртка вокруг кнопки (POST-действие в меню, ячейке, строке):
   не участвует в раскладке родителя. Вместо инлайнового style. */
.form-contents { display: contents; }

/* ---------- Каркас ---------- */
.app { min-height: 100vh; }
.stage { max-width: var(--stage-w); margin: 0 auto; padding: 12px 12px 84px; }
.page-title {
    font-size: 21px; font-weight: 800; letter-spacing: -.01em;
    margin: 8px 2px 14px; text-wrap: balance;
}
.page-title-link { color: inherit; }
.page-title-link:hover { color: var(--accent); }
.sec-title {
    font-size: 13px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--faint); margin: 18px 2px 8px;
}
/* Шапка внутренней страницы канала (лента канала, пост, идеи). */
.page-head { display: flex; align-items: center; gap: 11px; margin: 6px 2px 14px; }
.head-back {
    width: 34px; height: 34px; border-radius: 10px; flex: none;
    display: grid; place-items: center; color: var(--muted); margin-left: -6px;
}
.head-back:hover { background: var(--accent-soft); color: var(--accent); }
.page-head-mid { min-width: 0; }
.page-head-name {
    font-size: 17px; font-weight: 800; letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-head-sub { font-size: 12.5px; color: var(--faint); }

/* ---------- Топбар ---------- */
.topbar {
    position: sticky; top: 0; z-index: 40;
    background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-in {
    max-width: var(--stage-w); margin: 0 auto;
    display: flex; align-items: center; gap: 10px;
    height: 52px; padding: 0 12px;
}
.tb-logo {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 17px; letter-spacing: .01em; color: var(--text);
}
.tb-logo-mark {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--accent); color: var(--accent-ink);
    display: grid; place-items: center; font-size: 16px; font-weight: 800;
}
.tb-env {
    font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
    padding: 2px 7px; border-radius: 5px;
    background: var(--warn-soft); color: var(--warn); text-transform: uppercase;
}
.tb-spacer { flex: 1; }
.tb-btn {
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center; position: relative; color: var(--muted);
}
.tb-btn:hover { background: var(--accent-soft); color: var(--accent); }
.tb-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #5b8def, #7c5bd6);
    color: #fff; font-size: 12.5px; font-weight: 700;
    display: grid; place-items: center;
}
/* счётчик непрочитанного в навигации (обновляет unread-poll.js) */
.nav-n {
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 18px;
    background: var(--danger); color: #fff;
    font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
    display: inline-grid; place-items: center;
}

/* ---------- Меню под аватаром ---------- */
.pop-wrap { position: relative; }
.pop {
    position: absolute; right: 0; top: 44px; z-index: 50; min-width: 220px;
    background: var(--card); border: 1px solid var(--line);
    border-radius: 12px; box-shadow: var(--shadow-pop);
    padding: 6px; display: none;
}
.pop.open { display: block; }
.pop a, .pop button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 10px; border-radius: 8px;
    font-size: 14px; font-weight: 600; color: var(--text); text-align: left;
}
.pop a:hover, .pop button:hover { background: var(--accent-soft); }
.pop .danger { color: var(--danger); }
.pop .danger:hover { background: var(--danger-soft); }
/* Пункт-заглушка (раздел ещё не готов): приглушён и не реагирует на наведение. */
.pop-sep { height: 1px; background: var(--line); margin: 5px 8px; }

/* ---------- Нижние табы (мобильные) ---------- */
.tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--card); border-top: 1px solid var(--line);
    display: flex;
    /* Жёстко фиксируем высоту. Никакого env(safe-area-inset-bottom): на части
       мобильных браузеров (напр. Samsung Internet) он осциллирует при показе/
       скрытии панели браузера — и высота панели «прыгает» вдвое. Фикс-высота +
       overflow:hidden гарантируют, что панель не изменится ни от safe-area, ни
       от переноса подписи. translateZ(0) — свой GPU-слой (сглаживает позицию). */
    height: 56px; overflow: hidden;
    transform: translateZ(0);
    /* Подложка-вынос под панелью (box-shadow не режется overflow:hidden):
       когда браузер прячет свою панель, вьюпорт вырастает вниз и fixed-панель
       догоняет новый низ с задержкой — в просвете мигал фон страницы. Сплошной
       блок цвета панели на ~120px ниже закрывает просвет; саму анимацию
       вьюпорта убрать нельзя (в установленном PWA панели браузера нет и
       эффекта нет вовсе). */
    box-shadow: 0 60px 0 60px var(--card);
}
.tab {
    flex: 1; position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted);
    font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
}
.tab.active { color: var(--accent); }
/* в табе счётчик садится на угол иконки, а не в строку с подписью */
.tab .nav-n { position: absolute; top: 4px; left: calc(50% + 4px); border: 2px solid var(--card); }

/* ---------- Верхняя навигация (десктоп) ---------- */
.tb-nav { display: none; }
@media (min-width: 920px) {
    .stage { max-width: 780px; padding: 20px 24px 60px; }
    .topbar-in { max-width: none; padding: 0 24px; }
    .tabs { display: none; }
    .tb-nav { display: flex; gap: 4px; margin-left: 14px; }
    .tb-link {
        position: relative;
        display: flex; align-items: center; gap: 8px;
        padding: 7px 13px; border-radius: 10px;
        color: var(--muted); font-size: 14px; font-weight: 600;
    }
    .tb-link:hover, .tb-link.active { background: var(--accent-soft); color: var(--accent); }
    .tb-link .icon { width: 19px; height: 19px; }
}

/* ---------- Постоянная колонка каналов (широкий десктоп) ----------
   Колонка появляется только если страница передала список каналов
   (класс .has-chatlist на .app), иначе слева не остаётся пустой полосы. */
.chatlist { display: none; }
@media (min-width: 1120px) {
    .has-chatlist .chatlist {
        display: block; position: fixed; top: 0; bottom: 0; left: 0; z-index: 45;
        width: var(--chatlist-w); overflow-y: auto;
        background: var(--card); border-right: 1px solid var(--line);
    }
    .chatlist-head {
        display: flex; align-items: center; gap: 9px;
        font-size: 18px; font-weight: 700; padding: 12px 16px 10px;
    }
    .chatlist .chat { border-bottom: 0; border-radius: 12px; margin: 0 8px 2px; padding: 10px; }
    .has-chatlist { padding-left: var(--chatlist-w); }
    /* Логотип живёт в шапке колонки — в топбаре его прячем. А кнопку «Каналы»
       оставляем всегда: колонка каналов фильтрует ленту, а кнопка ведёт в
       каталог каналов (main.channels) — это разные вещи. */
    .has-chatlist .tb-logo { display: none; }
    /* фильтр каналов уже есть в колонке — чипы не дублируем */
    .has-chatlist .chips { display: none; }
}

/* ---------- Карточки ---------- */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 14px; box-shadow: var(--shadow);
}
.empty {
    padding: 28px 16px; text-align: center;
    color: var(--muted); font-size: 14.5px;
}

/* ---------- Каналы как «чаты» ---------- */
.chats { overflow: hidden; }
.chat {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; color: var(--text);
    border-bottom: 1px solid var(--line);
}
.chat:last-child { border-bottom: 0; }
.chat:hover { background: var(--accent-soft); }
.chat.active { background: var(--accent); color: var(--accent-ink); }
.chat.active .chat-snippet { color: inherit; opacity: .8; }
.chat .ch-av { width: 48px; height: 48px; font-size: 19px; }
/* Ссылка занимает всю строку, а колокольчик — её сосед: вложенные <a>
   недопустимы, поэтому строка-контейнер и ссылка разделены. */
.chat-link {
    display: flex; align-items: center; gap: 12px;
    flex: 1; min-width: 0; color: inherit;
}
.chat-mid { flex: 1; min-width: 0; }
.chat-link > .icon { color: var(--faint); }
.chat-top { display: flex; align-items: baseline; gap: 8px; }
.chat-name {
    font-size: 15px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-bot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.chat-snippet {
    flex: 1; font-size: 13.5px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-unread {
    flex: none; min-width: 21px; height: 21px; border-radius: 21px; padding: 0 6px;
    background: var(--accent); color: var(--accent-ink);
    font-size: 12px; font-weight: 700; display: grid; place-items: center;
}
.chat.active .chat-unread { background: var(--accent-ink); color: var(--accent); }

/* аватарка канала: буква/эмодзи на фирменном градиенте */
.ch-av {
    width: 38px; height: 38px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 15px;
}
.av-1 { background: linear-gradient(135deg, #f0894f, #d6574f); }
.av-2 { background: linear-gradient(135deg, #4fb0f0, #4f6bd6); }
.av-3 { background: linear-gradient(135deg, #52c07d, #2f9e8f); }
.av-4 { background: linear-gradient(135deg, #b07ae0, #6d54c9); }
.av-5 { background: linear-gradient(135deg, #e8a13c, #c9702a); }

.ch-av-s { width: 34px; height: 34px; font-size: 14px; }
.ch-av-all { background: var(--accent-soft); color: var(--accent); }
.ch-av-all .icon { width: 20px; height: 20px; }
/* Выбранная строка залита accent — инвертируем кружок, иначе синяя звезда
   сливается с синим фоном. */
.chat.active .ch-av-all { background: var(--accent-ink); color: var(--accent); }

/* колокольчик оповещений канала */
.notify-bell {
    flex: none; width: 30px; height: 30px; border-radius: 9px;
    display: grid; place-items: center; color: var(--faint);
}
.notify-bell:hover { background: var(--accent-soft); }
.nb-on { color: var(--accent); }
.nb-pending { color: var(--warn); }

/* ---------- «Закладки»-ярлычки (переключение вкладок-панелей) ---------- */
/* folder-tab на общей линии; активный ярлычок залит цветом карточки и несёт
   акцентную кромку сверху; линия под рядом непрерывна — панель ниже отделена
   отступом, «прорезать» линию в пустоту нельзя. Мобайл-фёрст: узкий ряд
   скроллится вбок. */
.bookmarks {
    display: flex; align-items: flex-end; gap: 4px;
    margin: 14px 0 12px; padding: 0 2px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto; scrollbar-width: none;
}
.bookmarks::-webkit-scrollbar { display: none; }
.btab {
    flex: none; position: relative; display: block;
    padding: 8px 16px; font: inherit; font-size: 13.5px; font-weight: 600;
    color: var(--muted); white-space: nowrap; cursor: pointer;
    text-decoration: none;  /* ярлычок бывает и ссылкой (серверные вкладки) */
    background: none; border: 1px solid transparent; border-bottom: none;
    border-radius: 9px 9px 0 0;
}
.btab:hover:not(.active) { color: var(--text); background: var(--accent-soft); }
.btab.active {
    color: var(--text); background: var(--card);
    border-color: var(--line);
}
.btab.active::before {
    content: ''; position: absolute; inset: -1px -1px auto -1px; height: 3px;
    background: var(--accent); border-radius: 9px 9px 0 0;
}

/* ---------- Чипы-фильтр (лента на узком экране) ---------- */
.chips {
    display: flex; gap: 7px; overflow-x: auto; padding: 2px 2px 10px;
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: none; display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 13px; border-radius: 20px;
    background: var(--card); border: 1px solid var(--line);
    font-size: 13.5px; font-weight: 600; color: var(--muted);
    max-width: 60vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-n {
    padding: 0 6px; border-radius: 10px; font-size: 11.5px; font-weight: 700;
    background: var(--accent-soft); color: var(--accent);
}
.chip.active .chip-n { background: var(--accent-ink); color: var(--accent); }

/* ---------- Лента: карточка поста ---------- */
/* minmax(0,1fr), а не дефолтный auto: иначе широкое медиа (скриншоты) не даёт
   колонке сжаться ниже своей натуральной ширины — карточка распирается шире
   экрана, а нижняя панель (fixed; right:0) тянется за ней. */
.post-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.post-card { min-width: 0; }
.post-card { padding: 12px 14px 10px; }
.post-card, .idea-block {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 14px; box-shadow: var(--shadow);
}
.post-unread { box-shadow: var(--shadow), inset 3px 0 0 var(--accent); }
.post-head { display: flex; align-items: center; gap: 10px; }
.post-head-mid { flex: 1; min-width: 0; }
.post-author {
    display: block; font-size: 14.5px; font-weight: 700; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.post-sub {
    display: flex; align-items: center; gap: 8px;
    font-size: 12.5px; color: var(--faint);
}
.post-date { color: var(--faint); }
.post-date:hover { color: var(--accent); }
.post-pin { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); }
.post-more { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--faint); }
.post-more:hover { background: var(--accent-soft); color: var(--accent); }
.pop-tight { top: 34px; }

/* текст поста: разметка приходит из app/posts/render.py */
.post-text { margin-top: 8px; font-size: 15px; overflow-wrap: anywhere; }
.post-text p { margin-bottom: 8px; }
.post-text a { color: var(--accent); }
.post-text blockquote {
    margin: 8px 0; padding: 2px 0 2px 12px;
    border-left: 3px solid var(--accent); color: var(--muted);
}
.post-text code, .post-text pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13.5px; background: var(--bg); border-radius: 8px;
}
.post-text code { padding: 1px 5px; }
.post-text pre { display: block; padding: 10px 12px; margin: 8px 0; overflow-x: auto; }
.post-text .hashtag { color: var(--accent); }
.post-text .spoiler {
    background: var(--line); color: transparent; border-radius: 4px;
    cursor: pointer; user-select: none;
}
.post-text .spoiler.revealed { background: none; color: inherit; user-select: auto; }

/* медиа поста */
.post-media { margin-top: 10px; border-radius: 12px; overflow: hidden; }
.post-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.post-image-link { display: block; }
.post-image { display: block; width: 100%; height: auto; }
.post-gallery .post-image { height: 100%; max-height: 220px; object-fit: cover; }
.post-media:not(.post-gallery) .post-image { max-height: 560px; object-fit: cover; }
.post-voice { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.post-voice audio { flex: 1; min-width: 0; height: 36px; }
.voice-duration { font-size: 12.5px; color: var(--faint); }
.post-video { position: relative; display: block; line-height: 0; }
.post-video-poster { display: block; width: 100%; height: auto; }
.post-video-play {
    position: absolute; inset: 0; display: grid; place-items: center;
    background: rgba(10, 16, 24, .18);
}
.post-video-play-badge {
    width: 62px; height: 62px; border-radius: 50%;
    background: rgba(10, 16, 24, .58); color: #fff;
    display: grid; place-items: center; padding-left: 4px;
}
.post-video-frame { display: block; width: 100%; max-width: 100%; border: 0; }
.post-video-msg {
    padding: 26px 14px; text-align: center; line-height: 1.5;
    background: var(--bg); color: var(--muted); font-size: 14px;
}

/* подвал поста: реакции слева, ссылка и просмотры справа */
.post-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.post-permalink, .post-views {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12.5px; color: var(--faint);
}
.post-permalink { margin-left: auto; }
.post-permalink:hover { color: var(--accent); }
.post-reactions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.reaction-picker { position: relative; }
.reaction-add {
    width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center; color: var(--faint);
    border: 1px solid var(--line);
}
.reaction-add:hover { color: var(--accent); border-color: var(--accent); }
.reaction-menu {
    position: absolute; bottom: 36px; left: 0; z-index: 50;
    display: flex; flex-wrap: wrap; gap: 2px; width: max-content; max-width: 244px;
    padding: 6px; border-radius: 12px;
    background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
}
.reaction-menu[hidden] { display: none; }
.reaction-pick { width: 34px; height: 34px; border-radius: 9px; font-size: 19px; }
.reaction-pick:hover { background: var(--accent-soft); }
.reaction-btn {
    display: inline-flex; align-items: center; gap: 5px;
    height: 30px; padding: 0 10px; border-radius: 20px;
    background: var(--bg); border: 1px solid var(--line);
    font-size: 13px; font-weight: 600; color: var(--muted);
}
.reaction-btn:hover { border-color: var(--accent); }
.reaction-btn[hidden] { display: none; }  /* реакция без голосов — скрыта */
.reaction-emoji { font-size: 15px; line-height: 1; }
.reaction-mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* служебные элементы ленты */
.feed-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.feed-new-pill {
    position: sticky; top: 62px; z-index: 30;
    display: block; margin: 0 auto 10px; padding: 7px 16px; border-radius: 20px;
    background: var(--accent); color: var(--accent-ink);
    font-size: 13px; font-weight: 700; box-shadow: var(--shadow-pop);
}
.feed-new-pill[hidden] { display: none; }
.feed-sentinel { height: 1px; }

/* блок «Идеи канала»: весь блок — ссылка, правка под «⋯» (см. ideas_block) */
.idea-block { display: flex; align-items: center; gap: 8px; padding: 12px 14px; margin-bottom: 10px; }
.idea-link {
    display: flex; align-items: center; gap: 12px;
    flex: 1; min-width: 0; color: var(--text);
}
.idea-link > .icon:first-child { color: var(--accent); flex: none; }
.idea-link > .icon:last-child { color: var(--faint); flex: none; margin-left: auto; }
.idea-block:hover { background: var(--accent-soft); }
.idea-mid { flex: 1; min-width: 0; }
.idea-title { font-size: 14.5px; font-weight: 700; }
.idea-text { font-size: 13px; }

/* просмотр картинки во весь экран (lightbox.js создаёт разметку сам) */
.lightbox-overlay {
    position: fixed; inset: 0; z-index: 95; display: none;
    align-items: center; justify-content: center; padding: 20px;
    background: rgba(6, 10, 16, .92);
}
.lightbox-overlay.open { display: flex; }
.lightbox-img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.lightbox-close {
    position: absolute; top: 12px; right: 16px;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255, 255, 255, .12); color: #fff; font-size: 26px; line-height: 1;
}
body.lightbox-lock { overflow: hidden; }

/* ---------- Бейджи ---------- */
.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-acc { background: var(--accent-soft); color: var(--accent); }
.b-mut { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* ---------- Кнопки ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border-radius: 10px;
    font-size: 14px; font-weight: 700;
    background: var(--accent); color: var(--accent-ink);
}
.btn:hover { filter: brightness(1.07); }
.btn-o { background: none; border: 1.5px solid var(--line); color: var(--text); }
.btn-o:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-s { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Формы (минимум: поле + строка действий) ---------- */
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); }
.input {
    width: 100%; padding: 10px 12px; border-radius: 10px;
    background: var(--card); border: 1px solid var(--line); color: var(--text);
    font: inherit;
}
.input:focus { outline: none; border-color: var(--accent); }
.field-err { font-size: 12.5px; color: var(--danger); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.field-hint, .hint { font-size: 12.5px; color: var(--muted); }
textarea.input { resize: vertical; min-height: 92px; }
select.input { appearance: none; }
/* Карточка-секция с внутренними отступами (списки-«чаты» и лента — без них). */
.pad { padding: 14px 16px; }
/* Строка-компонент внутри уже отступившей карточки: гасим её боковые поля. */
.flush { padding-left: 0; padding-right: 0; }
.mt { margin-top: 10px; }

.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; margin-bottom: 10px; }
.check input { flex: none; width: 17px; height: 17px; margin-top: 3px; accent-color: var(--accent); }
/* Узкая колонка форм входа/регистрации. */
.auth { max-width: 400px; margin: 0 auto; }
.auth-link { margin-top: 12px; font-size: 13.5px; color: var(--muted); text-align: center; }
.captcha { display: inline-block; padding: 6px 10px; margin-bottom: 8px; border-radius: 10px; background: var(--bg); }

/* ---------- Тоглы ---------- */
.toggle { position: relative; display: inline-block; flex: none; width: 44px; height: 25px; }
.toggle input { position: absolute; width: 0; height: 0; opacity: 0; }
.toggle-slider {
    position: absolute; inset: 0; border-radius: 25px;
    background: var(--line); transition: background .15s;
}
.toggle-slider::before {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 19px; height: 19px; border-radius: 50%;
    background: var(--card); box-shadow: var(--shadow); transition: transform .15s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(19px); }
.toggle input:disabled + .toggle-slider { opacity: .45; }
.toggle-warning input:checked + .toggle-slider { background: var(--warn); }

/* ---------- Пары «метка — значение» ---------- */
.props { display: grid; gap: 6px; }
.prop { display: flex; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.prop > span:first-child { color: var(--muted); }
/* Выравнивание пар «метка—значение» в две колонки (таблицей). */
.props.aligned { grid-template-columns: max-content 1fr; gap: 7px 16px; align-items: baseline; }
.props.aligned .prop { display: contents; }

/* ---------- Таблица (история подписок и т.п.) ---------- */
.table-wrap { overflow-x: auto; }
.utable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.utable th {
    text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line);
    font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--faint); white-space: nowrap;
}
.utable td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.utable tr:last-child td { border-bottom: 0; }

/* Идеи: две разметки в шаблоне. Телефон — список .ideas-cards (горизонты —
   строки-заголовки .ideas-h с легендой «цена интереса», идея в три строки:
   тикер+дата+цена / комментарий / обзор — комментарию вся ширина). На ≥920px
   список прячется и показывается настоящая таблица .ideas-wide с заголовками
   колонок — попытка «раскладывать список grid-колонками» на широкой вёрстке
   читалась хуже таблицы. */
.ideas-wide { display: none; }
.ideas-h {
    display: flex; align-items: baseline; gap: 8px;
    padding: 13px 14px 7px;
    font-size: 12px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--faint);
}
.ideas-h-note {
    margin-left: auto; font-weight: 600;
    letter-spacing: 0; text-transform: none;
}
.idea {
    display: grid; grid-template-columns: auto auto 1fr;
    column-gap: 9px; row-gap: 3px; align-items: baseline;
    padding: 10px 14px 11px; border-top: 1px solid var(--line);
}
.idea-ticker { font-size: 15px; font-weight: 800; letter-spacing: .01em; }
.idea-date { font-size: 12px; color: var(--faint); }
.idea-price {
    justify-self: end; font-size: 14.5px; font-weight: 700;
    white-space: nowrap;
}
.idea-comment {
    grid-column: 1 / -1; font-size: 13.5px; color: var(--muted);
    line-height: 1.45;
}
/* Ссылка «Смотреть обзор»: акцентный цвет (a → --accent) + иконка Play */
.ideas-review-link {
    grid-column: 1 / -1; justify-self: start;
    display: inline-flex; align-items: center; gap: .35em;
    margin-top: 2px; font-size: 13px; font-weight: 600;
    text-decoration: none; white-space: nowrap;
}
.ideas-review-link .icon { width: 15px; height: 15px; }
/* Широкая таблица: горизонты — строки-разделители, даты/цены не переносятся;
   ширина колонок автоматическая, остаток забирает «Комментарий». */
.ideas-table .ideas-group td {
    padding-top: 16px; font-weight: 700; font-size: 14.5px;
    color: var(--text);
}
.ideas-table td.num { white-space: nowrap; }
@media (min-width: 920px) {
    .ideas-cards { display: none; }
    .ideas-wide { display: block; }
}

/* ---------- Шапка канала ---------- */
.ch-hero { display: flex; gap: 14px; padding: 16px; }
.ch-av-lg { width: 62px; height: 62px; font-size: 25px; }
.ch-hero-mid { flex: 1; min-width: 0; }
.ch-name { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.ch-desc { margin-top: 4px; font-size: 14px; color: var(--muted); }
.ch-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ch-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 16px 16px; }
.md { font-size: 14px; }
.md p { margin-bottom: 8px; }
.md ul, .md ol { margin: 8px 0 8px 20px; }

/* ---------- Дисклеймер (предупреждающая карточка, напр. над таблицей идей) ---------- */
.disclaimer {
    border-color: var(--warn);
    background: var(--warn-soft);
    font-size: 13px;
}
.disclaimer :last-child { margin-bottom: 0; }

/* ---------- Строки контактов (оповещения канала) ---------- */
.contact-row {
    display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
    padding: 11px 16px; border-bottom: 1px solid var(--line);
}
.contact-row:last-child { border-bottom: 0; }
.contact-ico { width: 26px; height: 26px; flex: none; }
.contact-mid { flex: 1; min-width: 0; }
.contact-name { font-size: 14.5px; font-weight: 700; }
.contact-val { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.contact-note { flex-basis: 100%; font-size: 12.5px; color: var(--muted); }
.contact-note.warn { color: var(--warn); }

/* ---------- Таблица контактов профиля (3 колонки на гриде) ---------- */
.contact-table { display: grid; }
.ct-head, .ct-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px 150px;
    align-items: center; gap: 10px; padding: 11px 16px;
}
.ct-head { font-size: 12px; font-weight: 700; color: var(--faint); }
.ct-row { border-top: 1px solid var(--line); }
.ct-set, .ct-not { justify-self: center; text-align: center; }
.ct-contact { display: flex; align-items: center; gap: 11px; min-width: 0; }
.ct-note { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
.ct-note.warn { color: var(--warn); }
.ct-add {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 16px; border-top: 1px solid var(--line);
}
.ct-add .contact-mid { flex: 1; }
@media (max-width: 560px) {
    .ct-head { display: none; }
    .ct-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; }
}

/* ---------- Сообщения платформы (отдельные карточки, как посты) ---------- */
.msg-list { display: grid; gap: 10px; }
.msg {
    padding: 12px 16px;
    background: var(--card); border: 1px solid var(--line);
    border-radius: 14px; box-shadow: var(--shadow);
}
.msg-unread { box-shadow: var(--shadow), inset 3px 0 0 var(--accent); }
.msg-meta {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-bottom: 4px; font-size: 12px; color: var(--faint);
}
.msg-title { font-size: 14.5px; font-weight: 700; }
.msg-body { margin-top: 2px; font-size: 14px; color: var(--muted); }
.pager {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; margin-top: 12px; font-size: 13px; color: var(--muted);
}

/* ---------- Документы платформы ---------- */
.doc-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.doc-tile {
    display: flex; align-items: center; gap: 10px; padding: 12px;
    border: 1px solid var(--line); border-radius: 12px;
    color: var(--text); font-size: 13.5px; font-weight: 600;
}
.doc-tile:hover { border-color: var(--accent); }
.doc-tile img { width: 26px; height: 26px; flex: none; }

/* ---------- Тарифы (карточка канала и продающая страница) ---------- */
.tariffs { display: grid; gap: 12px; }
@media (min-width: 720px) {
    .tariffs { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
}
.tariff {
    position: relative; padding: 20px 16px 16px; text-align: center;
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.tariff-featured { border-color: var(--accent); }
.tariff-off { opacity: .6; }
.tariff-badge {
    position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
    padding: 3px 11px; border-radius: 20px; white-space: nowrap;
    font-size: 11.5px; font-weight: 700;
    background: var(--warn-soft); color: var(--warn);
}
.tariff-badge-featured { background: var(--accent); color: var(--accent-ink); }
.tariff-name { font-size: 15px; font-weight: 700; }
.tariff-old { margin-top: 6px; font-size: 13px; color: var(--faint); text-decoration: line-through; }
.tariff-price { margin-top: 2px; font-size: 26px; font-weight: 800; }
.tariff-price span { font-size: 13px; font-weight: 600; color: var(--muted); }
.tariff-total { font-size: 12.5px; color: var(--muted); }
.tariff-gift {
    margin-top: 10px; padding: 8px 10px; border-radius: 10px;
    background: var(--ok-soft); color: var(--ok); font-size: 12.5px; font-weight: 600;
}
.tariff .btn { width: 100%; margin-top: 14px; }

/* ---------- Отдельная страница вне каркаса (тарифы, приветствие) ---------- */
.landing { max-width: 900px; margin: 0 auto; padding: 28px 16px 60px; }
.landing-head { text-align: center; font-size: 14px; color: var(--muted); }
.landing-title {
    margin: 6px 0 22px; text-align: center;
    font-size: 24px; font-weight: 800; letter-spacing: -.01em; text-wrap: balance;
}

/* ---------- Флеш-сообщения ---------- */
.alert {
    padding: 11px 14px; border-radius: 12px; margin-bottom: 10px;
    font-size: 14px; border: 1px solid transparent;
}
/* Плашка после карточки (баннеры «подписка истекает» и т.п. в карточке
   канала/ленте): у .card нет нижнего отступа — без этого правила плашка
   прилипает к блоку выше. Флеш-стек вверху страницы не трогаем. */
.card + .alert { margin-top: 10px; }
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-warning { background: var(--warn-soft); color: var(--warn); }
.alert-info { background: var(--accent-soft); color: var(--accent); }

/* ---------- Модалка подтверждения (разметка <dialog>, поведение confirm.js) ---------- */
.modal {
    width: calc(100% - 40px); max-width: 380px; padding: 20px; margin: auto;
    background: var(--card); color: var(--text);
    border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-pop);
}
.modal::backdrop { background: rgba(10, 16, 24, .5); }
.modal .confirm-text { font-size: 14px; color: var(--muted); margin-bottom: 16px; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Тосты о новых сообщениях (разметку создаёт unread-poll.js) ---------- */
.toast-stack {
    position: fixed; left: 12px; right: 12px; top: 62px; z-index: 85;
    display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
    display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
    padding: 11px 13px; border-radius: 12px; pointer-events: auto;
    background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
}
.toast .t-icon { color: var(--accent); flex: none; line-height: 0; }
.toast .t-icon svg { fill: none; stroke: currentColor; stroke-width: 1.7; }
.toast .t-title { font-size: 14px; font-weight: 700; }
.toast .t-body { font-size: 12.5px; color: var(--muted); }
.toast .t-close { margin-left: auto; padding: 0 4px; color: var(--faint); font-size: 18px; line-height: 1; }
@media (min-width: 920px) {
    .toast-stack { left: auto; right: 20px; width: 340px; }
}

/* ---------- Баннер cookie ---------- */
.cookie-banner {
    position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 80;
    padding: 14px 16px; border-radius: 14px;
    background: var(--card); border: 1px solid var(--line);
    box-shadow: var(--shadow-pop); font-size: 13px; color: var(--muted);
}
.cookie-banner-actions { display: flex; gap: 8px; margin-top: 10px; }
@media (min-width: 920px) {
    .cookie-banner { left: auto; right: 20px; bottom: 20px; max-width: 420px; }
}