:root {
    --primary: #0088cc;
    --primary-hover: #0077b3;
    --bg: #e8ecef;
    --text: #222;
    --text-muted: #777;
    --text-light: #999;
    --white: #fff;
    --card-bg: #fff;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --card-shadow-light: 0 1px 3px rgba(0, 0, 0, 0.06);
    --border: #ddd;
    --border-light: #eee;
    --info-bg: #f5f5f5;
    --error: #e63946;
    --alert-success-bg: #d4edda;
    --alert-success-text: #155724;
    --alert-danger-bg: #f8d7da;
    --alert-danger-text: #721c24;
    --alert-info-bg: #d1ecf1;
    --alert-info-text: #0c5460;
    --alert-warning-bg: #fff3cd;
    --alert-warning-text: #856404;
    --radius: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Баннер среды */
.env-banner {
    text-align: center;
    padding: 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--white);
}
.env-test { background: #e67e22; }
.env-dev { background: #e74c3c; }

/* Навбар */
.navbar {
    background: var(--primary);
    color: var(--white);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    color: var(--white);
    text-decoration: none;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

.navbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: auto; /* меню прижато вправо, к колокольчику и аватару */
    margin-right: 20px;
}

/* Вертикальный разделитель перед админским пунктом «Управление» */
.nav-sep {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.4);
}

.navbar-menu a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 14px;
}

.navbar-menu a:hover {
    color: var(--white);
}

/* Активный раздел (aria-current) — только верхнеуровневые ссылки меню */
.navbar-menu > a.active {
    color: var(--white);
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* Правая часть шапки: колокольчик + аватар (+ бургер на мобильном) */
.navbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.nav-bell {
    position: relative;
    display: flex;
    align-items: center;
    color: var(--white);
    padding: 4px;
}

.nav-bell svg path {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-bell.has-unread .bell-body {
    fill: currentColor;
}

/* Счётчик непрочитанных постов — бейджем на пункте «Лента» */
.nav-feed-link {
    position: relative;
}

.nav-count-badge {
    display: inline-block;
    min-width: 17px;
    margin-left: 5px;
    padding: 0 5px;
    background: #e53935;
    color: #fff;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    vertical-align: middle;
}

.bell-badge {
    position: absolute;
    top: -7px;
    right: -12px;
    min-width: 18px;
    padding: 1px 5px;
    background: #e53935;
    color: #fff;
    border: 2px solid var(--primary);
    border-radius: 11px;
    font-size: 11px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
}

.avatar-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.18);
    color: var(--white);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    flex-shrink: 0;
}

.avatar-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Выпадающие меню шапки (аватар, «Управление») */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    padding: 0;
}

.nav-dropdown-toggle:hover {
    color: var(--white);
}

.nav-menu-pop {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    min-width: 240px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
    padding: 8px;
    z-index: 110;
}

.nav-menu-pop.open {
    display: block;
}

.nav-menu-right {
    left: auto;
    right: 0;
}

/* Единое оформление пунктов выпадающих меню шапки: иконка + подпись */
.navbar .nav-menu-pop a,
.navbar .nav-menu-pop button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    text-decoration: none;
}

/* Кнопка выхода (POST-форма) в меню профиля — сброс дефолтов кнопки. */
.navbar .nav-menu-pop button {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.navbar .nav-menu-pop a:hover,
.navbar .nav-menu-pop button:hover {
    background: var(--info-bg);
    color: var(--text);
}

.navbar .nav-menu-pop a svg,
.navbar .nav-menu-pop button svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.65;
}

.navbar .nav-menu-pop a svg path,
.navbar .nav-menu-pop a svg circle,
.navbar .nav-menu-pop a svg line,
.navbar .nav-menu-pop a svg polyline,
.navbar .nav-menu-pop button svg path,
.navbar .nav-menu-pop button svg circle,
.navbar .nav-menu-pop button svg line,
.navbar .nav-menu-pop button svg polyline {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Алерты */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin: 16px 0;
    font-size: 14px;
}

.alert-success { background: var(--alert-success-bg); color: var(--alert-success-text); }
.alert-danger { background: var(--alert-danger-bg); color: var(--alert-danger-text); }
.alert-info { background: var(--alert-info-bg); color: var(--alert-info-text); }
.alert-warning { background: var(--alert-warning-bg); color: var(--alert-warning-text); }

/* Авторизация */
.auth-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    margin: 40px auto;
    max-width: 400px;
    box-shadow: var(--card-shadow);
}

.auth-card h2 {
    margin-bottom: 24px;
    font-size: 24px;
    text-align: center;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: #555;
    margin-bottom: 4px;
}

.form-group.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group.checkbox label {
    margin-bottom: 0;
}

.form-input,
.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.form-error {
    color: var(--error);
    font-size: 13px;
    margin-top: 4px;
    display: block;
}

.btn {
    display: inline-block;
    padding: 10px 24px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-small {
    padding: 6px 16px;
    font-size: 14px;
}

.btn-outline {
    background: transparent;
    border: 1px solid #ccc;
    color: var(--text-muted);
}

.btn-outline:hover {
    border-color: #999;
    color: #555;
}

.auth-card .btn-primary {
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

/* Кнопки на посадочной странице приглашения — единая ширина, вертикальный стек */
.invite-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.invite-actions .btn {
    width: 100%;
    text-align: center;
}

.auth-link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

.auth-link a {
    color: var(--primary);
}

/* Каналы */
h1 {
    margin: 24px 0 16px;
    font-size: 22px;
}

h2 {
    margin: 32px 0 12px;
    font-size: 18px;
    font-weight: 600;
}

.channel-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

/* Карточка канала: контейнер-плашка, внутри ссылка на канал + опц. колокольчик. */
.channel-card {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--card-bg);
    padding: 14px 16px;
    border-radius: var(--radius);
    transition: background 0.15s;
}

.channel-card:hover {
    background: #f4f4f4;
}

.channel-card-link {
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 0;
}

/* Колокольчик-индикатор оповещений: часть плашки, в её правой части.
   Размер +20% относительно базового шага иконок. */
.notify-bell {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.notify-bell:hover { background: rgba(0, 0, 0, 0.05); }

/* on — чёрный колокольчик без слэша. off — чёрный со слэшем.
   pending — оранжевый со слэшем (привязка Макс не завершена). */
.notify-bell-on { color: var(--text); }
.notify-bell-off { color: var(--text); }
.notify-bell-pending { color: #ef6c00; }

.notify-bell-on .bell-slash { display: none; }

/* В sidebar /feed колокольчик внутри плашки .feed-channel-item, чуть мельче. */
.feed-channel-item .notify-bell {
    width: 29px;
    height: 29px;
}

.feed-channel-item .notify-bell svg {
    width: 18px;
    height: 18px;
}

.channel-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.channel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.channel-avatar span {
    color: var(--white);
    font-size: 20px;
    font-weight: 700;
}

.channel-info {
    flex: 1;
    min-width: 0;
}

.channel-info h3 {
    font-size: 16px;
    margin-bottom: 2px;
}

.channel-info p {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Карточка */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    margin: 24px 0;
    box-shadow: var(--card-shadow);
}

.card h1 {
    margin: 0 0 4px;
}

.section {
    margin-top: 20px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 14px;
}

.text-muted a {
    color: var(--primary);
}

/* Хлебные крошки — единый стиль обратных ссылок (← О проекте,
   ← Все посты канала и т.п.) */
.breadcrumb {
    margin: 4px 0 0;
    font-size: 14px;
}

.breadcrumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary);
}

/* Плитки документов в разделе «О проекте» */
.doc-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.doc-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--info-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.doc-tile:hover {
    border-color: var(--primary);
    box-shadow: var(--card-shadow);
}

.doc-tile-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.doc-tile-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
}

.sub-info p {
    margin: 4px 0;
    font-size: 14px;
}

.info-block {
    background: var(--info-bg);
    padding: 16px;
    border-radius: var(--radius-sm);
}

.info-block h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.info-block p {
    margin: 4px 0;
    font-size: 14px;
    line-height: 1.6;
}

/* Карточки тарифов в блоке оформления подписки */
.tariff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 8px;
}

.tariff-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tariff-card-name {
    font-weight: 600;
}

.tariff-card-price {
    font-size: 20px;
    font-weight: 700;
}

.tariff-card-desc {
    font-size: 13px;
    line-height: 1.5;
    margin: 4px 0;
}

.tariff-card .btn {
    margin-top: auto;
}

/* Спецпредложение — выделяем акцентным цветом */
.tariff-card-spec {
    border-color: var(--accent, #2d7ff9);
    background: var(--alert-info-bg, #eaf3ff);
}

.tariff-card-badge {
    align-self: flex-start;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--accent, #2d7ff9);
}

/* Неактивный тариф: виден, но приглушён серым, кнопка задизейблена. */
.tariff-card-inactive {
    opacity: 0.6;
    filter: grayscale(0.5);
}

/* Задизейбленная кнопка (неактивный тариф и т.п.): серая, без клика. */
.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
    flex-wrap: wrap;
}

.btn-row .btn {
    flex: 1;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.channel-link {
    color: var(--primary);
    font-size: 14px;
    word-break: break-all;
}

.channel-avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 28px;
}

/* Заголовок канала */
.channel-header {
    margin: 24px 0 16px;
}

.channel-header-top {
    display: flex;
    align-items: center;
    gap: 14px;
}

.channel-header h1 {
    margin: 0;
}

.channel-header p {
    color: var(--text-muted);
    font-size: 14px;
}

/* Посты */
.post-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-bottom: 32px;
}

.post-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--card-shadow-light);
    overflow: hidden;
    position: relative;
}

.post-delete-form {
    position: absolute;
    top: 6px;
    right: 8px;
    margin: 0;
}

.post-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    opacity: 0.4;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.post-delete-btn:hover {
    opacity: 1;
    color: #c0392b;
    background: rgba(192, 57, 43, 0.08);
}

.post-edited {
    font-style: italic;
    opacity: 0.7;
}

.post-image-link {
    display: block;
    margin: 8px 0;
    line-height: 0;
}

.post-image-link .post-image {
    width: 100%;
    max-height: 480px;
    object-fit: contain;
    background: #f3f4f6;
    border-radius: var(--radius-sm);
    cursor: zoom-in;
    margin-bottom: 0;
}

/* Альбом (несколько фото) — сетка-галерея */
.post-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    margin: 8px 0;
}

.post-gallery .post-image-link {
    margin: 0;
}

.post-gallery .post-image {
    height: 100%;
    max-height: 320px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
}

/* Закреплённое сообщение */
.post-pinned {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent, #2563eb);
    margin-bottom: 6px;
}

/* Кнопка ручного открепления (только для админа, рядом с бейджем) */
.post-unpin-form {
    display: inline;
    margin: 0 0 0 8px;
}

.post-unpin-btn {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.post-unpin-btn:hover {
    opacity: 1;
    color: #c0392b;
    background: rgba(192, 57, 43, 0.08);
}

/* Голосовые сообщения */
.post-voice {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 8px 0;
}

.post-voice audio {
    flex: 1;
    max-width: 320px;
    height: 40px;
}

/* Светлый фон плеера (Chromium) */
.post-voice audio::-webkit-media-controls-panel {
    background-color: var(--white);
}

.post-voice audio::-webkit-media-controls-enclosure {
    background-color: var(--white);
    border-radius: var(--radius-sm);
}

.voice-duration {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Видео: фасад 16:9 (постер-заглушка) с кнопкой play; по клику JS подменяет
   содержимое на iframe плеера Kinescope. */
.post-video {
    position: relative;
    margin: 8px 0;
    aspect-ratio: 16 / 9;
    width: 100%;
    background-color: #1e2430;
    background-size: cover;
    background-position: center;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

/* Заглушка «обрабатывается»/«недоступно» вместо плеера */
.post-video-msg {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.9rem;
}

.post-video-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.post-video-play svg {
    width: 64px;
    height: 64px;
    opacity: 0.9;
    filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.4));
    transition: transform 0.15s, opacity 0.15s;
}

.post-video-play:hover svg {
    opacity: 1;
    transform: scale(1.08);
}

/* iframe плеера, вставляемый скриптом вместо фасада */
.post-video-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Лайтбокс */
.lightbox-lock {
    overflow: hidden;
}

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
    -webkit-tap-highlight-color: transparent;
}

.lightbox-overlay.open {
    display: flex;
}

.lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-out;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.lightbox-close:hover,
.lightbox-close:focus {
    background: rgba(0, 0, 0, 0.7);
    outline: none;
}

@media (max-width: 600px) {
    .lightbox-overlay {
        padding: 0;
    }
    .lightbox-close {
        top: 8px;
        right: 8px;
    }
}

.post-title {
    font-size: 16px;
    margin-bottom: 8px;
}


.post-text {
    font-size: 15px;
    line-height: 1.6;
    word-break: break-word;
}

/* Гиперссылки в тексте поста: аккуратное подчёркивание-«пунктир», по наведению —
   акцентный цвет и сплошная линия (по образцу ссылок в хлебных крошках). */
.post-text a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
    transition: color 0.12s ease, border-color 0.12s ease;
}

.post-text a:hover {
    color: var(--primary-hover);
    border-bottom-color: currentColor;
}

/* Цитата (blockquote): полоса слева в акцентном цвете + лёгкая подложка. */
.post-text blockquote {
    margin: 8px 0;
    padding: 6px 12px;
    border-left: 3px solid var(--primary);
    background: color-mix(in srgb, var(--primary) 7%, transparent);
    border-radius: 0 6px 6px 0;
}

/* Инлайн-код: моноширинный, тонкая рамка, светлый фон (по образцу Telegram). */
.post-text code {
    font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
    font-size: 0.9em;
    background: var(--info-bg);
    border: 1px solid var(--border-light);
    border-radius: 5px;
    padding: 1px 5px;
}

/* Блок кода (pre): панель с рамкой. white-space: pre-wrap — переносы строк
   приходят как <br> (render заменяет \n), а pre-wrap держит отступы и
   переносит длинные строки. */
.post-text pre {
    font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
    font-size: 0.9em;
    background: var(--info-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    margin: 8px 0;
    overflow-x: auto;
    white-space: pre-wrap;
}

.post-text pre code {  /* code внутри pre — без двойной рамки/фона */
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

/* Спойлер: тёмная плашка с дрожащим точечным «шумом» (как в Telegram).
   Текст скрыт (color: transparent), раскрывается по клику (.revealed). */
.spoiler {
    color: transparent;
    cursor: pointer;
    border-radius: 3px;
    user-select: none;
    background-color: #8a9099;
    /* Три слоя точек с некратными размерами — регулярная сетка не видна,
       получается «шум» с пространством между крупинками. Каждый слой
       прыгает своим, несовпадающим путём — движение хаотичное. */
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, 0.9) 0.8px, transparent 1px),
        radial-gradient(circle, rgba(255, 255, 255, 0.65) 0.8px, transparent 1px),
        radial-gradient(circle, rgba(0, 0, 0, 0.45) 0.8px, transparent 1px);
    background-size: 5px 5px, 7px 7px, 6px 6px;
    animation: spoiler-noise 0.9s steps(6) infinite;
    transition: filter 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

@keyframes spoiler-noise {
    0%   { background-position: 0 0,    0 0,    0 0; }
    16%  { background-position: 3px 2px, -4px 3px, 2px -4px; }
    33%  { background-position: -2px 4px, 5px -2px, -5px 1px; }
    50%  { background-position: 4px -3px, -3px -4px, 3px 5px; }
    66%  { background-position: -4px -2px, 2px 4px, -1px -3px; }
    83%  { background-position: 1px 3px, -5px -1px, 4px 2px; }
    100% { background-position: 0 0,    0 0,    0 0; }
}

.spoiler.revealed {
    color: inherit;
    background: transparent;
    filter: none;
    animation: none;
    user-select: auto;
}

/* Уважаем prefers-reduced-motion: точки остаются, дрожание выключаем. */
@media (prefers-reduced-motion: reduce) {
    .spoiler { animation: none; }
}

.hashtag {
    color: var(--primary);
    font-weight: 500;
}

.post-date {
    font-size: 12px;
    color: var(--text-light);
}

/* Дата поста + иконка-ссылка на отдельную страницу поста */
.post-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.post-link-btn {
    display: inline-flex;
    color: var(--text-light);
    transition: color 0.15s;
}

.post-link-btn svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.post-link-btn:hover { color: var(--primary); }

/* Подвал поста: дата + счётчик просмотров */
.post-footer {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.post-views {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-light);
}

.post-views svg { opacity: 0.7; }

/* Реакции на пост */
.post-reactions {
    position: relative;          /* якорь для всплывающего меню выбора */
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

/* Кнопка-«смайлик» с всплывающим меню выбора реакции */
.reaction-picker {
    display: inline-flex;
}

.reaction-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: var(--card-bg);
    color: var(--text-light);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.reaction-add:hover { background: var(--border-light); color: var(--primary); }

.reaction-add svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Меню выбора — одна горизонтальная строка во всю ширину бара реакций
   (при нехватке места — горизонтальная прокрутка, а не перенос в высоту:
   .post-card имеет overflow:hidden и урезал бы высокое меню сверху). */
.reaction-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 20;
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    max-width: 100%;
    overflow-x: auto;
    padding: 6px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--card-bg);
    box-shadow: var(--card-shadow);
}

.reaction-menu[hidden] { display: none; }

.reaction-pick {
    flex: 0 0 auto;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 4px;
    border-radius: 8px;
    transition: background 0.15s, transform 0.1s;
}

.reaction-pick:hover { background: var(--border-light); transform: scale(1.15); }

.reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: var(--card-bg);
    cursor: pointer;
    font-size: 15px;
    line-height: 1.2;
    transition: background 0.15s, border-color 0.15s;
}

/* Класс задаёт display:inline-flex — гасим скрытые (непоставленные) явно. */
.reaction-btn[hidden] { display: none; }

.reaction-btn:hover { background: var(--border-light); }

.reaction-btn:disabled { opacity: 0.6; cursor: default; }

.reaction-btn.reaction-mine {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.reaction-count {
    font-size: 12px;
    color: var(--text-light);
    min-width: 8px;
}

.reaction-btn.reaction-mine .reaction-count { color: var(--primary); }

/* Непрочитанный пост — цветная левая грань */
.post-card.post-unread {
    box-shadow: inset 3px 0 0 0 var(--primary), var(--card-shadow-light);
}

/* Бейдж непрочитанного у канала в sidebar ленты */
.feed-unread-badge {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    margin-left: 4px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    vertical-align: middle;
}

/* Сентинел бесконечного скролла (невидимый триггер подгрузки) */
.feed-sentinel { height: 1px; }

/* Панель действий над лентой (отметить всё прочитанным) */
.feed-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

/* Плашка «↑ N новых постов» автообновления ленты */
.feed-new-pill {
    display: block;
    width: 100%;
    margin-bottom: 12px;
    padding: 8px 16px;
    border: none;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--card-shadow-light);
    transition: background 0.15s;
}

/* Класс задаёт display:block, поэтому UA-правило [hidden]{display:none}
   перебивается — гасим плашку явно, пока новых постов нет. */
.feed-new-pill[hidden] { display: none; }

.feed-new-pill:hover { background: var(--primary-hover); }

/* Пустое состояние */
.empty-state {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-light);
    font-size: 15px;
}

.empty-state a {
    color: var(--primary);
}

/* Лента */
.feed-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-top: 16px;
}

.feed-sidebar {
    width: 220px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 64px;
}

.feed-channel-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 10px;
    transition: background 0.15s;
}

.feed-channel-item:hover {
    background: var(--card-bg);
}

.feed-channel-item.selected {
    background: var(--card-bg);
    font-weight: 600;
}

.feed-channel-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 0;
}

.feed-channel-item .channel-avatar {
    width: 36px;
    height: 36px;
    font-size: 15px;
}

.feed-channel-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.feed-channel-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-channel-status {
    font-size: 12px;
}

.feed-channel-status.active { color: var(--primary); }
.feed-channel-status.inactive { color: var(--error); }
.feed-channel-status.not-linked { color: var(--text-light); }

.feed-posts {
    flex: 1;
    min-width: 0;
}

.post-channel-tag {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 6px;
}

/* Иконка контакта (профиль, заголовки блоков) */
.contact-icon {
    width: 20px;
    height: 20px;
    vertical-align: -4px;
    margin-right: 4px;
}

/* Блоки на странице восстановления пароля */
.reset-block {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.reset-block:last-of-type {
    border-bottom: none;
}
.reset-block h3 {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.reset-block h3 .contact-icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-right: 4px;
}
/* Одинаковая ширина для кнопок «Отправить по email» / «Отправить в Макс» */
.reset-submit {
    min-width: 200px;
    text-align: center;
}

/* Таблица контактов в профиле */
/* Таблица истории подписок в карточке канала (пользовательский интерфейс) */
.sub-history-wrap {
    overflow-x: auto;
}
.sub-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.sub-history-table th,
.sub-history-table td {
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.sub-history-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13px;
}
.sub-history-table .cell-nowrap {
    white-space: nowrap;
}

/* Список контактов в профиле: карточка на контакт, регулярная структура.
   Строка 1 (head): иконка + тип/значение, справа тогл системных уведомлений.
   Строка 2 (body): статус слева, кнопки действий справа в ряд; на узких
   экранах body складывается в столбик, кнопки — на всю ширину. */
.contacts-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.contact-list {
    display: flex;
    flex-direction: column;
}
.contact-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.contact-card:last-child {
    border-bottom: none;
}
.contact-head {
    display: flex;
    align-items: center;
    gap: 8px;
}
.contact-head .contact-main {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}
.contact-sys-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    flex: 0 0 auto;
}
.contact-sys-label {
    font-size: 13px;
}
.contact-body {
    display: flex;
    align-items: center;
    gap: 8px 12px;
    flex-wrap: wrap;
    /* статус выравнивается по левому краю текста head (под иконкой 20px+8px) */
    padding-left: 28px;
}
.contact-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-wrap: wrap;
}
.contact-actions form {
    margin: 0;
}
.contact-actions .btn {
    min-width: 130px;
    text-align: center;
}
@media (max-width: 600px) {
    .contact-body {
        flex-direction: column;
        align-items: stretch;
        padding-left: 0;
    }
    .contact-actions {
        flex-direction: column;
        margin-left: 0;
        align-items: stretch;
    }
    .contact-actions .btn,
    .contact-actions form {
        width: 100%;
        min-width: 0;
    }
    .contact-actions form .btn {
        width: 100%;
    }
}
.contacts-input {
    width: 100%;
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    line-height: 1.5;
}
.contacts-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Ручной ввод кода приглашения (карточка канала и каталог /channels) */
.invite-redeem-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.invite-redeem-form .contacts-input {
    width: auto;
    flex: 1 1 220px;
}
.invite-redeem-block {
    margin-bottom: 24px;
}

/* Журнал приглашений (админка): код, ссылка для копирования */
.invite-code {
    font-weight: 600;
    font-size: 14px;
}
.invite-link-row {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
}
.invite-link-input {
    flex: 1 1 260px;
    min-width: 0;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
}
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
}
.btn-icon:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

/* Детали приглашения: список «ключ — значение» */
.detail-list {
    margin: 16px 0;
}
.detail-list > div {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.detail-list dt {
    flex: 0 0 160px;
    color: var(--text-muted);
}
.detail-list dd {
    margin: 0;
}

/* Форма приглашения: переключатель режима и подсказки */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}
.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-weight: normal;
}
.radio-option input {
    margin-top: 3px;
}
.radio-option-body {
    display: flex;
    flex-direction: column;
}
.radio-option-body .form-hint {
    margin-top: 1px;
}
.form-hint {
    display: block;
    font-size: 12px;
    margin-top: 4px;
}

/* Статусы контактов (профиль, карточка канала) */
.contact-verified {
    color: var(--primary);
    font-size: 13px;
}

.contact-unverified {
    color: var(--error);
    font-size: 13px;
}

/* Бот заблокирован — оповещения включены, но не доходят */
.contact-blocked {
    color: #d17b1a;
    font-size: 13px;
}

/* Формы редактирования */
.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.form-textarea-lg {
    min-height: 160px;
}

.current-logo {
    margin-bottom: 8px;
}

.current-logo img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}

/* Markdown-контент */
.markdown-content p {
    margin: 4px 0;
    font-size: 14px;
    line-height: 1.6;
}

.markdown-content ul,
.markdown-content ol {
    margin: 4px 0 4px 20px;
    font-size: 14px;
}

.markdown-content a {
    color: var(--primary);
}

/* Таблица действий провайдера */
.actions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}
.actions-table tr + tr {
    border-top: 1px solid var(--border-light);
}
.actions-table td {
    padding: 10px 0;
    vertical-align: middle;
}
.actions-table-btn {
    white-space: nowrap;
    padding-right: 16px !important;
    width: 1%;
}
.actions-table-btn .btn {
    width: 100%;
    text-align: center;
}
.actions-table-desc {
    color: var(--text-muted);
    font-size: 14px;
}

/* Карточка пользователя в списке подписчиков канала */
.user-card {
    align-items: flex-start;
    cursor: default;
}

.user-card:hover {
    background: var(--card-bg);
}

.user-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.user-head h3 {
    margin: 0;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--border-light);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.user-fio {
    font-size: 14px;
    margin-top: 2px;
}

.user-contacts {
    font-size: 13px;
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}

.user-contact {
    white-space: nowrap;
}

.user-meta {
    font-size: 12px !important;
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}

.user-meta span {
    white-space: nowrap;
}

.user-subs {
    font-size: 12px;
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
}

.user-sub {
    white-space: nowrap;
}

/* Шапка карточки канала с кнопкой управления справа */
.channel-header-with-action {
    align-items: flex-start;
}

.channel-header-info {
    flex: 1;
    min-width: 0;
}

.channel-description {
    white-space: pre-line;
}

.channel-manage-btn {
    flex-shrink: 0;
    align-self: center;
    white-space: nowrap;
}

.channel-header-actions {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    min-width: 180px;
}

.channel-header-actions .btn {
    text-align: center;
    white-space: nowrap;
}

.channel-header-actions form {
    margin: 0;
}

.channel-header-actions form .btn {
    width: 100%;
}

.channel-admin-note {
    font-size: 13px;
    text-align: center;
    margin-top: 4px;
}

/* Плашки канала: тип доступа (открытый/закрытый), тип подписки (платная/бесплатная) */
.channel-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    vertical-align: middle;
    white-space: nowrap;
}
.channel-badge-closed { background: var(--alert-warning-bg); color: var(--alert-warning-text); }
.channel-badge-open   { background: var(--info-bg); color: var(--text-muted, #6c757d); }
.channel-badge-paid   { background: var(--alert-info-bg); color: var(--alert-info-text); }
.channel-badge-free   { background: var(--alert-success-bg); color: var(--alert-success-text); }

/* Плашки в карточке каталога — отдельной строкой под описанием */
.channel-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

/* Ссылки под шапкой канала (исходный канал, посты на сайте) */
.channel-header-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    margin-top: 4px;
    padding-left: 78px;  /* отступ под аватар (64 + 14 gap) */
}

/* Компактный блок подписки */
.sub-headline {
    font-weight: 600;
    margin-bottom: 8px;
}

.sub-info {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
    font-size: 14px;
    margin: 4px 0;
}

.info-row {
    font-size: 14px;
    margin: 4px 0;
}

.sub-unlink-form {
    margin-top: 14px;
}

.pending-order {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
    padding: 8px 0;
}

/* Блок автопродления в «Ваша подписка» (карточка канала) */
.auto-renew-block {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e8e8e8;
}
.auto-renew-block form {
    margin: 0;
}
/* Строка тумблера автопродления вплотную к границе блока */
.auto-renew-block .confirm-renew-row {
    margin: 0 0 8px;
}
/* Кнопка удаления привязанной карты (выключенное автопродление) */
.auto-renew-block .card-delete {
    margin-top: 8px;
}

/* Заголовок блока с действием справа */
.block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.block-header h3 {
    margin: 0;
}

.block-header form {
    margin: 0;
}

/* Блок управления оповещениями (карточки .contact-card, как в профиле).
   Pending-состояние: транспорт включён, но контакт не привязан. */
.notify-warning {
    color: #b07d00;
    font-size: 13px;
}

/* Админские уведомления канала (дашборд /manage): строка контакт + тогл */
.admin-notify-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.admin-notify-row:last-child {
    border-bottom: none;
}
.admin-notify-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-wrap: anywhere;
}
.admin-notify-main .text-muted {
    font-size: 13px;
}

/* Строка автопродления в форме подтверждения оплаты (тогл как у оповещений) */
.confirm-renew-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
}

.confirm-renew-label {
    flex: 1;
    min-width: 0;
}

/* iOS-style toggle */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    transition: background 0.2s;
    cursor: pointer;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 2px;
    background: var(--white);
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle input:disabled + .toggle-slider {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Warning-toggle: включён, но доставка невозможна (контакт не привязан) */
.toggle.toggle-warning input:checked + .toggle-slider {
    background: #f0ad4e;
}

/* =============================================
   Адаптивность — планшет (≤768px)
   ============================================= */
@media (max-width: 768px) {
    /* Бургер-меню */
    .navbar-toggle {
        display: block;
    }

    .navbar-menu {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary);
        padding: 8px 0;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        z-index: 99;
    }

    .navbar-menu.open {
        display: flex;
    }

    .navbar-menu a {
        padding: 10px 20px;
        font-size: 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-menu a:last-child {
        border-bottom: none;
    }

    .navbar-menu {
        margin-left: 0;
        margin-right: 0;
    }

    .nav-sep {
        display: none;
    }

    /* «Управление» внутри бургера: не поповер, а обычные пункты списка */
    .navbar-menu .nav-dropdown {
        width: 100%;
    }

    .navbar-menu .nav-dropdown-toggle {
        display: block;
        width: 100%;
        text-align: left;
        padding: 10px 20px;
        font-size: 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-menu .nav-menu-pop {
        position: static;
        min-width: 0;
        background: none;
        box-shadow: none;
        padding: 0;
    }

    .navbar .navbar-menu .nav-menu-pop a,
    .navbar .navbar-menu .nav-menu-pop button {
        color: rgba(255, 255, 255, 0.85);
        padding: 10px 20px 10px 28px;
        border-radius: 0;
    }

    .navbar .navbar-menu .nav-menu-pop a:hover,
    .navbar .navbar-menu .nav-menu-pop button:hover {
        background: rgba(255, 255, 255, 0.08);
        color: var(--white);
    }

    .navbar .container {
        position: relative;
    }

    /* Лента — сайдбар сверху */
    .feed-layout {
        flex-direction: column;
    }

    .feed-sidebar {
        width: 100%;
        position: static;
        flex-direction: row;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .feed-channel-item {
        flex-shrink: 0;
        min-width: 0;
        padding: 8px 12px;
    }

    .feed-channel-info {
        display: none;
    }

    .feed-channel-item .channel-avatar {
        width: 40px;
        height: 40px;
    }

    /* Карточка канала */
    .card {
        padding: 16px;
        margin: 16px 0;
    }

    .auth-card {
        padding: 24px 16px;
        margin: 24px auto;
    }

    /* Кнопки в ряд — стековать */
    .btn-row {
        flex-direction: column;
    }

    .btn-row .btn {
        flex: none;
        width: 100%;
    }

    /* Таблица действий — вертикальный стек */
    .actions-table,
    .actions-table tbody,
    .actions-table tr,
    .actions-table td {
        display: block;
        width: 100%;
    }

    .actions-table tr {
        padding: 12px 0;
    }

    .actions-table tr + tr {
        border-top: 1px solid var(--border-light);
    }

    .actions-table-btn {
        padding-right: 0 !important;
        padding-bottom: 8px;
        width: 100%;
    }

    .actions-table-btn .btn {
        width: 100%;
    }

    /* Заголовок канала */
    .channel-header-top {
        gap: 10px;
    }

    .channel-avatar-lg {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }

    .channel-header-links {
        padding-left: 0;
    }

    .channel-manage-btn {
        align-self: flex-start;
    }

    .channel-header-with-action {
        flex-wrap: wrap;
    }

    .channel-header-actions {
        width: 100%;
        min-width: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-top: 8px;
    }

    .channel-header-actions .btn {
        width: 100%;
    }

    .channel-admin-note {
        margin-top: 0;
        text-align: left;
        flex-basis: 100%;
        order: -1;
    }
}

/* =============================================
   Адаптивность — смартфон (≤480px)
   ============================================= */
@media (max-width: 480px) {
    .container {
        padding: 0 12px;
    }

    h1 {
        font-size: 20px;
        margin: 16px 0 12px;
    }

    .auth-card {
        padding: 20px 14px;
        margin: 16px auto;
        border-radius: var(--radius-sm);
    }

    .auth-card h2 {
        font-size: 20px;
    }

    .card {
        padding: 14px;
        border-radius: var(--radius-sm);
    }

    .btn {
        padding: 10px 16px;
        font-size: 15px;
    }

    .channel-card {
        padding: 12px;
        gap: 10px;
    }

    .channel-avatar {
        width: 40px;
        height: 40px;
    }

    .channel-avatar span {
        font-size: 18px;
    }

    .post-card {
        padding: 12px;
    }

    .info-block {
        padding: 12px;
    }

    .empty-state {
        padding: 32px 12px;
    }

    /* Сайдбар ленты — только аватарки */
    .feed-sidebar {
        gap: 6px;
    }

    .feed-channel-item {
        padding: 6px 8px;
    }
}
/* ── Типовая админ-таблица (CRUD) ─────────────────────────────── */
.admin-table-wrap {
    overflow-x: auto;
    margin: 16px 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.admin-table thead th {
    font-weight: 600;
    color: var(--text-muted);
    background: #fafafa;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.admin-table tbody tr:hover {
    background: #fafafa;
}

/* Ссылки в таблице — фирменный цвет без дефолтного подчёркивания */
.admin-table a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.admin-table a:hover {
    text-decoration: underline;
}

.admin-table .cell-nowrap { white-space: nowrap; }
.admin-table .cell-actions { white-space: nowrap; text-align: right; }

.admin-table .cell-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Бейджи признаков и статуса действия */
.tag {
    display: inline-block;
    padding: 1px 7px;
    margin-right: 4px;
    border-radius: 10px;
    font-size: 12px;
    background: #eef3f8;
    color: #456;
    white-space: nowrap;
}

.tag-muted { background: #eee; color: var(--text-muted); }

.status-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
}

.status-active { background: #e6f4ea; color: #1e7e34; }
.status-planned { background: #fff3cd; color: #8a6d3b; }
.status-expired { background: #f1f1f1; color: #888; }
.status-off { background: #fbe4e4; color: #b02a2a; }

/* Ручной выключатель тарифа (active=false): приглушаем строку списка. */
.admin-table tr.row-inactive td { opacity: 0.55; }

/* Статистика по миграции (временно) — колонки-блоки (админка) */
.migration-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
}
/* Жёсткие 2 колонки (схлопываются в 1 на узких экранах) */
.migration-grid--2col { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 600px) {
    .migration-grid--2col { grid-template-columns: 1fr; }
}
/* Разделитель и общий заголовок блока «Миграция tbot → канал» */
.migration-divider {
    border: 0;
    border-top: 1px solid var(--border-color, #ddd);
    margin: 22px 0 14px;
}
.migration-section-head {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
}
.migration-col h4 {
    margin: 0 0 6px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.migration-col > p {
    margin: 0 0 6px;
    font-size: 15px;
}
.migration-sub {
    margin: 0;
    padding-left: 18px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
}

/* Воронка миграции — горизонтальная стек-шкала */
.migration-funnel { margin-top: 22px; }
.migration-funnel h4 {
    margin: 0 0 10px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.mig-bar {
    display: flex;
    height: 26px;
    border-radius: 6px;
    overflow: hidden;
    background: #eee;
}
.mig-seg { height: 100%; }
.mig-bar .mig-seg + .mig-seg,
.mig-bar .mig-group + .mig-seg,
.mig-bar .mig-seg + .mig-group { box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.5); }
/* Группа «Вошли в канал» — один общий сегмент с подсегментами внутри;
   тёмная рамка явно выделяет группу среди верхнеуровневых сегментов */
.mig-group { display: flex; height: 100%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.55); }
.mig-group .mig-seg + .mig-seg { box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.5); }
/* Скобка-подпись под градусником, повторяет ширину группы «Вошли в канал» */
.mig-bracket-row { display: flex; margin-top: 5px; }
.mig-bracket-spacer { flex-shrink: 0; }
.mig-bracket {
    flex-shrink: 0;
    box-sizing: border-box;
    border-top: 2px solid rgba(0, 0, 0, 0.55);
    padding-top: 3px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Вторая скобка «Пользователи tghub» — цвет tghub-сегментов, чтобы не сливалась с первой */
.mig-bracket--tghub { border-top-color: #3fb6a8; color: #2a8c81; }
/* Число скобки — на отдельной строке под подписью */
.mig-bracket-num { display: block; font-weight: 700; }
/* Верхняя скобка «Активные подписчики» — над баром, штрих снизу (указывает на бар) */
.mig-bracket-row--top { margin-top: 0; margin-bottom: 5px; align-items: flex-end; }
.mig-bracket--top {
    border-top: 0;
    border-bottom: 2px solid rgba(0, 0, 0, 0.55);
    padding-top: 0;
    padding-bottom: 4px;
}
.mig-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-top: 12px;
    font-size: 13px;
}
.mig-legend-item { display: flex; align-items: center; gap: 6px; }
/* Первый ряд легенды — верхнеуровневая партиция в одну строку */
.mig-legend-row { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px 18px; }
/* Группа легенды «Активные подписчики»: своя строка, заголовок + подсегменты с отступом */
.mig-legend-group { flex-basis: 100%; display: flex; flex-direction: column; gap: 6px; }
.mig-legend-head { font-weight: 600; }
.mig-legend-sub { margin-left: 18px; }
.mig-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
/* Дот «Активные подписчики» — мини-склейка из цветов четырёх подсегментов */
.mig-dot--active {
    background: linear-gradient(90deg, #6c757d 0 25%, #28a745 25% 50%, #5b9bd5 50% 75%, #3fb6a8 75% 100%);
}
.mig-funnel-note { margin: 10px 0 0; font-size: 12px; }

/* Цвета сегментов: серые = «не проблема»/серая зона, цветные = вовлечённые */
.mig-seg--blocked    { background: #cfd4da; }   /* заблокировали — не проблема */
.mig-seg--notentered { background: #f0ad4e; }   /* не вошли — будем добирать */
.mig-seg--gray       { background: #6c757d; }   /* серая зона — проблемные */
.mig-seg--good       { background: #28a745; }   /* tghub + tbot — отлично */
.mig-seg--lost       { background: #5b9bd5; }   /* бывшие telegram, сидят на tghub */
.mig-seg--ok         { background: #3fb6a8; }   /* только tghub — хорошо */

/* Пагинация */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 16px 0;
}

.pager-link {
    padding: 6px 14px;
    border: 1px solid #ccc;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 14px;
}

.pager-link:hover { border-color: #999; color: #555; }
.pager-disabled { opacity: 0.4; pointer-events: none; }
.pager-info { font-size: 14px; color: var(--text-muted); }

/* Две колонки в форме (узкие поля рядом) */
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

@media (max-width: 600px) {
    .form-row { flex-direction: column; gap: 0; }
}

/* ── Дашборд канала: плитки ────────────────────────────────────── */
.dashboard-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.tile {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tile-head {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.tile-metric {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.tile-num {
    font-size: 34px;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}

.tile-num-label {
    font-size: 14px;
    color: var(--text-muted);
}

/* Второстепенные цифры (всего/неактивных) — мельче основной */
.tile-subs {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 13px;
    color: var(--text-muted);
    min-height: 18px;
}

.tile-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

/* Кнопки в плитке — одинаковой ширины (на всю плитку) */
.tile-actions .btn {
    width: 100%;
    text-align: center;
    box-sizing: border-box;
}

/* Шапка раздела управления каналом (channel_admin_header) */
.ca-header h1 {
    margin: 0;
}

.ca-header .channel-description {
    margin: 4px 0 0;
    font-size: 15px;
}

/* Компактная шапка подраздела: аватар + имя, без описания и кнопок */
.ca-header-compact {
    align-items: center;
    gap: 12px;
}

.ca-header-compact-name {
    margin: 0;
    font-size: 20px;
    min-width: 0;
    word-break: break-word;
}

/* Заголовок секции с действием справа (напр. «Тарифы канала» + «Создать») */
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
}

.section-head h2 {
    margin: 0;
}

/* ── Хлебные крошки ────────────────────────────────────────────── */
.breadcrumbs {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.breadcrumbs a {
    color: var(--text-muted);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.breadcrumb-sep { margin: 0 8px; color: #bbb; }
.breadcrumb-current { color: var(--text); }

/* ── Сегментированный фильтр (все/активные/неактивные) ─────────── */
/* Строка поиска админ-списков (подписчики и т.п.) */
.admin-search {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 4px 0 16px;
    flex-wrap: wrap;
}
.admin-search .form-control { flex: 1 1 260px; max-width: 420px; }

.filter-tabs {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin: 4px 0 16px;
}

.filter-tab {
    padding: 6px 16px;
    font-size: 14px;
    text-decoration: none;
    color: var(--text-muted);
    border-right: 1px solid var(--border);
}

.filter-tab:last-child { border-right: none; }
.filter-tab:hover { background: #fafafa; }

.filter-tab-on {
    background: var(--primary);
    color: var(--white);
}

.filter-tab-on:hover { background: var(--primary-hover); }

/* === Уведомления (portal-лента /messages; колокол в шапке — см. «Навбар») === */

/* Тосты — всплывающие уведомления в углу открытой вкладки (navbar.js) */
.toast-stack {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    animation: toast-in 0.25s ease-out;
}

@keyframes toast-in {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .toast { animation: none; }
}

.toast .t-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

/* белый колокольчик, как в шапке */
.toast .t-icon svg path {
    fill: #fff;
    stroke: #fff;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.toast .t-title {
    font-size: 14px;
    font-weight: 600;
}

.toast .t-body {
    font-size: 13px;
    color: var(--text-muted);
}

.toast .t-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
}

/* Модальный диалог подтверждения (confirm.js) */
.confirm-dialog {
    /* margin: auto центрирует модалку — глобальный ресет * { margin: 0 }
       иначе прижимает <dialog> в левый верхний угол. */
    margin: auto;
    border: none;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 380px;
    width: calc(100% - 32px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    color: var(--text);
    background: var(--card-bg);
}

.confirm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.confirm-text {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-actions .btn { font-size: 15px; }

.btn-danger {
    background: var(--error);
    color: var(--white);
}

.btn-danger:hover { background: #c92d3a; }

.messages-list { display: flex; flex-direction: column; gap: 12px; }

.message-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
}

.message-unread { border-left: 3px solid var(--primary); background: #f4faff; }

.message-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.message-kind {
    background: #eef3f7;
    border-radius: 4px;
    padding: 1px 8px;
}

.message-new {
    background: var(--primary);
    color: #fff;
    border-radius: 4px;
    padding: 1px 8px;
    font-size: 12px;
}

.message-title { font-weight: 600; margin-bottom: 4px; }

.message-author { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }

.message-body { white-space: pre-line; }

.message-action { margin-top: 8px; }

.messages-pager {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

/* Продающая страница тарифов (/channel/<id>/tariffs) — отдельный чистый
   макет без портальной навигации */
.landing-body {
    background: linear-gradient(180deg, #f7fafc 0%, #e9eef5 100%);
    min-height: 100vh;
}

.landing {
    max-width: 1000px;
    margin: 0 auto;
    padding: 48px 16px 64px;
    text-align: center;
}

.landing-alert {
    max-width: 640px;
    margin: 0 auto 20px;
    text-align: left;
}

.landing-channel {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
}

.landing-title {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.landing-subtitle {
    color: var(--text-muted);
    font-size: 17px;
}

.landing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    align-items: stretch;
    margin-top: 36px;
}

.landing-card {
    position: relative;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(20, 40, 80, 0.08);
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Неактивный тариф на продающей странице: виден, но серый; кнопка задизейблена. */
.landing-card-inactive {
    opacity: 0.6;
    filter: grayscale(0.6);
}

/* Основной тариф: рамка, усиленная тень, приподнят на десктопе. */
.landing-card-featured {
    border: 2px solid var(--primary);
    box-shadow: 0 18px 44px rgba(20, 60, 140, 0.20);
    padding-top: 34px;
    z-index: 1;
}

.landing-badge {
    background: var(--alert-info-bg);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 999px;
    padding: 5px 14px;
}

/* Плашка основного тарифа — поверх верхней границы карточки, синяя со звездой. */
.landing-badge-featured {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(20, 60, 140, 0.30);
}

.landing-badge-icon {
    margin-top: -1px;
}

.landing-name {
    font-size: 20px;
    font-weight: 700;
    margin-top: 4px;
}

.landing-old-price {
    position: relative;
    display: inline-block;
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
}

/* Диагональное зачёркивание: горизонтальная линия перекрывала середину цифр
   (0/9, 6/8 нечитаемы), наклонная пересекает под углом и не мешает читать. */
.landing-old-price::after {
    content: "";
    position: absolute;
    left: -3px;
    right: -3px;
    top: 50%;
    height: 2px;
    background: var(--error);
    transform: rotate(-12deg);
    transform-origin: center;
    pointer-events: none;
}

.landing-price {
    font-size: 40px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
}

.landing-price span {
    font-size: 20px;
    font-weight: 700;
}

.landing-total {
    background: var(--info-bg);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 14px;
    font-weight: 600;
}

.landing-saving {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    background: var(--alert-success-bg);
    color: var(--alert-success-text);
    border-radius: 12px;
    padding: 10px 14px;
    text-align: center;
}

.landing-gift {
    flex-shrink: 0;
}

.landing-saving-text {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
}

.landing-desc {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.landing-renew {
    font-size: 13px;
    color: var(--text-light);
    margin: 0;
}

.landing-btn {
    margin-top: auto;
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border-radius: 10px;
}

/* Промежуточная страница «войдите или зарегистрируйтесь» (subscribe_welcome) */
.landing-welcome {
    max-width: 520px;
    margin: 36px auto 0;
    gap: 16px;
}

.landing-welcome-tariff {
    font-size: 14px;
    color: var(--text-muted);
}

.landing-welcome-text {
    font-size: 16px;
    line-height: 1.55;
    margin: 0;
}

.landing-welcome-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

.landing-welcome-actions .landing-btn { margin-top: 0; }

@media (max-width: 640px) {
    .landing { padding-top: 32px; }
    .landing-title { font-size: 28px; }
    .landing-welcome-actions { flex-direction: column; }
}

/* --- Согласия: cookie-баннер и чекбоксы документов --- */

.cookie-banner {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    z-index: 1000;
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    font-size: 14px;
}

.cookie-banner-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.consent-row {
    align-items: flex-start;
}

.consent-row input[type="checkbox"] {
    margin-top: 3px;
    flex-shrink: 0;
}

.consent-row label {
    font-size: 13px;
}

.consent-logout {
    margin-top: 16px;
}

/* Кнопка выхода на interstitial согласий — той же ширины, что «Подтвердить»
   (его растягивает .auth-card .btn-primary { width: 100% }) */
.consent-logout .btn {
    width: 100%;
}

.cookie-settings {
    margin-top: 16px;
    font-size: 13px;
}
