/* =========================================================================
   Стили чата свадебного сайта.
   Адаптивно: телефоны, планшеты, компьютеры.
   ========================================================================= */

:root {
    --bg: #f4f5f7;
    --bg-soft: #ffffff;
    --bg-card: #ffffff;
    --primary: #5b6b7d;
    --primary-dark: #455160;
    --primary-soft: #e8edf2;
    --text: #2c3338;
    --text-soft: #8a929c;
    --border: #e2e6ea;
    --bubble-me: #5b8def;
    --bubble-me-text: #ffffff;
    --bubble-other: #ffffff;
    --bubble-other-text: #2c3338;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --radius: 16px;
    --radius-sm: 10px;
    --maxw: 720px;
    /* Дополнительные семантические цвета (адаптируются под тему) */
    --input-bg: #ffffff;
    --hover-soft: #dde6f0;
    --danger-bg: #fde8e8;
    --danger-color: #c0392b;
    --pinned-bg: #fff8e1;
    --pinned-border: #ffe082;
    --pinned-accent: #b8860b;
    --poll-mine: #d4e4ff;
    --link-hover: #dde6f0;
    --overlay-bg: rgba(58, 42, 51, 0.45);
    --danger-border: #e2cfd4;
}

/* --------------------------- Тёмная тема ------------------------------ */
[data-theme="dark"] {
    --bg: #1a1d23;
    --bg-soft: #252932;
    --bg-card: #252932;
    --primary: #7d8fa5;
    --primary-dark: #9fb0c5;
    --primary-soft: #2e343f;
    --text: #e4e7eb;
    --text-soft: #8a929c;
    --border: #3a4150;
    --bubble-me: #3b6fd6;
    --bubble-me-text: #ffffff;
    --bubble-other: #2e343f;
    --bubble-other-text: #e4e7eb;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    /* Адаптация семантических цветов под тёмную тему */
    --input-bg: #2a2f3a;
    --hover-soft: #3a4250;
    --danger-bg: #3a2226;
    --danger-color: #ff6b6b;
    --pinned-bg: #3a3220;
    --pinned-border: #5a4a28;
    --pinned-accent: #d4a93f;
    --poll-mine: #2a3a5a;
    --link-hover: #3a4250;
    --overlay-bg: rgba(0, 0, 0, 0.6);
    --danger-border: #4a2a2e;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    /* Без pinch/double-tap zoom; скролл жестов не ломаем */
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
}

/* Android/iOS WebView-приложение: фиксированный масштаб, нативный вид */
html.balabol-app,
html.balabol-app body {
    touch-action: manipulation;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
}
html.balabol-app input,
html.balabol-app textarea,
html.balabol-app [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
}
html.balabol-app .chat-wrap {
    max-width: none;
    border: none;
    box-shadow: none;
}

/* ----------------------------- Карточка-обёртка ------------------------- */
.chat-wrap {
    max-width: var(--maxw);
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0;
}

/* ------------------------------- Шапка ---------------------------------- */
.chat-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    z-index: 5;
    flex: 0 0 auto;
    position: relative;
}

.chat-header__title {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header__title small {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Блок чата в шапке: аватар + название */
.chat-header__info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 4px 8px 4px 4px;
    border: none;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.chat-header__info:hover {
    background: var(--primary-soft);
}

.chat-header__info:active {
    transform: scale(0.99);
}

.chat-header__titles {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chat-header__room {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header__meta {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-soft);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header__meta-sep {
    opacity: 0.55;
}

.chat-header__online {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header__online--clickable {
    cursor: pointer;
    border-radius: 8px;
    padding: 0 4px;
    margin: 0 -4px;
}
.chat-header__online--clickable:hover {
    background: rgba(76, 175, 80, 0.12);
}

.chat-header__avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-soft);
    flex: 0 0 auto;
    background: var(--primary-soft);
}

.chat-header__btn {
    background: none;
    border: none;
    color: var(--primary-dark);
    font-size: 16px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 12px;
    flex: 0 0 auto;
    min-height: 40px;
    min-width: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.chat-header__btn--back {
    min-width: 36px;
    font-size: 20px;
    font-weight: 500;
}

.chat-header__btn--icon {
    position: relative;
    font-size: 18px;
}

.chat-header__btn:hover {
    background: var(--primary-soft);
}

.chat-header__btn:active {
    background: var(--primary-soft);
    transform: scale(0.96);
}

.chat-header__menu-toggle[aria-expanded="true"] {
    background: var(--primary-soft);
}

/* Баннер-запрос уведомлений */
.notify-banner {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(91,139,239,0.15), rgba(91,139,239,0.08));
    border-bottom: 1px solid rgba(91,139,239,0.3);
    font-size: 13px;
    color: var(--text);
    animation: notifySlideIn 0.3s ease;
}
@keyframes notifySlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.notify-banner__icon { font-size: 18px; flex: 0 0 auto; }
.notify-banner__text { flex: 1 1 auto; min-width: 0; }
.notify-banner__btn {
    flex: 0 0 auto;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.notify-banner__btn:active { transform: scale(0.96); }
.notify-banner__close {
    flex: 0 0 auto;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-soft);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.notify-banner__close:hover { background: rgba(0,0,0,0.06); }

/* Выпадающее меню в шапке */
.chat-header__menu {
    position: relative;
    flex: 0 0 auto;
}

.chat-header__dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.14);
    padding: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 60;
    display: none;
    flex-direction: column;
    gap: 2px;
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    animation: headerMenuIn 0.14s ease;
}

@keyframes headerMenuIn {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-header__dropdown.open {
    display: flex;
}

.chat-header__menu-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-soft);
    padding: 6px 12px 4px;
}

.chat-header__menu-sep {
    height: 1px;
    background: var(--border);
    margin: 6px 8px;
}

.chat-header__menu-item {
    background: none;
    border: none;
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 10px;
    text-align: left;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
    box-sizing: border-box;
}

.chat-header__menu-item:hover {
    background: var(--primary-soft);
}

.chat-header__menu-item--danger {
    color: var(--danger-color);
}

.chat-header__menu-item--danger:hover {
    background: var(--danger-bg);
}

/* ------------------------------- Лента ---------------------------------- */
.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overscroll-behavior: contain;
}

.msg {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    max-width: 85%;
    position: relative;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    /* Вертикаль — скролл; горизонталь оставляем JS (свайп → ответить) */
    touch-action: pan-y;
}

.msg--me {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* ↩ всегда справа от пузыря (row-reverse иначе ставит её слева) */
.msg--me .msg__quick-reply { order: -1; }
.msg--me .msg__avatar { order: 1; }

.msg__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
    cursor: pointer;
}

.msg__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.msg__quick-reply {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-bottom: 2px;
    border: none;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
}
.msg__quick-reply:active {
    transform: scale(0.92);
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.msg__meta {
    font-size: 12px;
    color: var(--text-soft);
    margin: 0 4px 2px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.msg--me .msg__meta {
    justify-content: flex-end;
}

.msg__name {
    font-weight: 600;
    color: var(--primary-dark);
    cursor: pointer;
}

.msg__bot-badge {
    display: inline-block;
    background: #7c5cbf;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
}

.msg--crocobot .msg__bot-badge {
    background: #2e7d32;
}

.msg__bubble {
    background: var(--bubble-other);
    color: var(--bubble-other-text);
    padding: 9px 13px;
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.msg--crocobot .msg__bubble {
    background: #e8f5e9;
    color: #1b5e20;
    border: 1px solid rgba(46, 125, 50, 0.28);
}

html[data-theme="dark"] .msg--crocobot .msg__bubble,
body.theme-dark .msg--crocobot .msg__bubble {
    background: rgba(46, 125, 50, 0.28);
    color: #c8e6c9;
    border-color: rgba(165, 214, 167, 0.35);
}

.msg--me .msg__bubble {
    background: var(--bubble-me);
    color: var(--bubble-me-text);
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: 4px;
}

.msg__time {
    font-size: 11px;
    color: var(--text-soft);
    margin: 2px 4px 0;
}

.msg--me .msg__time {
    text-align: right;
}

/* --------------------------- Футер сообщения ---------------------------- */
.msg__footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.msg--me .msg__footer {
    justify-content: flex-end;
}

.msg__reply-btn {
    background: none;
    border: none;
    color: var(--text-soft);
    font-size: 11px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 8px;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    white-space: nowrap;
}

.msg:hover .msg__reply-btn,
.msg__reply-btn:focus {
    opacity: 1;
}

.msg__reply-btn:hover {
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.msg__del-btn:hover {
    background: var(--danger-bg);
    color: var(--danger-color);
}

.msg__edit-btn:hover {
    background: #e8f0fd;
    color: #2563a8;
}

/* --------------------------- Цитата ответа ------------------------------ */
.msg__reply {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin-bottom: 6px;
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
    border-radius: 8px;
    font-size: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    max-width: 100%;
}

.msg__reply:hover {
    background: var(--hover-soft);
    border-left-color: #3a6fb0;
}

.msg--me .msg__reply:hover {
    border-right-color: #3a6fb0;
}

/* Подсветка сообщения при переходе из цитаты ответа */
.msg--highlight {
    animation: msg-highlight 2s ease-out;
}

@keyframes msg-highlight {
    0%   { background: rgba(91, 139, 239, 0.28); box-shadow: 0 0 0 3px rgba(91, 139, 239, 0.4); }
    70%  { background: rgba(91, 139, 239, 0.18); box-shadow: 0 0 0 2px rgba(91, 139, 239, 0.2); }
    100% { background: transparent; box-shadow: none; }
}

.msg--me .msg__reply {
    border-left: none;
    border-right: 3px solid var(--primary);
}

.msg__reply-name {
    font-weight: 600;
    white-space: nowrap;
    flex: 0 0 auto;
}

.msg__reply-text {
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1 1 auto;
}

/* Метка «ред.» — отредактированное сообщение */
.msg__edited {
    display: inline-block;
    font-size: 10px;
    color: var(--text-soft);
    opacity: 0.6;
    margin-left: 6px;
    font-style: italic;
    vertical-align: bottom;
    cursor: help;
}
.msg--me .msg__edited {
    color: rgba(255, 255, 255, 0.6);
}

/* Контекстное меню сообщения (долгое нажатие) */
/* Ловит тап вне меню/реакций — закрытие на телефоне */
.msg-chrome-backdrop {
    position: fixed;
    inset: 0;
    z-index: 5100;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ctx-menu {
    position: fixed;
    z-index: 200;
    min-width: 160px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
    padding: 6px;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.12s, transform 0.12s;
}
.ctx-menu--show {
    opacity: 1;
    transform: scale(1);
}
.ctx-menu__item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    padding: 11px 14px;
    border-radius: 8px;
    cursor: pointer;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}
.ctx-menu__item:hover, .ctx-menu__item:active {
    background: var(--primary-soft);
}
.ctx-menu__item--danger {
    color: #c0392b;
}
.ctx-menu__item--danger:hover, .ctx-menu__item--danger:active {
    background: var(--danger-bg);
}

/* Inline-редактирование сообщения */
.msg__edit-area {
    width: 100%;
    min-height: 40px;
    max-height: 200px;
    padding: 8px 10px;
    border: 1px solid var(--primary);
    border-radius: 10px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    resize: none;
    box-sizing: border-box;
    background: var(--bg);
    color: var(--text);
    outline: none;
}
.msg--me .msg__edit-area {
    background: rgba(255, 255, 255, 0.95);
    color: var(--text);
}
.msg__edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.msg__edit-btn {
    padding: 5px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.msg__edit-btn--save {
    background: var(--primary);
    color: #fff;
}
.msg__edit-btn--save:disabled {
    opacity: 0.6;
}
.msg__edit-btn--cancel {
    background: var(--primary-soft);
    color: var(--text);
}
.msg__edit-btn:active {
    transform: scale(0.96);
}

.msg__reply-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}

.msg__reply-avatar--initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.msg__reply-arrow {
    color: var(--text-soft);
    font-size: 14px;
    flex: 0 0 auto;
    opacity: 0.6;
}

/* ------------------------- Системные события --------------------------- */
.system-event {
    align-self: center;
    text-align: center;
    margin: 6px 0;
    max-width: 90%;
}

.system-event__name {
    display: inline-block;
    font-size: 12px;
    color: var(--text-soft);
    background: var(--primary-soft);
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 500;
}

/* --------------------------- Бейдж онлайн ------------------------------- */
.online-count {
    font-weight: 600;
    color: #4caf50;
}

/* ----------------------- Превью ответа над вводом ----------------------- */
.reply-preview {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--primary-soft);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.reply-preview.show {
    display: flex;
}

.reply-preview__info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.reply-preview__name {
    font-weight: 600;
    white-space: nowrap;
    flex: 0 0 auto;
}

.reply-preview__text {
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.reply-preview__close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-soft);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex: 0 0 auto;
}

.reply-preview__close:hover {
    color: var(--primary-dark);
}

/* ------------------------------- Ввод ---------------------------------- */
.crocodile-bar {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: linear-gradient(180deg, rgba(46, 125, 50, 0.12), rgba(46, 125, 50, 0.04));
    border-top: 1px solid rgba(46, 125, 50, 0.25);
    font-size: 13px;
    color: var(--text);
}
.crocodile-bar.hidden {
    display: none;
}
.crocodile-bar__top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
}
.crocodile-bar__status {
    color: var(--text-soft);
    line-height: 1.35;
    flex: 1 1 auto;
    min-width: 0;
}
.crocodile-bar__timer {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.02em;
    color: #1b5e20;
    background: rgba(46, 125, 50, 0.14);
    border: 1px solid rgba(46, 125, 50, 0.35);
    border-radius: 999px;
    padding: 4px 10px;
    line-height: 1.2;
}
.crocodile-bar__timer--alert {
    color: #b71c1c;
    background: rgba(198, 40, 40, 0.12);
    border-color: rgba(198, 40, 40, 0.35);
}
html[data-theme="dark"] .crocodile-bar__timer,
body.theme-dark .crocodile-bar__timer {
    color: #c8e6c9;
}
html[data-theme="dark"] .crocodile-bar__timer--alert,
body.theme-dark .crocodile-bar__timer--alert {
    color: #ffcdd2;
}
.crocodile-bar__online {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-size: 12px;
    line-height: 1.35;
    padding: 0;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.crocodile-bar__online:hover {
    color: var(--text);
    text-decoration: underline;
}
.crocodile-bar__online--empty {
    opacity: 0.75;
    font-style: italic;
}
.online-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.28);
}
.online-sheet-backdrop.hidden {
    display: none;
}
.online-sheet {
    position: fixed;
    left: 50%;
    top: 72px;
    transform: translateX(-50%);
    z-index: 1201;
    width: min(360px, calc(100vw - 24px));
    max-height: min(60vh, 420px);
    overflow: auto;
    background: var(--bg, #fff);
    color: var(--text);
    border: 1px solid var(--border, rgba(0,0,0,0.12));
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    padding: 12px;
}
.online-sheet.hidden {
    display: none;
}
.online-sheet__title {
    font-weight: 700;
    font-size: 14px;
    margin: 0 0 8px;
}
.online-sheet__empty {
    color: var(--text-soft);
    font-size: 13px;
    padding: 8px 2px 4px;
}
.online-sheet__list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.online-sheet__row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    padding: 8px 6px;
    border-radius: 10px;
    cursor: pointer;
}
.online-sheet__row:hover {
    background: rgba(46, 125, 50, 0.1);
}
.online-sheet__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    flex: 0 0 auto;
}
.online-sheet__name {
    font-weight: 600;
    font-size: 14px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.online-sheet__nick {
    margin-left: auto;
    color: var(--text-soft);
    font-size: 12px;
    flex: 0 0 auto;
}
.crocodile-bar__word {
    font-weight: 700;
    color: #1b5e20;
    font-size: 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
html[data-theme="dark"] .crocodile-bar__word,
body.theme-dark .crocodile-bar__word {
    color: #a5d6a7;
}
.crocodile-bar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.crocodile-bar__btn {
    border: 1px solid rgba(46, 125, 50, 0.35);
    background: var(--bg, #fff);
    color: #1b5e20;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 12px;
    cursor: pointer;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
}
.crocodile-bar__btn:hover {
    background: rgba(46, 125, 50, 0.12);
}
.crocodile-bar__btn:disabled {
    opacity: 0.55;
    cursor: default;
}
.crocodile-bar__btn--primary {
    background: #2e7d32;
    border-color: #2e7d32;
    color: #fff;
}
.crocodile-bar__btn--primary:hover {
    background: #1b5e20;
}
.crocodile-bar__btn--rate {
    font-size: 18px;
    min-width: 48px;
    padding: 6px 10px;
}
.crocodile-bar__score {
    color: var(--text-soft);
    font-size: 12px;
    margin-left: auto;
}
.crocodile-word-modal__hint {
    margin: 0 0 12px;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.4;
}
.crocodile-word-modal__word {
    font-size: 28px;
    font-weight: 800;
    text-align: center;
    color: #1b5e20;
    padding: 16px 12px;
    margin: 0 0 16px;
    background: rgba(46, 125, 50, 0.1);
    border-radius: 14px;
    letter-spacing: 0.02em;
    word-break: break-word;
}
html[data-theme="dark"] .crocodile-word-modal__word,
body.theme-dark .crocodile-word-modal__word {
    color: #c8e6c9;
}

.chat-input {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--bg-soft);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
    position: relative;
}

.chat-input__field {
    flex: 1 1 auto;
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 10px 14px;
    font-size: 16px; /* 16px+ чтобы iOS не зумил при фокусе */
    resize: none;
    max-height: 120px;
    min-height: 44px;
    line-height: 1.4;
    outline: none;
    background: var(--input-bg);
    transition: border-color 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.chat-input__field:focus {
    border-color: var(--primary);
}

.chat-input__emoji {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 50%;
    line-height: 1;
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.chat-input__emoji:hover {
    background: var(--primary-soft);
}

.chat-input__send {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 20px;
    cursor: pointer;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.chat-input__send:hover {
    background: var(--primary-dark);
}

.chat-input__send:disabled {
    background: #d8b6c4;
    cursor: not-allowed;
}
/* Состояние записи голосового по зажатию */
.chat-input__send.recording {
    background: var(--danger, #e53935);
    animation: rec-pulse 1s ease-in-out infinite;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    user-select: none;
    color: #fff;
}
@keyframes rec-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(229, 57, 53, 0); }
}


/* --------------------------- Панель смайлов ----------------------------- */
.emoji-panel {
    display: none;
    flex: 0 0 auto;
    padding: 8px 8px 4px;
    background: var(--bg-soft);
    border-top: 1px solid var(--border);
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow: hidden;
}

.emoji-tabs {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
    overflow-x: auto;
    padding-bottom: 4px;
}

.emoji-tab {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
    opacity: 0.6;
    flex: 0 0 auto;
}

.emoji-tab.active,
.emoji-tab:hover {
    background: var(--primary-soft);
    opacity: 1;
}

.emoji-content {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    overflow-y: auto;
    max-height: 140px;
}

.emoji-panel.open {
    display: flex;
}

.emoji-panel__item {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, background 0.12s ease;
}

.emoji-panel__item:hover {
    background: var(--primary-soft);
    transform: scale(1.15);
}

/* ================= Анимированные ICQ-смайлы (GIF, набор Kolobok) =========
   Единый фиксированный размер ВЕЗДЕ — и в панели-превью, и в сообщениях. */
:root { --icq-size: 28px; --icq-panel-size: 36px; }

.icq-smiley {
    display: inline-block;
    width: var(--icq-size);
    height: var(--icq-size);
    vertical-align: middle;
    line-height: 1;
    overflow: hidden;
}
/* Настоящий GIF-колобок ICQ/QIP — всегда вписан в квадрат фикс. размера */
.icq-smiley .icq-gif {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    vertical-align: middle;
    -webkit-user-select: none;
    user-select: none;
}
/* Если GIF не загрузился — показываем шорткод текстом (не пустую картинку) */
.icq-smiley--failed {
    width: auto;
    height: auto;
    overflow: visible;
    font-size: 13px;
    color: var(--text-soft);
    background: var(--primary-soft);
    border-radius: 4px;
    padding: 0 3px;
}

/* --- Панель выбора смайлов --- */
/* ICQ-вкладка: аккуратная сетка одинаковых ячеек */
.emoji-content--icq {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 2px;
    align-content: start;
}
.emoji-content--icq .emoji-panel__item {
    width: 44px;
    height: 44px;
    padding: 0;
}
.emoji-panel__item .icq-smiley {
    width: var(--icq-panel-size);
    height: var(--icq-panel-size);
}
/* Обычные (юникод) смайлы в панели — текстом */
.emoji-panel__item--uni { font-size: 24px; line-height: 1; }
/* Верхние вкладки панели (ICQ / Обычные) */
.emoji-tab--top {
    font-size: 14px;
    font-weight: 600;
    padding: 5px 12px;
    white-space: nowrap;
}

/* Старые SVG-«колобки» и их CSS-анимации удалены — теперь используются
   реальные анимированные GIF-смайлы набора Kolobok HD (ICQ/QIP). */

/* ==================== Баннер обновления приложения (PWA/Safari) ========== */
.app-update-banner {
    position: fixed;
    left: 10px;
    right: 10px;
    top: max(10px, env(safe-area-inset-top));
    z-index: 4000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--primary);
    border-radius: 14px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
}
.app-update-banner.hidden { display: none !important; }
.app-update-banner__text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    line-height: 1.3;
}
.app-update-banner__text strong { font-size: 14px; }
.app-update-banner__text span { color: var(--text-soft); font-size: 12px; }
.app-update-banner__btn {
    flex: 0 0 auto;
    border: none;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.app-update-banner__btn:disabled { opacity: 0.7; }
.app-update-banner__dismiss {
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: var(--text-soft);
    font-size: 22px;
    line-height: 1;
    padding: 4px 6px;
    cursor: pointer;
}

/* ==================== Всплывающие уведомления (toast) ==================== */
.toast-container {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: max(8px, env(safe-area-inset-top)) 8px 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    width: 100%;
    max-width: 420px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-soft);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.18);
    cursor: pointer;
    opacity: 0;
    transform: translateY(-16px);
    transition: opacity 0.28s ease, transform 0.28s ease;
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--hide { opacity: 0; transform: translateY(-16px); }
.toast--accent { border-left: 4px solid var(--bubble-me); }

.toast__avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}
.toast__icon { font-size: 28px; flex: 0 0 auto; line-height: 1; }
.toast__body { flex: 1 1 auto; min-width: 0; }
.toast__title {
    font-weight: 700;
    font-size: 14px;
    color: var(--primary-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toast__text {
    font-size: 13px;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toast__close {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--text-soft);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 8px;
}
.toast__close:hover { background: rgba(0,0,0,0.06); }
.toast__action {
    display: inline-block;
    margin-top: 6px;
    border: none;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
}
.toast__action:active { transform: scale(0.97); }

/* ----------------------------- Модалки --------------------------------- */
.overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
    /* Не отдаём скролл фону (iOS/Android: список чатов за модалкой) */
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.overlay.open {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.modal {
    background: var(--bg-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 380px;
    /* Скроллит .overlay, а не вложенный .modal — так iOS не цепляет фон */
    max-height: none;
    overflow: visible;
    padding: 24px;
    margin-top: auto;
    margin-bottom: auto;
    flex-shrink: 0;
    overscroll-behavior: contain;
    box-sizing: border-box;
}

/* Пока открыта любая модалка — фон (список чатов и т.п.) не листается */
body.body--overlay-open {
    overflow: hidden !important;
    touch-action: none;
}
body.body--overlay-open .chat-wrap,
body.body--overlay-open .rooms-main,
body.body--overlay-open .rooms-panel,
body.body--overlay-open .cabinet-main,
body.body--overlay-open .home-main,
body.body--overlay-open .forum-main,
body.body--overlay-open .landing,
body.body--overlay-open #messages,
body.body--overlay-open .globaladmin-main {
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none;
}

.modal__title {
    margin: 0 0 16px;
    text-align: center;
    color: var(--primary-dark);
    font-size: 20px;
}

.modal__field {
    margin-bottom: 14px;
}

.modal__label {
    display: block;
    font-size: 13px;
    color: var(--text-soft);
    margin-bottom: 4px;
}

.modal__input,
.modal__textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 15px;
    outline: none;
    background: var(--input-bg);
    font-family: inherit;
}

.modal__input:focus,
.modal__textarea:focus {
    border-color: var(--primary);
}

.modal__textarea {
    resize: vertical;
    min-height: 70px;
}

.modal__btn {
    width: 100%;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
}

.modal__btn:hover {
    background: var(--primary-dark);
}

.modal__btn--danger {
    background: #c0392b;
    margin-top: 8px;
}

.modal__btn--danger:hover {
    background: #a93226;
}

.modal__btn:disabled {
    background: #d8b6c4;
    cursor: not-allowed;
}

.modal__switch {
    text-align: center;
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-soft);
}

.modal__switch a {
    color: var(--primary-dark);
    cursor: pointer;
    text-decoration: underline;
}

.modal__error {
    color: #c0392b;
    background: #fdecea;
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 13px;
    margin-bottom: 12px;
    display: none;
}

.modal__error.show {
    display: block;
}

.modal__avatar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.modal__avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-soft);
}

.modal__avatar-btn {
    font-size: 13px;
    color: var(--primary-dark);
    cursor: pointer;
    text-decoration: underline;
}

.modal__avatar-btn--remove {
    color: #c0392b;
    background: none;
    border: none;
    padding: 0;
    margin-left: 8px;
}

.modal__close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-soft);
    cursor: pointer;
}

/* ----------------------------- Профиль-карточка ------------------------ */
.profile-card {
    text-align: center;
}
.profile-card__hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}
.profile-card__avatar-wrap {
    position: relative;
    width: 104px;
    height: 104px;
    margin: 0 auto 4px;
}
.profile-card__avatar {
    width: 104px;
    height: 104px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-soft);
    display: block;
    box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.profile-card__online-dot {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #9aa3af;
    border: 2px solid var(--bg-soft, #fff);
}
.profile-card__online-dot--on { background: #22c55e; }
.profile-card__name {
    font-size: 21px;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.profile-card__username {
    font-size: 14px;
    color: var(--text-soft);
    margin: 0;
}
.profile-card__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 6px;
}
.profile-card__chip {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg, #f0f2f5);
    color: var(--text-soft);
    border: 1px solid var(--border, #e2e6eb);
}
.profile-card__chip--on {
    background: #e8f8ee;
    color: #1b7a3d;
    border-color: #b7e4c7;
}
.profile-card__chip--m { background: #e8f0fe; color: #2b5bb0; border-color: #c5d7f7; }
.profile-card__chip--f { background: #fce8f3; color: #a1286a; border-color: #f3c4dc; }
.profile-card__bio {
    font-size: 14px;
    color: var(--text);
    background: var(--primary-soft);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 0 0 12px;
    text-align: left;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.45;
}
.profile-card__bio--empty {
    color: var(--text-soft);
    font-style: italic;
    background: var(--bg, #f5f6f8);
}
.profile-card__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
    margin: 0 0 14px;
}
.profile-card__stat {
    background: var(--bg, #f5f6f8);
    border: 1px solid var(--border, #e5e8ec);
    border-radius: 12px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.profile-card__stat b {
    font-size: 14px;
    color: var(--primary-dark);
    text-transform: capitalize;
}
.profile-card__stat span {
    font-size: 11px;
    color: var(--text-soft);
}
.profile-card__meta {
    font-size: 13px;
    color: var(--text-soft);
    margin: 0 0 10px;
}
.profile-card__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.profile-card__mod {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border, #e5e8ec);
    text-align: left;
}
.profile-card__mod-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* Вкладки профиля: Устройства */
.profile-tabs {
    display: flex;
    gap: 4px;
    margin: 12px 0 4px;
    padding: 3px;
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}
.profile-tab {
    flex: 1 1 0;
    border: none;
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.profile-tab.active {
    background: var(--bg-soft);
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.profile-pane { margin-top: 8px; }
.profile-devices__hint {
    margin: 0 0 10px;
    font-size: 12px;
    color: var(--text-soft);
    line-height: 1.4;
}
.profile-devices__list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: min(50vh, 360px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.profile-devices__loading,
.profile-devices__empty {
    font-size: 13px;
    color: var(--text-soft);
    padding: 12px 4px;
}
.profile-devices__note {
    font-size: 12px;
    color: var(--text-soft);
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    line-height: 1.4;
}
.profile-device {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-soft);
}
.profile-device--current {
    border-color: rgba(47, 158, 68, 0.35);
    background: rgba(47, 158, 68, 0.06);
}
.profile-device--unknown {
    opacity: 0.92;
}
.profile-device__icon {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--primary-soft);
    border-radius: 10px;
}
.profile-device__meta {
    flex: 1 1 auto;
    min-width: 0;
}
.profile-device__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-device__sub {
    font-size: 11px;
    color: var(--text-soft);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.profile-device__badge {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    color: #2f9e44;
    background: rgba(47, 158, 68, 0.12);
    padding: 4px 8px;
    border-radius: 999px;
}
.profile-device__actions {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.profile-device__rename {
    flex: 0 0 auto;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-soft);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 8px;
    cursor: pointer;
}
.profile-device__revoke {
    flex: 0 0 auto;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--danger-color, #c0392b);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
}
.profile-device__revoke:active { transform: scale(0.96); }
.profile-devices__foot {
    padding-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Свайп вправо → ответить */
.msg.msg--swiping {
    transition: none !important;
    z-index: 2;
    will-change: transform;
}
.msg.msg--swipe-reply {
    background: rgba(47, 158, 68, 0.08);
    border-radius: 12px;
}
.msg.msg--swipe-reply::before {
    content: '↩';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    -webkit-transform: translateY(-50%);
    font-size: 18px;
    color: #2f9e44;
    opacity: 0.9;
    pointer-events: none;
    z-index: 3;
}

/* ------------------------------- Утилиты ------------------------------- */
.hidden {
    display: none !important;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--primary-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --------------------- Touch / узкий экран ---------------------------- */
/* Действия — тап по сообщению (единая панель). ↩ сбоку всегда на узком. */
@media (hover: none), (max-width: 700px) {
    .msg__reply-btn {
        display: none !important;
    }
    .msg__quick-reply {
        display: inline-flex !important;
        opacity: 0.75;
    }
    .msg__reactions .reaction--add:only-child {
        display: none;
    }
    .msg__reactions:not(:has(.reaction:not(.reaction--add))) {
        display: none;
    }
}

/* Единая панель: реакции сверху + действия снизу */
.msg-sheet {
    z-index: 5200;
    min-width: 200px;
    max-width: min(300px, calc(100vw - 16px));
    padding: 0;
    overflow: hidden;
}
.msg-sheet__reacts {
    display: flex;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 8px 8px 6px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.msg-sheet__react {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.msg-sheet__react:active,
.msg-sheet__react:hover {
    background: var(--primary-soft);
    transform: scale(1.08);
}
.msg-sheet__actions {
    padding: 4px 6px 6px;
}

@media (max-width: 600px) {
    .msg {
        gap: 6px;
        max-width: 94%;
    }
    .msg__footer {
        gap: 6px;
        margin-top: 1px;
        flex-wrap: wrap;
    }
    .msg__reactions {
        margin-top: 3px;
        gap: 3px;
    }
    .reaction {
        padding: 1px 6px;
        font-size: 12px;
    }
    .reaction--add {
        font-size: 15px;
        padding: 1px 6px;
        opacity: 0.55;
    }
    .msg__read-by {
        margin-top: 0;
        margin-left: 0;
        padding: 0 2px;
        font-size: 10px;
        opacity: 0.75;
    }
    .msg__read-by-check { font-size: 11px; }
    .msg__quick-reply {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }
}

/* ------------------------------- Вложения ------------------------------- */
.msg__media {
    margin-bottom: 6px;
    max-width: 100%;
}

/* Рамка вокруг фото/видео — для бейджа GIF и кнопки развернуть */
.msg__media-frame {
    position: relative;
    display: inline-block;
    max-width: min(200px, 58vw);
    border-radius: 12px;
    overflow: hidden;
    line-height: 0;
}

.msg__media-img {
    width: 100%;
    max-width: min(200px, 58vw);
    max-height: 140px;
    height: auto;
    border-radius: 12px;
    cursor: zoom-in;
    display: block;
    object-fit: cover;
    background: #000;
    transition: filter 0.15s;
}

.msg__media-img:hover { filter: brightness(1.04); }

.msg__media-video {
    max-width: min(240px, 70vw);
    max-height: 180px;
    border-radius: 12px;
    display: block;
    background: #000;
}

/* Бейдж «GIF» в углу анимированной картинки */
.msg__media-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: 6px;
    pointer-events: none;
    line-height: 1.4;
}

/* Кнопка «на весь экран» поверх видео */
.msg__media-expand {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s, background 0.15s;
}
.msg__media-expand:hover { opacity: 1; background: rgba(0, 0, 0, 0.75); }

/* Кнопка «Скачать» поверх фото/видео */
.msg__media-download {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 18px;
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s, background 0.15s;
}
.msg__media-download:hover { opacity: 1; background: rgba(0, 0, 0, 0.75); }

/* Кнопка «Скачать» для аудио (рядом с плеером) */
.msg__media-audio-wrap { display: flex; flex-direction: column; gap: 6px; }
.msg__media-download--audio {
    align-self: flex-start;
    padding: 4px 12px;
    border-radius: 8px;
    background: rgba(91, 141, 239, 0.15);
    color: #5b8def;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    -webkit-tap-highlight-color: transparent;
}
.msg__media-download--audio:hover { background: rgba(91, 141, 239, 0.3); }

/* ---------------------- Голосовой плеер (play + волны) ----------------- */
.voice-player {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 280px;
    min-width: 180px;
    padding: 8px 12px 8px 8px;
    background: var(--primary-soft);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-sizing: border-box;
}
.voice-player__play {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, transform 0.1s;
}
.voice-player__play:hover { background: var(--primary-dark); }
.voice-player__play:active { transform: scale(0.93); }
.voice-player__wave {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 36px;
    min-width: 0;
    cursor: pointer;
    touch-action: none;
    padding: 0 2px;
}
.voice-player__bar {
    flex: 1 1 0;
    min-width: 2px;
    max-width: 4px;
    height: 24%;
    border-radius: 2px;
    background: rgba(91, 141, 239, 0.35);
    transition: background 0.12s ease, height 0.2s ease;
}
.voice-player__bar--on {
    background: var(--primary);
}
.voice-player--playing .voice-player__bar:not(.voice-player__bar--on) {
    opacity: 0.85;
}
.voice-player__time {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
    min-width: 34px;
    text-align: right;
}
/* совместимость со старым классом */
.audio-player { display: none; }

/* Превью выбранного вложения над полем ввода */
.attach-preview {
    flex: 0 0 auto;
    padding: 8px 12px;
    background: var(--primary-soft);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attach-preview.hidden {
    display: none;
}

#overlay-compress-ask {
    z-index: 130;
}

.attach-preview__info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.attach-preview__name {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attach-preview__size {
    font-size: 12px;
    color: var(--text-soft);
}

.attach-preview__close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-soft);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.attach-preview__close:hover {
    background: rgba(0, 0, 0, 0.08);
}

.attach-preview__thumb {
    max-width: 100%;
    max-height: 160px;
    border-radius: 8px;
    object-fit: contain;
}

.attach-preview__audio {
    width: 100%;
    max-width: 320px;
}

/* Меню скрепки: галерея / аудио онлайн */
.attach-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-elevated, #fff);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: attach-sheet-in 0.18s ease-out;
}
.attach-sheet__backdrop {
    position: fixed;
    inset: 0;
    z-index: 1199;
    background: rgba(0, 0, 0, 0.35);
}
@keyframes attach-sheet-in {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.attach-sheet__btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 16px;
    text-align: left;
    padding: 14px 12px;
    border-radius: 12px;
    cursor: pointer;
}
.attach-sheet__btn:hover,
.attach-sheet__btn:focus-visible {
    background: var(--primary-soft, rgba(0, 0, 0, 0.06));
    outline: none;
}
.attach-sheet__icon {
    width: 28px;
    text-align: center;
    font-size: 20px;
}
.attach-sheet__cancel {
    margin-top: 4px;
    color: var(--muted, #888);
    font-weight: 500;
}

/* Поиск музыки */
.music-modal {
    max-width: 440px;
    width: min(96vw, 440px);
}
.music-modal__hint {
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--muted, #777);
}
.music-modal__search {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.music-modal__search .modal__input {
    flex: 1;
    min-width: 0;
}
.music-modal__search-btn {
    flex: 0 0 auto;
    width: auto;
    padding: 0 16px;
    margin: 0;
}
.music-modal__status {
    min-height: 1.2em;
    margin: 8px 0 4px;
    font-size: 13px;
    color: var(--muted, #777);
}
.music-search-results {
    max-height: min(52vh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}
.music-track {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 8px;
    border-radius: 12px;
    cursor: pointer;
    color: inherit;
    font: inherit;
}
.music-track:hover {
    background: var(--primary-soft, rgba(0, 0, 0, 0.06));
}
.music-track__art {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--border, #ddd);
    flex: 0 0 auto;
}
.music-track__art--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.music-track__meta {
    flex: 1;
    min-width: 0;
}
.music-track__title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.music-track__artist {
    font-size: 12px;
    color: var(--muted, #777);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.music-track__badge {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--muted, #888);
}

/* Кнопки бота в сообщении (Крокодил: лайк/дизлайк) */
.msg__bot-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.msg__bot-action {
    border: 1px solid var(--border, rgba(0,0,0,.12));
    background: var(--bg-soft, #f4f5f7);
    color: var(--text);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    min-height: 40px;
    min-width: 64px;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.msg__bot-action:hover:not(:disabled) {
    background: var(--primary-soft, rgba(46,125,50,.12));
    border-color: rgba(46,125,50,.35);
}
.msg__bot-action--up:hover:not(:disabled) {
    background: rgba(229, 57, 53, 0.1);
    border-color: rgba(229, 57, 53, 0.35);
}
.msg__bot-action:disabled {
    opacity: 0.55;
    cursor: default;
}
.msg--mine .msg__bot-action {
    background: rgba(255,255,255,0.16);
    border-color: rgba(255,255,255,0.28);
    color: inherit;
}

/* Карточка трека в сообщении */
.msg__music {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: min(260px, 72vw);
    max-width: 320px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.04);
}
.msg--mine .msg__music {
    background: rgba(255, 255, 255, 0.14);
}
.msg__music-head {
    display: flex;
    gap: 10px;
    align-items: center;
}
.msg__music-art {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    background: rgba(0, 0, 0, 0.08);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.msg__music-meta {
    flex: 1;
    min-width: 0;
}
.msg__music-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    word-break: break-word;
}
.msg__music-artist {
    font-size: 12px;
    opacity: 0.75;
    margin-top: 2px;
}
.msg__music-note {
    font-size: 11px;
    opacity: 0.65;
    margin-top: 4px;
}
.msg__music-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.msg__music-actions .forum-btn {
    padding: 6px 10px;
    font-size: 12px;
}
.msg__music-link {
    font-size: 12px;
    color: inherit;
    opacity: 0.8;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Глобальный мини-плеер
   Высота контента (без home-indicator): 8+40+8 = 56px.
   Safe-area только у плеера — иначе в Safari (viewport-fit=cover)
   отступ от поля ввода удваивается. */
:root {
    --global-music-content-h: 56px;
}
.global-music {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 4px;
    box-sizing: border-box;
    min-height: calc(var(--global-music-content-h) + env(safe-area-inset-bottom, 0px));
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-soft, #fff);
    border-top: 1px solid var(--border, rgba(0,0,0,.1));
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.08);
}
.global-music.hidden { display: none !important; }
.global-music__main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    padding: 0;
    cursor: pointer;
    font: inherit;
}
.global-music__art {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--primary-soft, #e8ecef);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    overflow: hidden;
}
.global-music__art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.global-music__meta { min-width: 0; flex: 1; }
.global-music__title {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.global-music__artist {
    font-size: 11px;
    color: var(--text-soft, #777);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.global-music__btn {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.global-music__btn:hover { background: var(--primary-soft, rgba(0,0,0,.06)); }
.global-music__btn--play {
    width: 40px;
    height: 40px;
    background: #2e7d32;
    color: #fff;
    border-radius: 50%;
    font-size: 13px;
}
.global-music__btn--play:hover { background: #1b5e20; }
.global-music audio { display: none; }
/* Место под плеер — только у wrap (один раз). У input обычный компактный padding. */
body.has-global-music .chat-wrap {
    padding-bottom: calc(var(--global-music-content-h) + env(safe-area-inset-bottom, 0px));
}
body.has-global-music .chat-input {
    padding-bottom: 10px;
}

/* Полноэкранный «сейчас играет» поверх чата */
.global-music-sheet {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.global-music-sheet__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    padding: 0;
    margin: 0;
    background: rgba(11, 18, 28, 0.48);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    cursor: pointer;
}
.global-music-sheet__panel {
    position: relative;
    z-index: 1;
    width: min(100%, 440px);
    max-height: min(92vh, 720px);
    overflow: auto;
    box-sizing: border-box;
    margin: 0;
    padding: 16px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    border-radius: 22px 22px 0 0;
    background: linear-gradient(180deg, #f7fafc 0%, #eef3f8 100%);
    color: #0b1f3a;
    box-shadow: 0 -12px 40px rgba(11, 31, 58, 0.22);
    animation: global-music-sheet-in 0.22s ease-out;
}
@keyframes global-music-sheet-in {
    from { transform: translateY(24px); opacity: 0.6; }
    to { transform: translateY(0); opacity: 1; }
}
.global-music-sheet__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}
.global-music-sheet__label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #5a6b7d;
}
.global-music-sheet__dismiss {
    border: 0;
    background: rgba(11, 31, 58, 0.06);
    color: #0b1f3a;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.global-music-sheet__dismiss:active {
    background: rgba(11, 31, 58, 0.12);
}
.global-music-sheet__art {
    width: min(42vw, 168px);
    aspect-ratio: 1;
    margin: 0 auto 14px;
    border-radius: 16px;
    overflow: hidden;
    background: #d7e2ee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 42px;
    box-shadow: 0 12px 28px rgba(11, 31, 58, 0.16);
}
.global-music-sheet__art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.global-music-sheet__title {
    text-align: center;
    font-size: 18px;
    font-weight: 750;
    line-height: 1.25;
    margin: 0 8px 4px;
}
.global-music-sheet__artist {
    text-align: center;
    font-size: 14px;
    color: #5a6b7d;
    margin: 0 8px 14px;
    min-height: 1.2em;
}
.global-music-sheet__progress {
    margin: 0 4px 18px;
}
.global-music-sheet__seek {
    width: 100%;
    accent-color: #2e7d32;
    margin: 0;
}
.global-music-sheet__times {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    color: #6a7b8c;
}
.global-music-sheet__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    margin-bottom: 18px;
}
.global-music-sheet__ctrl {
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #0b1f3a;
    font-size: 22px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.global-music-sheet__ctrl:active {
    background: rgba(11, 31, 58, 0.08);
}
.global-music-sheet__play {
    width: 68px;
    height: 68px;
    border: 0;
    border-radius: 50%;
    background: #2e7d32;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(46, 125, 50, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.global-music-sheet__play:active {
    background: #1b5e20;
}
.global-music-sheet__tools {
    display: flex;
    justify-content: center;
    margin: 0 0 12px;
}
.global-music-sheet__shuffle {
    border: 0;
    border-radius: 999px;
    background: rgba(11, 31, 58, 0.07);
    color: #0b1f3a;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    cursor: pointer;
    min-height: 36px;
}
.global-music-sheet__shuffle.is-on {
    background: rgba(46, 125, 50, 0.16);
    color: #1b5e20;
}
.global-music-sheet__foot {
    display: flex;
    gap: 8px;
}
.global-music-sheet__save,
.global-music-sheet__stop {
    flex: 1;
    border: 0;
    border-radius: 14px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 12px 10px;
    cursor: pointer;
    min-height: 44px;
}
.global-music-sheet__save {
    background: rgba(11, 31, 58, 0.07);
    color: #0b1f3a;
}
.global-music-sheet__stop {
    background: rgba(198, 40, 40, 0.1);
    color: #b71c1c;
}
.global-music-sheet__queue {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(11, 31, 58, 0.08);
}
.global-music-sheet__queue-count {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #5a6b7d;
    margin-bottom: 8px;
}
.global-music-sheet__queue-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: min(36vh, 280px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.global-music-sheet__queue-empty {
    font-size: 13px;
    color: #6a7b8c;
    padding: 8px 2px;
}
.global-music-sheet__queue-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    text-align: left;
    padding: 8px;
    cursor: pointer;
    font: inherit;
}
.global-music-sheet__queue-item.is-active,
.global-music-sheet__queue-item:active {
    background: rgba(46, 125, 50, 0.12);
}
.global-music-sheet__queue-art {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    flex: 0 0 auto;
    background: #d7e2ee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.global-music-sheet__queue-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.global-music-sheet__queue-meta {
    flex: 1 1 auto;
    min-width: 0;
}
.global-music-sheet__queue-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.global-music-sheet__queue-artist {
    margin-top: 2px;
    font-size: 11px;
    color: #6a7b8c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.global-music-sheet__queue-now {
    flex: 0 0 auto;
    color: #2e7d32;
    font-size: 12px;
    font-weight: 700;
}
[data-theme="dark"] .global-music-sheet__panel,
body.theme-dark .global-music-sheet__panel {
    background: linear-gradient(180deg, #1c222a 0%, #14181e 100%);
    color: #e8eef4;
}
[data-theme="dark"] .global-music-sheet__label,
[data-theme="dark"] .global-music-sheet__artist,
[data-theme="dark"] .global-music-sheet__times,
[data-theme="dark"] .global-music-sheet__queue-count,
[data-theme="dark"] .global-music-sheet__queue-artist,
[data-theme="dark"] .global-music-sheet__queue-empty,
body.theme-dark .global-music-sheet__label,
body.theme-dark .global-music-sheet__artist,
body.theme-dark .global-music-sheet__times,
body.theme-dark .global-music-sheet__queue-count,
body.theme-dark .global-music-sheet__queue-artist,
body.theme-dark .global-music-sheet__queue-empty {
    color: #9aabbc;
}
[data-theme="dark"] .global-music-sheet__dismiss,
[data-theme="dark"] .global-music-sheet__save,
[data-theme="dark"] .global-music-sheet__shuffle,
body.theme-dark .global-music-sheet__dismiss,
body.theme-dark .global-music-sheet__save,
body.theme-dark .global-music-sheet__shuffle {
    background: rgba(255, 255, 255, 0.08);
    color: #e8eef4;
}
[data-theme="dark"] .global-music-sheet__shuffle.is-on,
body.theme-dark .global-music-sheet__shuffle.is-on {
    background: rgba(46, 125, 50, 0.28);
    color: #c8e6c9;
}
[data-theme="dark"] .global-music-sheet__ctrl,
body.theme-dark .global-music-sheet__ctrl {
    color: #e8eef4;
}
[data-theme="dark"] .global-music-sheet__queue,
body.theme-dark .global-music-sheet__queue {
    border-top-color: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .global-music-sheet__queue-item.is-active,
body.theme-dark .global-music-sheet__queue-item.is-active {
    background: rgba(46, 125, 50, 0.22);
}

/* Раздел Медиа */
.media-main { gap: 12px; padding-bottom: 12px; }
body.has-global-music #media-view .media-main {
    padding-bottom: 12px; /* место под плеер даёт .chat-wrap */
}
.media-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.media-hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-soft, #777);
}
.media-now {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(46,125,50,.14), rgba(46,125,50,.04));
    border: 1px solid rgba(46,125,50,.22);
}
.media-now.hidden { display: none; }
.media-now__art {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--bg-soft);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    overflow: hidden;
}
.media-now__art img { width: 100%; height: 100%; object-fit: cover; }
.media-now__meta { min-width: 0; flex: 1; }
.media-now__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-soft);
    margin-bottom: 4px;
}
.media-now__title {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.25;
}
.media-now__artist {
    font-size: 13px;
    color: var(--text-soft);
    margin-top: 2px;
}
.media-now__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.media-library {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--border, var(--primary-soft));
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg);
}
.media-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.45;
}
.media-track {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border, var(--primary-soft));
    background: transparent;
    text-align: left;
    padding: 10px 12px;
    cursor: pointer;
    color: inherit;
    font: inherit;
}
.media-track:last-child { border-bottom: 0; }
.media-track:hover,
.media-track--active { background: var(--bg-soft); }
.media-track__art {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-soft);
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}
.media-track__meta { flex: 1; min-width: 0; }
.media-track__title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.media-track__artist {
    font-size: 12px;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.media-track__del {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: var(--text-soft);
    font-size: 18px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    border-radius: 8px;
}
.media-track__del:hover { color: #c62828; background: var(--danger-bg, rgba(198,40,40,.08)); }
.music-track__actions {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
}
.music-track__act {
    border: 0;
    background: var(--bg-soft);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    font-size: 14px;
}
.attach-preview__music {
    display: flex;
    align-items: center;
    gap: 10px;
}
.attach-preview__music-art {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
}

/* Превью приватного чата (без авто-заявки) */
.private-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    padding: 28px 20px 40px;
    min-height: 55vh;
    box-sizing: border-box;
}
.private-gate__avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--border, #ddd);
}
.private-gate__lock {
    font-size: 28px;
    line-height: 1;
}
.private-gate__title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}
.private-gate__desc {
    margin: 0;
    max-width: 360px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--muted, #777);
    white-space: pre-wrap;
    word-break: break-word;
}
.private-gate__note {
    margin: 4px 0 0;
    max-width: 320px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text);
}
.private-gate__msg-label {
    display: block;
    width: 100%;
    max-width: 360px;
    text-align: left;
    font-size: 13px;
    color: var(--muted, #777);
    margin: 10px 0 6px;
}
.private-gate__message {
    width: 100%;
    max-width: 360px;
    margin-bottom: 4px;
    min-height: 72px;
    resize: vertical;
}
.join-request-message {
    font-style: italic;
    color: var(--text, #1a1d23) !important;
    margin: 4px 0 !important;
    white-space: pre-wrap;
    word-break: break-word;
}
.private-gate__meta {
    font-size: 13px;
    color: var(--muted, #888);
}
.private-gate__btn {
    margin-top: 8px;
    min-width: 220px;
}
.private-gate__btn:disabled {
    opacity: 0.7;
    cursor: default;
}
.private-gate__btn--cancel {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border, #ccc);
    box-shadow: none;
}
.private-gate__btn--cancel:hover {
    background: var(--primary-soft, rgba(0, 0, 0, 0.06));
}
.private-gate__back {
    margin-top: 4px;
    border: 0;
    background: transparent;
    color: var(--muted, #888);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 12px;
}
.chat-view--private-gate .chat-input,
.chat-view--private-gate #attach-preview,
.chat-view--private-gate #reply-preview,
.chat-view--private-gate #emoji-panel,
.chat-view--private-gate #typing-indicator,
.chat-view--private-gate #pinned-bar,
.chat-view--private-gate #crocodile-bar,
.chat-view--private-gate #scroll-bottom-btn {
    display: none !important;
}



/* Просмотр фото на весь экран */
.media-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

/* Кнопка «Скачать» в полноэкранном просмотре */
.media-viewer__download {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: 72px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 22px;
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.media-viewer__download:hover { background: rgba(255, 255, 255, 0.3); }

.media-viewer__img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    cursor: zoom-in;
    transition: transform 0.15s ease;
    transform-origin: center center;
    will-change: transform;
}

.media-viewer__video {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    background: #000;
}

.media-viewer__close {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

/* --------------------------- Адаптивность ------------------------------ */
@media (max-width: 600px) {
    .chat-wrap {
        height: 100dvh;
    }
    .chat-header {
        gap: 4px;
        padding: 6px 8px;
        padding-top: max(6px, env(safe-area-inset-top));
    }
    .chat-header__title {
        font-size: 15px;
    }
    .chat-header__title small {
        font-size: 11px;
    }
    .chat-header__info {
        gap: 8px;
        padding: 2px 6px 2px 2px;
    }
    .chat-header__room {
        font-size: 15px;
    }
    .chat-header__meta {
        font-size: 11px;
    }
    .chat-header__avatar {
        width: 34px;
        height: 34px;
    }
    .chat-header__btn {
        min-width: 36px;
        min-height: 36px;
        padding: 4px 6px;
        font-size: 17px;
    }
    .msg {
        max-width: 92%;
    }
    .msg__bubble {
        font-size: 14px;
    }
    .modal {
        padding: 20px 18px;
    }
}

/* Очень узкие экраны (маленькие телефоны) */
@media (max-width: 360px) {
    .chat-header {
        gap: 2px;
        padding: 5px 6px;
    }
    .chat-header__title {
        font-size: 14px;
    }
    .chat-header__title small {
        font-size: 10px;
    }
    .chat-header__room {
        font-size: 14px;
    }
    .chat-header__meta {
        font-size: 10px;
        gap: 3px;
    }
    .chat-header__avatar {
        width: 30px;
        height: 30px;
    }
    .chat-header__btn {
        min-width: 32px;
        min-height: 32px;
        font-size: 16px;
    }
}

/* Узкие экраны: прячем @ник в шапке — остаётся онлайн */
@media (max-width: 420px) {
    .chat-header__meta #header-name,
    .chat-header__meta-sep {
        display: none;
    }
}

/* Планшеты и десктоп */
@media (min-width: 768px) {
    :root { --maxw: 860px; }
    .chat-wrap {
        height: 100vh;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
    html.balabol-app .chat-wrap {
        max-width: 960px;
        border: none;
    }
    .chat-header {
        gap: 8px;
        padding: 10px 14px;
        padding-top: max(10px, env(safe-area-inset-top));
    }
    .chat-header__title {
        font-size: 18px;
    }
    .chat-header__room {
        font-size: 17px;
    }
    .chat-header__avatar {
        width: 40px;
        height: 40px;
    }
    .chat-header__dropdown {
        min-width: 240px;
    }
    .home-nav {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    .home-nav__item {
        padding: 18px 16px;
        min-height: 96px;
    }
    .home-nav__item--wide { grid-column: auto; }
    .home-hello__greet { font-size: 26px; }
    .home-main { padding: 18px 22px 36px; }
    .rooms-list { gap: 12px; }
    .room-card { padding: 18px; }
}

/* Широкие планшеты / landscape */
@media (min-width: 1024px) {
    :root { --maxw: 980px; }
    html.balabol-app .chat-wrap { max-width: 1100px; }
    .home-nav { grid-template-columns: repeat(4, 1fr); }
}


/* ----------------------------- Упоминания ----------------------------- */
.mention {
    color: var(--primary);
    font-weight: 600;
    background: rgba(91, 139, 239, 0.12);
    border-radius: 4px;
    padding: 0 2px;
    cursor: pointer;
}

.mention--me {
    background: rgba(91, 139, 239, 0.28);
    color: #fff;
}

.msg--me .mention {
    color: #fff;
    background: rgba(255, 255, 255, 0.22);
}

.msg--me .mention--me {
    background: rgba(255, 255, 255, 0.4);
    color: #fff;
}

/* --------------------------- Автодополнение --------------------------- */
.autocomplete {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
    margin-bottom: 4px;
    z-index: 50;
}

.autocomplete.show {
    display: block;
}

.autocomplete__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    min-height: 44px;
    box-sizing: border-box;
}

.autocomplete__item:hover,
.autocomplete__item.active {
    background: var(--bg);
}

.autocomplete__nick {
    font-weight: 600;
    font-size: 14px;
}

.autocomplete__name {
    color: #8a717f;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --------------------------- Бейдж непрочитанных ---------------------- */
.unread-badge {
    display: inline-block;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    text-align: center;
    margin-left: 6px;
    vertical-align: middle;
}

.unread-badge.hidden {
    display: none;
}

/* ----------------------- Кнопка «к последним» -------------------------- */
.scroll-bottom-btn {
    position: absolute;
    bottom: 80px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    z-index: 40;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s, opacity 0.2s;
    animation: scrollBtnIn 0.2s ease;
}
@keyframes scrollBtnIn {
    from { opacity: 0; transform: scale(0.7); }
    to { opacity: 1; transform: scale(1); }
}
.scroll-bottom-btn.hidden {
    display: none;
}
.scroll-bottom-btn:active {
    transform: scale(0.92);
}
.scroll-bottom-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}
.scroll-bottom-badge.hidden {
    display: none;
}

/* --------------------------- Индикатор «печатает…» -------------------- */
.typing-indicator {
    flex: 0 0 auto;
    padding: 6px 16px;
    font-size: 12px;
    color: var(--text-soft);
    background: var(--bg-soft);
    border-top: 1px solid var(--border);
}

.typing-indicator.hidden {
    display: none;
}

.typing-indicator__inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.typing-indicator__avatars {
    display: flex;
    flex: 0 0 auto;
}

.typing-indicator__avatars .typing-indicator__avatar:not(:first-child) {
    margin-left: -6px;
}

.typing-indicator__avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--bg-soft);
}

.typing-indicator__avatar--initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
}

.typing-indicator__text {
    font-style: italic;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.typing-indicator__dots {
    display: inline-flex;
    gap: 3px;
    flex: 0 0 auto;
}

.typing-indicator__dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-soft);
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-indicator__dot:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* --------------------------- Закреплённое сообщение ------------------- */
/* Статус соединения — тонкая полоска под шапкой */
.conn-status {
    flex: 0 0 auto;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    letter-spacing: 0.01em;
    transition: background 0.2s, color 0.2s;
}
.conn-status.hidden { display: none; }
.conn-status--wait {
    background: #fff3cd;
    color: #856404;
}
.conn-status--offline {
    background: #f8d7da;
    color: #721c24;
}
.conn-status--ok {
    background: #d4edda;
    color: #155724;
}
[data-theme="dark"] .conn-status--wait {
    background: #4a3c14;
    color: #ffe08a;
}
[data-theme="dark"] .conn-status--offline {
    background: #4a1c22;
    color: #f5a5ae;
}
[data-theme="dark"] .conn-status--ok {
    background: #1e3d2f;
    color: #8fd4a8;
}

.pinned-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--pinned-bg);
    border-bottom: 1px solid var(--pinned-border);
    font-size: 13px;
    min-width: 0;
}

.pinned-bar.hidden {
    display: none;
}

.pinned-bar__icon {
    font-size: 16px;
    flex: 0 0 auto;
}

.pinned-bar__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 6px;
    overflow: hidden;
}

.pinned-bar__name {
    font-weight: 600;
    flex: 0 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 40%;
}

.pinned-bar__text {
    color: var(--text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

.pinned-bar__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.pinned-bar__goto,
.pinned-bar__unpin {
    background: none;
    border: 1px solid var(--pinned-border);
    color: var(--pinned-accent);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    flex: 0 0 auto;
    min-height: 32px;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.pinned-bar__goto:hover {
    background: var(--hover-soft);
}

.pinned-bar__unpin {
    color: var(--danger-color);
    border-color: var(--danger-border);
}

.pinned-bar__unpin:hover {
    background: var(--danger-bg);
}

/* Кнопка «Закрепить» в сообщении */
.msg__pin-btn:hover {
    background: var(--hover-soft);
    color: var(--pinned-accent);
}

/* --------------------------- Разделитель по дням ---------------------- */
.day-separator {
    align-self: center;
    margin: 12px 0 6px;
    text-align: center;
}

.day-separator__label {
    display: inline-block;
    font-size: 12px;
    color: var(--text-soft);
    background: var(--primary-soft);
    padding: 4px 14px;
    border-radius: 12px;
    font-weight: 500;
}

/* --------------------------- Поиск по сообщениям ---------------------- */
.search-results {
    max-height: 50vh;
    overflow-y: auto;
    margin-top: 8px;
}

.search-results__empty {
    text-align: center;
    color: var(--text-soft);
    font-size: 13px;
    padding: 16px;
}

.search-result {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
    margin-bottom: 8px;
    transition: background 0.15s;
}

.search-result:hover {
    background: var(--bg);
}

.search-result__name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}

.search-result__text {
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result__mark {
    background: rgba(255, 213, 79, 0.55);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}
.search-result__time {
    font-size: 11px;
    color: var(--text-soft);
    margin-top: 2px;
}

/* --------------------------- Профиль чата ----------------------------- */
.chatinfo-modal {
    max-width: 460px;
}

.chatinfo-card__title {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-dark);
    text-align: center;
}

.chatinfo-card__desc {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--text);
    text-align: center;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.chatinfo-card__stats {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 16px;
}

.chatinfo-stat {
    font-size: 13px;
    color: var(--text-soft);
}

.chatinfo-stat b {
    color: var(--primary-dark);
    font-size: 15px;
}

.chatinfo-card__edit {
    margin-top: 8px;
}
.chatinfo-card__danger {
    margin-top: 8px;
    background: var(--danger, #e53935);
    color: #fff;
    border: none;
}
.chatinfo-card__danger:hover { background: #c62828; }


.chatinfo-card__back {
    margin-top: 12px;
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.chatinfo-card__subtitle {
    margin: 18px 0 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-dark);
}

.chatinfo-members {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
}

.chatinfo-member {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
}

.chatinfo-member:hover {
    background: var(--bg);
}

.chatinfo-member__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
}

.chatinfo-member__info {
    flex: 1 1 auto;
    min-width: 0;
}

.chatinfo-member__name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chatinfo-member__nick {
    font-size: 12px;
    color: var(--text-soft);
}

.chatinfo-member__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #c5cad1;
    flex: 0 0 auto;
}

.chatinfo-member__dot--on {
    background: #4caf50;
}

.chatinfo-member__remove {
    background: none;
    border: 1px solid var(--danger-border);
    color: var(--danger-color);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 8px;
    cursor: pointer;
    flex: 0 0 auto;
}

.chatinfo-member__remove:hover {
    background: var(--danger-bg);
}

.chatinfo-member__self {
    font-size: 12px;
    color: var(--text-soft);
    font-style: italic;
    flex: 0 0 auto;
}

.chatinfo-admin-add {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.chatinfo-admin-select {
    flex: 1 1 auto;
}

.chatinfo-admin-add__btn {
    flex: 0 0 auto;
    margin-top: 0;
    width: auto;
    padding: 10px 18px;
}

/* Форум Балаболов — темы и треды, не чат */
.forum-main {
    gap: 0;
    max-width: 920px;
    margin: 0 auto;
    width: 100%;
    padding-bottom: 24px;
}

.forum-intro {
    margin: 0 0 14px;
    padding: 14px 16px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.1), rgba(46, 125, 50, 0.02));
    border: 1px solid rgba(46, 125, 50, 0.22);
}
.forum-intro__title {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.forum-intro__text {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
    color: var(--text-soft);
}

.forum-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: auto;
    margin: 0;
    padding: 7px 12px;
    border: 1px solid var(--primary-soft);
    border-radius: 10px;
    background: var(--bg-soft);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
}
.forum-btn:hover { background: var(--primary-soft); }
.forum-btn--primary {
    background: #2e7d32;
    border-color: #2e7d32;
    color: #fff;
}
.forum-btn--primary:hover { background: #1b5e20; filter: none; }
.forum-btn--ghost { background: transparent; }
.forum-btn--danger {
    border-color: #e53935;
    color: #e53935;
    background: transparent;
}

.forum-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.forum-toolbar--foot {
    margin-top: 14px;
    margin-bottom: 0;
    justify-content: center;
}
.forum-search {
    display: flex;
    flex: 1 1 220px;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.forum-search__input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 11px;
    border: 1px solid var(--primary-soft);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
}

.forum-table-head {
    display: none;
    grid-template-columns: 40px minmax(0, 1fr) 72px 150px;
    gap: 10px 12px;
    padding: 6px 14px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-soft);
}
.forum-table-head .forum-col--topic { grid-column: 2; }
@media (min-width: 760px) {
    .forum-table-head { display: grid; }
}

.forum-topics {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border, var(--primary-soft));
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg);
}
.forum-empty {
    padding: 28px 18px;
    text-align: center;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.45;
}

.forum-topic {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border, var(--primary-soft));
    cursor: pointer;
    transition: background 0.12s;
    align-items: start;
}
.forum-topic:last-child { border-bottom: none; }
.forum-topic:hover { background: var(--bg-soft); }
.forum-topic--pinned { background: rgba(46, 125, 50, 0.06); }
.forum-topic__icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-soft);
    font-size: 16px;
}
.forum-topic__main { min-width: 0; }
.forum-topic__title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.forum-topic__title {
    margin: 0;
    font-weight: 700;
    font-size: 15px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}
.forum-topic__excerpt {
    margin: 4px 0 0;
    font-size: 13px;
    line-height: 1.35;
    color: var(--text-soft);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.forum-topic__by {
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-soft);
}
.forum-topic__stats,
.forum-topic__last { display: none; }
.forum-topic__stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    color: var(--text-soft);
}
.forum-topic__stat b {
    font-size: 16px;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.forum-topic__last-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-soft);
}
.forum-topic__last-who {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.forum-topic__last-when {
    font-size: 12px;
    color: var(--text-soft);
}

.forum-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}
.forum-badge--pin {
    background: rgba(46, 125, 50, 0.16);
    color: #1b5e20;
}
.forum-badge--lock {
    background: rgba(120, 120, 120, 0.16);
    color: var(--text-soft);
}
html[data-theme="dark"] .forum-badge--pin,
body.theme-dark .forum-badge--pin { color: #a5d6a7; }

@media (min-width: 760px) {
    .forum-topic {
        grid-template-columns: 40px minmax(0, 1fr) 72px 150px;
        align-items: center;
    }
    .forum-topic__stats,
    .forum-topic__last { display: block; }
    .forum-topic__excerpt { -webkit-line-clamp: 1; }
}

.forum-crumb { margin: 0 0 10px; }
.forum-crumb__link {
    border: 0;
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 0;
    cursor: pointer;
}
.forum-crumb__link:hover { color: var(--primary); }

.forum-thread { margin-top: 0; }
.forum-thread__head {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border, var(--primary-soft));
}
.forum-thread__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.forum-thread__title {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.02em;
}
.forum-thread__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    font-size: 13px;
    color: var(--text-soft);
    margin-bottom: 10px;
}
.forum-thread__mod {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.forum-section-label {
    margin: 8px 0 4px;
    padding: 8px 4px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-soft);
}

.forum-posts {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.forum-post {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 0;
    border-radius: 14px;
    background: var(--bg);
    border: 1px solid var(--border, var(--primary-soft));
    overflow: hidden;
    transition: background 0.35s, box-shadow 0.35s;
}
.forum-post--op {
    border-color: rgba(46, 125, 50, 0.35);
    box-shadow: 0 1px 0 rgba(46, 125, 50, 0.08);
}
.forum-post--flash {
    background: var(--primary-soft);
    box-shadow: 0 0 0 2px var(--primary);
}
.forum-post__side {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 0;
}
.forum-post__avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    cursor: pointer;
    background: var(--primary-soft);
    flex: 0 0 auto;
}
.forum-post__name {
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}
.forum-post__nick {
    font-size: 12px;
    color: var(--text-soft);
}
.forum-post__role {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    color: #1b5e20;
    background: rgba(46, 125, 50, 0.12);
    padding: 3px 8px;
    border-radius: 999px;
}
html[data-theme="dark"] .forum-post__role,
body.theme-dark .forum-post__role { color: #a5d6a7; }
.forum-post__content {
    padding: 8px 14px 12px;
    min-width: 0;
}
.forum-post__top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-soft);
}
.forum-post__num {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
.forum-post__body {
    font-size: 15px;
    line-height: 1.55;
    word-wrap: break-word;
}
.forum-post__body a {
    color: var(--primary);
    word-break: break-all;
}
.forum-post__quote {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
    text-align: left;
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 0;
    border-left: 3px solid #2e7d32;
    border-radius: 0 10px 10px 0;
    background: var(--bg-soft);
    cursor: pointer;
    font: inherit;
    color: inherit;
}
.forum-post__quote-name {
    font-size: 12px;
    font-weight: 700;
    color: #1b5e20;
}
html[data-theme="dark"] .forum-post__quote-name,
body.theme-dark .forum-post__quote-name { color: #a5d6a7; }
.forum-post__quote-text {
    font-size: 13px;
    color: var(--text-soft);
    line-height: 1.35;
}
.forum-post__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--border, var(--primary-soft));
}
.forum-post__actions .forum-btn {
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 600;
    box-shadow: none;
}
.forum-post__actions .forum-btn:hover {
    background: transparent;
    color: var(--primary);
}
.forum-post__actions .forum-btn--danger { color: #c62828; }
.forum-post__actions .forum-btn--danger:hover { color: #e53935; }

@media (min-width: 720px) {
    .forum-post {
        grid-template-columns: 140px minmax(0, 1fr);
    }
    .forum-post__side {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 16px 12px;
        background: var(--bg-soft);
        border-right: 1px solid var(--border, var(--primary-soft));
    }
    .forum-post__role { margin-left: 0; margin-top: 4px; }
    .forum-post__avatar { width: 56px; height: 56px; }
    .forum-post__content { padding: 14px 16px; }
}

.forum-locked-note {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg-soft);
    color: var(--text-soft);
    font-size: 13px;
    text-align: center;
}

.forum-load-more-posts {
    align-self: center;
    margin: 8px auto 4px;
    display: flex;
}

.forum-composer {
    position: sticky;
    bottom: 0;
    z-index: 4;
    margin-top: 16px;
    padding: 12px 14px 10px;
    border: 1px solid var(--border, var(--primary-soft));
    border-radius: 14px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.04);
}
.forum-composer__title {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
}
.forum-composer .modal__textarea { min-height: 96px; }
.forum-composer__send {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.forum-composer__send-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.forum-composer__hint {
    font-size: 11px;
    color: var(--text-soft);
}
.forum-composer .reply-preview { position: relative; }
.forum-composer .modal__btn,
.forum-composer .forum-btn {
    width: auto;
    align-self: flex-start;
}

.forum-post__edit-box {
    width: 100%;
    min-height: 80px;
    margin: 0;
}
.forum-post__edit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.dm-peer-info__mute {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    font-size: 16px;
    cursor: pointer;
}

.dm-peer-info__mute:hover {
    background: var(--bg-soft);
}

#chat-title {
    cursor: pointer;
    transition: color 0.15s;
}

#chat-title:hover {
    color: var(--primary);
}

/* DM badge */
.dm-badge { display: inline-block; background: #e53935; color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px; border-radius: 8px; text-align: center; position: absolute; top: 2px; right: 2px; }
.dm-badge.hidden { display: none; }

/* DM */
.dm-modal { max-width: 480px; padding: 16px; }
.dm-view.hidden { display: none; }
.dm-dialogs { max-height: 50vh; overflow-y: auto; margin-bottom: 12px; }
.dm-dialog { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-sm); cursor: pointer; position: relative; }
.dm-dialog:hover { background: var(--bg); }
.dm-dialog--unread { background: var(--primary-soft); }
.dm-dialog--bot { border: 1px solid var(--primary-soft); }

/* Панель Чатикуса в инфо чата */
.bot-panel { margin: 12px 0 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.bot-panel__status { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.bot-panel__chip {
    font-size: 12px;
    color: var(--text-soft);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 10px;
}
.bot-panel__chip--on {
    color: var(--primary-dark, #4a3a8a);
    border-color: var(--primary-soft);
    background: var(--primary-soft);
}
.bot-panel__toggles { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.bot-panel__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}
.bot-panel__hint {
    font-size: 12px;
    color: var(--text-soft);
    margin: 6px 0 10px;
}
.bot-panel__textblock { margin-bottom: 12px; }
.bot-panel__label { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.bot-panel__textarea {
    width: 100%;
    min-height: 72px;
    resize: vertical;
    font-family: inherit;
}
.bot-panel__actions { display: flex; gap: 8px; margin-top: 6px; }
.bot-panel__actions .modal__btn { width: auto; flex: 1; padding: 8px 12px; }
.bot-panel__btn-muted { opacity: 0.85; }

.botsetup-modal { max-width: 440px; width: calc(100% - 24px); max-height: 86vh; overflow: auto; }
.botsetup-card { padding: 4px 2px 8px; }
.botsetup-title { font-size: 18px; font-weight: 700; margin: 0 0 6px; }
.botsetup-hint { font-size: 13px; color: var(--text-soft); margin: 0 0 12px; line-height: 1.35; }
.botsetup-back {
    display: inline-flex; align-items: center;
    margin: 0 0 10px; padding: 0;
    border: none; background: none;
    color: var(--primary); font-size: 14px; cursor: pointer;
}
.botsetup-room {
    display: flex; align-items: center; gap: 10px;
    width: 100%; text-align: left;
    padding: 10px 12px; margin-bottom: 8px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--bg); cursor: pointer; color: inherit;
}
.botsetup-room:hover { border-color: var(--primary); }
.botsetup-room__av {
    width: 42px; height: 42px; border-radius: 12px;
    object-fit: cover; flex: 0 0 auto; background: var(--bg-soft);
}
.botsetup-room__body { min-width: 0; flex: 1; }
.botsetup-room__name { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.botsetup-room__meta { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.botsetup-room__go { color: var(--text-soft); font-size: 18px; }
.dm-peer-info__setup {
    background: none; border: 1px solid var(--border); color: var(--text);
    font-size: 13px; font-weight: 650; height: 34px; padding: 0 10px;
    border-radius: 17px; cursor: pointer; flex: 0 0 auto;
    white-space: nowrap;
}
.dm-peer-info__setup:hover { border-color: var(--primary); color: var(--primary); }

.dm-dialog__avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.dm-dialog__info { flex: 1 1 auto; min-width: 0; }
.dm-dialog__name { font-weight: 600; font-size: 14px; }
.dm-dialog__last { font-size: 12px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-dialog__time { position: absolute; top: 10px; right: 12px; font-size: 10px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.dm-dialog__badge { background: #e53935; color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; border-radius: 9px; text-align: center; flex: 0 0 auto; }
.dm-back { background: none; border: none; color: var(--primary-dark); font-size: 14px; cursor: pointer; padding: 4px 0; margin-bottom: 8px; }
/* Шапка собеседника */
.dm-peer-info { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.dm-peer-info__avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; cursor: pointer; border: 2px solid var(--primary-soft); transition: transform .12s; flex: 0 0 auto; }
.dm-peer-info__avatar:hover { transform: scale(1.06); }
.dm-peer-info__text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.dm-peer-info__name { font-weight: 700; font-size: 15px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-peer-info__name:hover { text-decoration: underline; }
.dm-peer-info__nick { font-size: 12px; color: var(--text-soft); }
.dm-peer-info__count { font-size: 11px; color: var(--text-soft); margin-top: 1px; }
.dm-peer-info__delete { background: none; border: 1px solid var(--border); color: var(--danger-color); font-size: 15px; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; transition: background .15s, border-color .15s; }
.dm-peer-info__delete:hover { background: var(--danger-bg); border-color: var(--danger-color); }

/* Лента сообщений */
.dm-messages { max-height: 48vh; min-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; padding: 6px 4px; }

/* Разделитель даты */
.dm-day { align-self: center; font-size: 11px; color: var(--text-soft); background: var(--primary-soft); padding: 3px 12px; border-radius: 10px; margin: 10px 0 6px; font-weight: 600; }

/* Сообщение */
.dm-msg { position: relative; display: flex; flex-direction: column; max-width: 78%; align-self: flex-start; align-items: flex-start; }
.dm-msg--mine { align-self: flex-end; align-items: flex-end; }
.dm-msg__bubble { padding: 8px 12px; border-radius: 16px; border-bottom-left-radius: 5px; font-size: 14px; line-height: 1.45; background: var(--bubble-other); color: var(--bubble-other-text); box-shadow: 0 1px 2px rgba(0,0,0,0.06); word-wrap: break-word; overflow-wrap: anywhere; }
.dm-msg--mine .dm-msg__bubble { background: var(--bubble-me); color: var(--bubble-me-text); border-bottom-left-radius: 16px; border-bottom-right-radius: 5px; }
.dm-msg__bubble a { color: inherit; text-decoration: underline; }
.dm-msg__meta { display: flex; align-items: center; gap: 5px; margin: 2px 6px 0; }
.dm-msg--mine .dm-msg__meta { flex-direction: row-reverse; }
.dm-msg__time { font-size: 10px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.dm-msg__status { font-size: 11px; color: var(--text-soft); font-weight: 700; line-height: 1; }
.dm-msg__status--read { color: #2f9e44; }
/* Кнопка удаления — по наведению на сообщение */
.dm-msg__del { position: absolute; top: 0; background: var(--bg-soft); border: 1px solid var(--border); color: var(--danger-color); font-size: 11px; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .12s; display: flex; align-items: center; justify-content: center; z-index: 2; }
.dm-msg--mine .dm-msg__del { left: -30px; }
.dm-msg:not(.dm-msg--mine) .dm-msg__del { right: -30px; }
.dm-msg:hover .dm-msg__del { opacity: 1; pointer-events: auto; }
@media (hover: none) {
    .dm-msg__del {
        opacity: 0.9;
        pointer-events: auto;
    }
}
.dm-msg__del:hover { background: var(--danger-bg); }

/* Пустое состояние диалога */
.dm-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 40px 20px; margin: auto; text-align: center; }
.dm-empty__icon { font-size: 44px; opacity: .5; }
.dm-empty__title { font-size: 15px; font-weight: 700; color: var(--primary-dark); }
.dm-empty__hint { font-size: 13px; color: var(--text-soft); }

/* Форма ввода */
.dm-form { display: flex; gap: 8px; align-items: flex-end; }
.dm-form__attach {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dm-form__attach:active { transform: scale(.94); }
.dm-form__input { flex: 1 1 auto; resize: none; border: 1px solid var(--border); border-radius: 18px; padding: 10px 14px; font-size: 14px; font-family: inherit; line-height: 1.4; background: var(--bg-soft); color: var(--text); max-height: 120px; overflow-y: auto; box-sizing: border-box; transition: border-color .15s; }
.dm-form__input:focus { outline: none; border-color: var(--primary); }
.dm-form__send { flex: 0 0 auto; width: 42px; height: 42px; border: none; border-radius: 50%; background: var(--primary); color: #fff; font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s, transform .1s; }
.dm-form__send:hover { background: var(--primary-dark); }
.dm-form__send:active { transform: scale(.94); }
.dm-attach-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 8px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
}
.dm-attach-preview.hidden { display: none; }
.dm-attach-preview__thumb {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    flex: 0 0 auto;
}
.dm-attach-preview__info { flex: 1 1 auto; min-width: 0; }
.dm-attach-preview__name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dm-attach-preview__size { font-size: 11px; color: var(--text-soft); }
.dm-attach-preview__close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-soft);
    font-size: 18px;
    cursor: pointer;
}
.dm-msg__bubble .msg__media { margin-top: 4px; }
.dm-msg__bubble .msg__media:first-child { margin-top: 0; }

/* Полноэкранный раздел сообщений */
#dm-overlay-host {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.dm-page {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}
.dm-shared {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}
.dm-shared[hidden] { display: none !important; }
.dm-shared--page {
    height: 100%;
    padding: 0 12px 12px;
    box-sizing: border-box;
}
.dm-shared--page .dm-view {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.dm-shared--page .dm-view.hidden { display: none !important; }
.dm-shared--page .dm-dialogs,
.dm-shared--page #dm-new-list {
    flex: 1 1 auto;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 10px;
}
.dm-shared--page .dm-messages {
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.dm-shared--page .dm-form {
    flex: 0 0 auto;
    padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
}
.dm-shared--page .dm-peer-info {
    flex: 0 0 auto;
}
.dm-shared--page .modal__btn {
    flex: 0 0 auto;
}
.dm-page-view .chat-header__title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Polls */
.polls-container { flex: 0 0 auto; padding: 8px 16px; display: flex; flex-direction: column; gap: 8px; }
.polls-container:empty { display: none; }
.poll-card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; }
.poll-card__question { font-weight: 600; font-size: 14px; margin-bottom: 8px; color: var(--primary-dark); }
.poll-option { position: relative; padding: 8px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 4px; overflow: hidden; background: var(--primary-soft); transition: background 0.15s; }
.poll-option:hover { background: var(--hover-soft); }
.poll-option--mine { background: var(--poll-mine); }
.poll-option--locked { cursor: default; opacity: 0.95; }
.poll-option--locked:not(.poll-option--mine):hover { background: transparent; }
.poll-option__bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(91, 139, 239, 0.2); z-index: 0; }
.poll-option__text, .poll-option__count { position: relative; z-index: 1; }
.poll-option__text { font-size: 13px; }
.poll-option__count { float: right; font-size: 12px; color: var(--text-soft); font-weight: 600; }
.poll-card__meta { font-size: 11px; color: var(--text-soft); margin-top: 6px; }
.poll-card__close { background: none; border: 1px solid var(--border); color: var(--text-soft); font-size: 12px; padding: 4px 10px; border-radius: 8px; cursor: pointer; margin-top: 6px; }
.poll-card__close:hover { background: var(--bg); }
.poll-card__closed-badge { font-size: 12px; color: var(--text-soft); margin-top: 6px; font-style: italic; }
.poll-card__actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.poll-card__delete { background: none; border: 1px solid #e53935; color: #e53935; font-size: 12px; padding: 4px 10px; border-radius: 8px; cursor: pointer; }
.poll-card__delete:hover { background: rgba(229, 57, 53, 0.1); }

/* Link preview */
.msg-link {
    color: var(--primary-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.dm-msg__bubble a.msg-link {
    color: var(--primary-dark);
}
.link-insert__label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-soft);
    margin: 10px 0 4px;
}
#overlay-insert-link {
    z-index: 130;
}
#overlay-insert-link .modal__input {
    width: 100%;
    box-sizing: border-box;
}
@media (max-width: 360px) {
    .chat-input {
        gap: 4px;
    }
    .chat-input__emoji {
        min-width: 36px;
        min-height: 36px;
        padding: 4px;
        font-size: 18px;
    }
}
.msg__link-preview { margin-top: 6px; }
.link-preview { display: flex; gap: 10px; padding: 10px; border-radius: 10px; background: var(--primary-soft); border: 1px solid var(--border); text-decoration: none; color: var(--text); max-width: 100%; overflow: hidden; transition: background 0.15s; }
.link-preview:hover { background: var(--link-hover); }
.link-preview__img { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; }
.link-preview__body { flex: 1 1 auto; min-width: 0; }
.link-preview__title { font-weight: 600; font-size: 13px; color: var(--primary-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-preview__desc { font-size: 12px; color: var(--text-soft); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-preview__url { font-size: 11px; color: var(--primary); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* СТАРТОВАЯ СТРАНИЦА (ЛЕНДИНГ) */
.landing { flex: 1; overflow-y: auto; width: 100%; box-sizing: border-box; padding-bottom: 32px; }
.landing-header { background: transparent; }
.landing-header__btn { background: var(--primary); color: #fff; border-radius: 20px; padding: 6px 16px; font-weight: 600; }
.landing__hero { position: relative; padding: 40px 20px 32px; text-align: center; overflow: hidden; }
.landing__hero-bg { position: absolute; inset: 0; background: linear-gradient(135deg, var(--primary, #5b8def) 0%, #7e57c2 100%); opacity: .08; z-index: 0; }
.landing__hero-content { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; }
.landing__logo { font-size: 72px; margin-bottom: 12px; line-height: 1; }
.landing__title { font-size: 28px; font-weight: 800; color: var(--primary-dark); margin: 0 0 6px; letter-spacing: -.5px; }
.landing__tagline { font-size: 17px; font-weight: 600; color: var(--primary-dark); margin: 0 0 10px; opacity: .85; }
.landing__subtitle { font-size: 15px; color: var(--text-soft); line-height: 1.55; margin: 0 auto 16px; max-width: 380px; }
.landing__trust {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
    max-width: 400px;
    margin: 0 auto 22px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(46, 125, 50, 0.1);
    border: 1px solid rgba(46, 125, 50, 0.28);
}
.landing__trust-icon {
    font-size: 22px;
    line-height: 1.2;
    flex: 0 0 auto;
}
.landing__trust-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.landing__trust-text b {
    font-size: 14px;
    font-weight: 800;
    color: #1b5e20;
    letter-spacing: -0.01em;
}
.landing__trust-text span {
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-soft);
}
.landing__pilot {
    display: inline-block;
    margin: -10px auto 20px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #0d47a1;
    background: rgba(25, 118, 210, 0.1);
    border: 1px solid rgba(25, 118, 210, 0.28);
}
[data-theme="dark"] .landing__trust,
body.theme-dark .landing__trust {
    background: rgba(165, 214, 167, 0.12);
    border-color: rgba(165, 214, 167, 0.28);
}
[data-theme="dark"] .landing__trust-text b,
body.theme-dark .landing__trust-text b {
    color: #a5d6a7;
}
[data-theme="dark"] .landing__pilot,
body.theme-dark .landing__pilot {
    color: #90caf9;
    background: rgba(144, 202, 249, 0.12);
    border-color: rgba(144, 202, 249, 0.3);
}
.landing__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; }
.landing__cta { background: var(--primary, #5b8def); color: #fff; border: none; border-radius: 24px; padding: 12px 28px; font-size: 15px; font-weight: 700; cursor: pointer; transition: transform .12s, box-shadow .12s; box-shadow: 0 4px 12px rgba(91,141,239,.3); }
.landing__cta:active { transform: scale(.97); }
.landing__cta--ghost { background: transparent; color: var(--primary, #5b8def); border: 2px solid var(--primary, #5b8def); box-shadow: none; padding: 10px 26px; }
.landing__stats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.landing__stat { background: var(--bg-card, #fff); border-radius: 12px; padding: 10px 18px; min-width: 80px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.landing__stat-num { font-size: 20px; font-weight: 800; color: var(--primary-dark); }
.landing__stat-label { font-size: 12px; color: var(--text-soft); }
.landing__features { display: grid; grid-template-columns: 1fr; gap: 12px; padding: 0 16px; max-width: 640px; margin: 0 auto; }
@media (min-width: 480px) { .landing__features { grid-template-columns: repeat(2, 1fr); } }
.landing__feature { background: var(--bg-card, #fff); border-radius: 14px; padding: 18px 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.landing__feature-icon { font-size: 28px; }
.landing__feature h3 { font-size: 15px; margin: 0; color: var(--primary-dark); }
.landing__feature p { font-size: 13px; color: var(--text-soft); margin: 0; line-height: 1.45; }
.landing__how { max-width: 640px; margin: 28px auto 0; padding: 0 16px; }
.landing__how-title { font-size: 18px; font-weight: 700; color: var(--primary-dark); margin: 0 0 14px; text-align: center; }
.landing__steps { display: flex; flex-direction: column; gap: 10px; }
.landing__step { display: flex; align-items: center; gap: 12px; background: var(--bg-card, #fff); border-radius: 12px; padding: 12px 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.landing__step-num { width: 32px; height: 32px; border-radius: 50%; background: var(--primary, #5b8def); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex: 0 0 auto; }
.landing__step-text { font-size: 14px; color: var(--primary-dark); }
.landing__bottom { text-align: center; padding: 32px 16px 8px; }

/* СПИСОК ЧАТОВ */
.rooms-main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; background: var(--bg, #f5f6f8); }
.rooms-tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--border, #eee); flex: 0 0 auto; background: var(--bg-soft, #fff); }
.rooms-tab { flex: 1; padding: 9px 6px; border: none; background: transparent; color: var(--text-soft); font-size: 13px; font-weight: 600; border-radius: 10px; cursor: pointer; transition: background .15s, color .15s; }
.rooms-tab:hover { background: var(--primary-soft); color: var(--primary-dark); }
.rooms-tab.active { background: var(--primary); color: #fff; }
.rooms-tab.active:hover { background: var(--primary-dark); color: #fff; }

/* Глобальная админка: вкладки и списки */
.admin-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
    background: var(--bg-soft);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.admin-tab {
    flex: 1 1 auto;
    min-width: max-content;
    padding: 9px 10px;
    border: none;
    background: transparent;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    white-space: nowrap;
}
.admin-tab:hover { background: var(--primary-soft); color: var(--primary-dark); }
.admin-tab.active { background: var(--primary); color: #fff; }
.admin-search { margin: 0 0 12px; width: 100%; }
.admin-quick {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}
.admin-list { display: flex; flex-direction: column; gap: 8px; }
.admin-list__item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
}
.admin-list__item--row {
    flex-direction: row;
    align-items: center;
}
.admin-list__head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.admin-list__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.chatinfo-stat--btn {
    border: 1px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    font: inherit;
    color: inherit;
    border-radius: 10px;
    padding: 8px 10px;
}
.chatinfo-stat--btn:hover {
    background: var(--primary-soft);
}
.rooms-panel { flex: 1 1 auto; overflow-y: auto; padding: 14px; }
.rooms-geo { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; background: var(--bg-soft, #fff); padding: 12px; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.rooms-geo__status { font-size: 13px; color: var(--text-soft); }
.rooms-list { display: flex; flex-direction: column; gap: 10px; }
.room-card { background: var(--bg-soft, #fff); border-radius: 14px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); cursor: pointer; transition: transform .12s, box-shadow .15s, border-color .15s; border: 1px solid var(--border, transparent); }
.room-card:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.1); border-color: var(--primary-soft); }
.room-card:active { transform: scale(.99); }
.room-card--default { border-color: var(--primary); background: linear-gradient(135deg, var(--primary-soft) 0%, var(--bg-soft, #fff) 60%); }
.room-card--list { padding: 12px 14px; border-radius: 12px; }
.room-card--list .room-card__header { align-items: center; }
.room-card--pinned { order: -1; }
.room-card--unread .room-card__preview { color: var(--text); font-weight: 500; }
.room-card__header { display: flex; align-items: flex-start; gap: 12px; }
.room-card__time {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--text-soft);
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}
.room-card__preview-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.room-card__preview {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    color: var(--text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.room-card__unread {
    flex: 0 0 auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
.room-card__icon { font-size: 28px; flex: 0 0 auto; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: var(--primary-soft); border-radius: 12px; }
.room-card--default .room-card__icon { background: var(--primary); }
.room-card__avatar {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    object-fit: cover;
    background: var(--primary-soft);
}
.room-card__body { flex: 1 1 auto; min-width: 0; }
.room-card__title { font-size: 16px; font-weight: 700; color: var(--primary-dark); margin: 0 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-card__desc { font-size: 13px; color: var(--text-soft); margin: 0 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }
.room-card__meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-soft); }
.room-card__meta span { display: inline-flex; align-items: center; gap: 3px; }
.room-card__distance { color: var(--primary); font-weight: 700; }
.room-card__address { font-size: 12px; color: var(--text-soft); margin-top: 6px; display: flex; align-items: center; gap: 3px; }
.room-card__owner { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
/* Свой чат — акцентная рамка */
.room-card--own { border-color: var(--primary); }
.room-card--own:hover { border-color: var(--primary-dark); }
/* Строка заголовка + бейдж владельца */
.room-card__title-row { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; }
.room-card__title-row .room-card__title { margin: 0; flex: 1 1 auto; min-width: 0; }
.room-card__badge {
    flex: 0 0 auto;
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
    color: #fff; background: var(--primary);
    padding: 2px 7px; border-radius: 8px; white-space: nowrap;
}
/* Кнопка удаления чата */
.room-card { position: relative; }
.room-card__delete {
    position: absolute; top: 10px; right: 10px;
    width: 32px; height: 32px; border-radius: 8px;
    border: none; background: rgba(229, 57, 53, 0.1); color: var(--danger, #e53935);
    font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .15s ease, background .15s ease, transform .12s ease;
    -webkit-tap-highlight-color: transparent;
}
.room-card:hover .room-card__delete,
.room-card--own .room-card__delete { opacity: 1; }
.room-card__delete:hover { background: var(--danger, #e53935); color: #fff; transform: scale(1.08); }
.room-card__delete:active { transform: scale(0.92); }
/* Онлайн-метка */
.room-card__meta-item--online { color: #2e7d32; font-weight: 600; }

.room-geo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rooms-empty { text-align: center; padding: 40px 20px; color: var(--text-soft); }
.rooms-empty__icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.rooms-empty__text { font-size: 15px; margin-bottom: 16px; }

/* ЛИЧНЫЙ КАБИНЕТ */
.cabinet-main { flex: 1; overflow-y: auto; padding: 16px; max-width: 640px; margin: 0 auto; width: 100%; box-sizing: border-box; background: var(--bg, #f5f6f8); }
.cabinet-profile { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; background: var(--bg-soft, #fff); padding: 20px; border-radius: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.cabinet-profile__head { display: flex; align-items: center; gap: 16px; }
.cabinet-profile__avatar-wrap { position: relative; flex: 0 0 auto; width: 80px; height: 80px; }
.cabinet-profile__avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; border: 3px solid var(--primary-soft); display: block; }
.cabinet-profile__avatar-edit {
    position: absolute; right: -2px; bottom: -2px;
    width: 30px; height: 30px; border-radius: 50%;
    border: 2px solid var(--bg-soft, #fff);
    background: var(--accent, #5b6b7d); color: #fff;
    font-size: 13px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.cabinet-profile__info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.cabinet-profile__name { font-size: 19px; font-weight: 700; color: var(--primary-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cabinet-profile__username { font-size: 13px; color: var(--text-soft); }
.cabinet-profile__email { font-size: 12px; color: var(--text-soft); }
.cabinet-profile__warn { font-size: 12px; color: #c62828; cursor: pointer; margin-top: 2px; }
.cabinet-profile__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.cabinet-profile__chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--bg, #f0f2f5); color: var(--text-soft); }
.cabinet-profile__bio { font-size: 14px; color: var(--text); line-height: 1.45; padding: 10px 12px; background: var(--primary-soft); border-radius: 10px; text-align: left; border: none; width: 100%; box-sizing: border-box; }
.cabinet-profile__bio--empty { color: var(--text-soft); font-style: italic; background: var(--bg, #f5f6f8); cursor: pointer; }
.cabinet-profile__stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.cabinet-profile__stat {
    background: var(--bg, #f5f6f8);
    border: 1px solid var(--border, #e5e8ec);
    border-radius: 12px;
    padding: 10px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cabinet-profile__stat b { font-size: 13px; color: var(--primary-dark); text-transform: capitalize; }
.cabinet-profile__stat span { font-size: 11px; color: var(--text-soft); }
/* Детали профиля (дата рождения, пол) */
.cabinet-profile__details { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; }
.cabinet-detail { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.cabinet-detail__icon { flex: 0 0 auto; font-size: 16px; width: 22px; text-align: center; }
.cabinet-detail__label { color: var(--text-soft); flex: 0 0 auto; }
.cabinet-detail__value { color: var(--text); font-weight: 600; margin-left: auto; text-align: right; }
.cabinet-detail__value--muted { color: var(--text-soft); font-weight: 400; font-style: italic; }
.cabinet-section-title { font-size: 15px; font-weight: 700; color: var(--primary-dark); margin: 0 0 12px; display: flex; align-items: center; gap: 6px; }
.cabinet-block {
    background: var(--bg-soft, #fff);
    border-radius: 16px;
    padding: 14px 14px 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.cabinet-block__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.cabinet-block__head .cabinet-section-title { margin: 0; }
.cabinet-block__more {
    border: none;
    background: transparent;
    color: var(--primary-dark);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 2px;
    white-space: nowrap;
}
.cabinet-block__more:active { opacity: 0.7; }
.rooms-list--cabinet {
    max-height: none;
}
.rooms-list--cabinet .room-card {
    margin-bottom: 6px;
}
.rooms-list--cabinet .room-card:last-child { margin-bottom: 0; }
.cabinet-rooms-more {
    width: 100%;
    margin-top: 6px;
    border: 1px dashed var(--border);
    background: var(--bg);
    color: var(--text-soft);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
}
.cabinet-inline-btn {
    width: 100%;
    margin-top: 8px;
    border: none;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
}
.cabinet-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.cabinet-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    min-height: 64px;
    -webkit-tap-highlight-color: transparent;
}
.cabinet-tile span {
    font-size: 18px;
    line-height: 1;
}
.cabinet-tile:active {
    transform: scale(0.98);
    background: var(--primary-soft);
}
.cabinet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.cabinet-actions--footer {
    margin-top: 4px;
    margin-bottom: 8px;
}
.cabinet-actions .modal__btn { width: 100%; text-align: left; display: flex; align-items: center; gap: 8px; justify-content: flex-start; }

.tos-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
}
.tos-check input { margin-top: 3px; flex: 0 0 auto; }
.tos-check a { color: var(--accent, #5b6b7d); text-decoration: underline; }

.landing__legal,
.site-legal {
    margin-top: 16px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 13px;
}
.landing__legal a,
.site-legal a {
    color: var(--text-soft, #6b7280);
    text-decoration: underline;
}
.site-legal a:hover {
    color: var(--text, #222);
}

.modal--terms {
    max-width: min(560px, 96vw);
    max-height: min(85vh, 720px);
    display: flex;
    flex-direction: column;
}
.terms-body {
    overflow-y: auto;
    flex: 1 1 auto;
    margin: 0 0 14px;
    padding-right: 4px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text, #222);
}
.terms-body h3 {
    margin: 16px 0 8px;
    font-size: 15px;
}
.terms-body p { margin: 0 0 8px; }
.terms-body__meta {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-soft, #6b7280);
}

/* ВЫБОР ПОЛА */
.gender-select { display: flex; gap: 10px; }
.gender-option { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 8px; border: 2px solid var(--border, #e2e6ea); border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.gender-option input { display: none; }
.gender-option__label { font-size: 14px; font-weight: 600; color: var(--text-soft); }
.gender-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.gender-option:has(input:checked) .gender-option__label { color: var(--primary-dark); }
.gender-option:has(input:checked) { border-color: var(--primary); }
.gender-option--m:has(input:checked) { border-color: #4a90d9; background: #e8f0fe; }
.gender-option--m:has(input:checked) .gender-option__label { color: #2c6fbd; }
.gender-option--f:has(input:checked) { border-color: #e91e63; background: #fce4ec; }
.gender-option--f:has(input:checked) .gender-option__label { color: #c2185b; }
.gender-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.gender-badge--m { background: #e8f0fe; color: #2c6fbd; }
.gender-badge--f { background: #fce4ec; color: #c2185b; }
/* В тёмной теме бейджи пола чуть темнее, чтобы не выбивались из фона */
[data-theme="dark"] .gender-badge--m { background: #1e3a5f; color: #9cc3f5; }
[data-theme="dark"] .gender-badge--f { background: #4a1d3a; color: #f5a8c9; }
[data-theme="dark"] .gender-option--m:has(input:checked) { background: #1e3a5f; }
[data-theme="dark"] .gender-option--m:has(input:checked) .gender-option__label { color: #9cc3f5; }
[data-theme="dark"] .gender-option--f:has(input:checked) { background: #4a1d3a; }
[data-theme="dark"] .gender-option--f:has(input:checked) .gender-option__label { color: #f5a8c9; }

/* --------------------------- Реакции на сообщения ---------------------- */
.msg__reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    align-items: center;
}
.reaction {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    border-radius: 14px;
    padding: 2px 8px;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
    transition: background .12s, border-color .12s, transform .1s;
    -webkit-tap-highlight-color: transparent;
}
.reaction:hover { background: var(--primary-soft); border-color: var(--primary); }
.reaction:active { transform: scale(.94); }
.reaction--mine {
    background: var(--primary-soft);
    border-color: var(--primary);
}
.reaction--mine:hover { background: var(--primary); color: #fff; }
.reaction--mine:hover .reaction__count { color: #fff; }
.reaction__emoji { font-size: 14px; }
.reaction__count { font-size: 11px; font-weight: 700; color: var(--text-soft); }
.reaction--add {
    border-style: dashed;
    color: var(--text-soft);
    font-weight: 700;
    padding: 2px 9px;
}
/* Наглядная кнопка-эмодзи для добавления реакции */
.reaction--add {
    border-style: solid;
    border-color: var(--border);
    font-size: 18px;
    font-weight: 400;
    padding: 2px 7px;
    line-height: 1;
    opacity: 0.65;
    transition: opacity .15s ease, transform .12s ease, background .15s ease, border-color .15s ease;
}
.reaction--add:hover {
    opacity: 1;
    background: var(--primary-soft);
    border-color: var(--primary);
    transform: scale(1.12);
}
.reaction--add:active { transform: scale(0.95); }
.reaction--add:hover { color: var(--primary-dark); }

/* Панель выбора реакции */
.reaction-picker {
    position: fixed;
    z-index: 5000;
    display: flex;
    gap: 4px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
    animation: reactPop .14s ease-out;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
@keyframes reactPop {
    from { opacity: 0; transform: translateY(6px) scale(.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.reaction-picker__item {
    border: none;
    background: transparent;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: background .14s ease, transform .14s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
.reaction-picker__item:hover {
    background: var(--primary-soft);
    transform: scale(1.3) translateY(-2px);
}
.reaction-picker__item:active { transform: scale(0.92); }

/* --------------------------- Индикатор «кем прочитано» ----------------- */
.msg__read-by {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-top: 0;
    font-size: 11px;
    color: var(--text-soft);
    opacity: .9;
    border: 0;
    background: transparent;
    padding: 0 2px;
    margin-left: 0;
    border-radius: 8px;
    cursor: default;
    font: inherit;
    -webkit-tap-highlight-color: transparent;
    flex: 0 0 auto;
    line-height: 1;
}
.msg__read-by:not(.msg__read-by--static) {
    cursor: pointer;
}
.msg__read-by:not(.msg__read-by--static):hover {
    background: rgba(0, 0, 0, 0.06);
    opacity: 1;
}
.msg__read-by-check {
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}
.msg__read-by--read .msg__read-by-check {
    color: #2f9e44;
}
.msg--me .msg__read-by { justify-content: flex-end; }

/* Список читателей: заголовок фиксирован, список листается */
.readers-sheet {
    display: flex;
    flex-direction: column;
    max-height: min(55vh, 380px);
    overflow: hidden;
    padding-bottom: 8px;
}
.readers-sheet .online-sheet__title {
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    background: var(--bg, #fff);
    z-index: 1;
    padding-bottom: 6px;
}
.readers-sheet__list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: min(46vh, 320px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.online-sheet__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 auto;
    background: var(--primary-soft);
}

/* =========================================================================
   Улучшения отображения: скроллбары, фокус, плавные переходы темы
   ========================================================================= */

/* Плавный переход цветов при переключении темы — без мерцания */
body, .chat-header, .chat-input, .modal, .overlay, .msg__bubble,
.chat-header__dropdown, .autocomplete, .emoji-panel, .toast,
.pinned-bar, .typing-indicator, .room-card, .cabinet-profile,
.landing__stat, .landing__feature, .landing__step, .rooms-geo,
.audio-player, .poll-card, .poll-option, .link-preview, .reaction {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* Кастомные скроллбары (WebKit) — аккуратные, под тему */
.chat-messages, .modal, .dm-messages, .dm-dialogs, .search-results,
.chatinfo-members, .rooms-panel, .cabinet-main, .landing,
.emoji-content, .autocomplete, .chat-header__dropdown {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.chat-messages::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.dm-messages::-webkit-scrollbar,
.dm-dialogs::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.chatinfo-members::-webkit-scrollbar,
.rooms-panel::-webkit-scrollbar,
.cabinet-main::-webkit-scrollbar,
.landing::-webkit-scrollbar,
.emoji-content::-webkit-scrollbar,
.autocomplete::-webkit-scrollbar,
.chat-header__dropdown::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.chat-messages::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track,
.dm-messages::-webkit-scrollbar-track,
.rooms-panel::-webkit-scrollbar-track,
.cabinet-main::-webkit-scrollbar-track,
.landing::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb,
.dm-messages::-webkit-scrollbar-thumb,
.rooms-panel::-webkit-scrollbar-thumb,
.cabinet-main::-webkit-scrollbar-thumb,
.landing::-webkit-scrollbar-thumb,
.emoji-content::-webkit-scrollbar-thumb,
.autocomplete::-webkit-scrollbar-thumb,
.chat-header__dropdown::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 8px;
}
.chat-messages::-webkit-scrollbar-thumb:hover,
.modal::-webkit-scrollbar-thumb:hover,
.rooms-panel::-webkit-scrollbar-thumb:hover,
.cabinet-main::-webkit-scrollbar-thumb:hover,
.landing::-webkit-scrollbar-thumb:hover {
    background: var(--text-soft);
}

/* Видимый фокус-контур для клавиатурной навигации (доступность) */
.chat-header__btn:focus-visible,
.chat-input__emoji:focus-visible,
.chat-input__send:focus-visible,
.modal__btn:focus-visible,
.modal__close:focus-visible,
.rooms-tab:focus-visible,
.room-card:focus-visible,
.landing__cta:focus-visible,
.poll-option:focus-visible,
.reaction:focus-visible,
.chat-header__menu-item:focus-visible,
.ctx-menu__item:focus-visible,
.autocomplete__item:focus-visible,
.emoji-panel__item:focus-visible,
.search-result:focus-visible,
.chatinfo-member:focus-visible,
.dm-dialog:focus-visible,
.toast__close:focus-visible,
.scroll-bottom-btn:focus-visible,
.audio-player__play:focus-visible,
.reaction-picker__item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Мягкий фокус-контур у полей ввода вместо жёсткого outline */
.chat-input__field:focus-visible,
.modal__input:focus-visible,
.modal__textarea:focus-visible,
.msg__edit-area:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-soft), 0 0 0 4px var(--primary);
}

/* Лендинг в тёмной теме */
[data-theme="dark"] .landing__hero-bg {
    background: linear-gradient(135deg, #3b6fd6 0%, #7e57c2 100%);
    opacity: .12;
}
[data-theme="dark"] .landing__cta {
    box-shadow: 0 4px 12px rgba(59, 111, 214, .35);
}

/* Уважение к prefers-reduced-motion: отключаем анимации */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Плавная прокрутка (если пользователь не отключил анимации) */
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* --------------------------- Запис аудио/видео -------------------------- */
.record-overlay { z-index: 1200; }
.record-modal {
    background: var(--bg, #fff);
    border-radius: 16px;
    width: min(420px, 94vw);
    max-width: 420px;
    padding: 0;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.record-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border, #eee);
}
.record-modal__title { font-weight: 600; font-size: 15px; }
.record-modal__close {
    background: none; border: none; font-size: 22px; cursor: pointer;
    color: var(--muted, #888); line-height: 1; padding: 0 4px;
}
.record-modal__close:hover { color: var(--danger, #e53935); }
.record-modal__stage {
    display: flex; align-items: center; justify-content: center;
    min-height: 180px; padding: 12px; background: #000;
}
.record-video-wrap {
    position: relative;
    width: 180px; height: 180px;
    border-radius: 12px; overflow: hidden;
    background: #000;
}
.record-video {
    width: 100%; height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}
.record-video__timer {
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 13px;
    padding: 3px 10px; border-radius: 12px; font-variant-numeric: tabular-nums;
}
.record-audio-wrap {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    color: #fff;
}
.record-audio__icon { font-size: 44px; line-height: 1; }
.record-audio__timer {
    font-size: 18px; font-variant-numeric: tabular-nums; font-weight: 600;
}
.record-audio__wave {
    display: flex; align-items: center; gap: 3px; height: 32px;
}
.record-audio__wave span {
    display: inline-block; width: 3px; background: #fff; border-radius: 2px;
    animation: rec-wave 0.9s ease-in-out infinite alternate;
}
@keyframes rec-wave {
    0% { height: 6px; opacity: 0.5; }
    100% { height: 36px; opacity: 1; }
}
.record-modal__controls {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    padding: 10px;
}
.record-btn {
    border: none; cursor: pointer; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform 0.12s ease, background 0.15s ease;
}
.record-btn:active { transform: scale(0.92); }
.record-btn--start {
    width: 52px; height: 52px; background: var(--danger, #e53935);
}
.record-btn--start .record-btn__dot {
    width: 20px; height: 20px; background: #fff; border-radius: 50%;
}
.record-btn--start.recording { background: #444; }
.record-btn--start.recording .record-btn__dot {
    border-radius: 4px; width: 18px; height: 18px;
}
.record-btn--stop {
    width: 44px; height: 44px; background: #444; color: #fff; font-size: 18px;
}
.record-btn--send {
    width: 44px; height: 44px; background: var(--primary, #5b8def); color: #fff; font-size: 18px;
}
.record-btn--send:hover { background: var(--primary-dark, #3f6fd6); }
.record-btn--cancel {
    width: 38px; height: 38px; background: rgba(0, 0, 0, 0.08); color: var(--danger, #e53935); font-size: 16px;
}
.record-btn--cancel:hover { background: rgba(229, 57, 53, 0.15); }
.record-preview {
    padding: 8px 12px; border-top: 1px solid var(--border, #eee);
    display: flex; flex-direction: column; gap: 6px;
}
.record-preview video,
.record-preview audio { width: 100%; max-width: 100%; }
.record-preview.hidden { display: none; }

/* Квадратное видеосообщение в ленте */
.msg__media-frame--square {
    width: 240px; max-width: 100%;
    aspect-ratio: 1 / 1;
}
.msg__media-frame--square .msg__media-video {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
@media (max-width: 480px) {
    .msg__media-frame--square { width: 200px; }
    .record-video-wrap { width: 160px; height: 160px; }
    .record-modal { width: min(360px, 94vw); }
}

/* =========================================================================
   Системные сообщения (справка, правила, уведомления)
   ========================================================================= */
.msg--system {
    justify-content: center;
    margin: 8px 0;
    transition: opacity 0.45s ease;
}

.msg--system.msg--system-fade {
    opacity: 0;
}

.msg__content--system {
    background: var(--bg-secondary, #f0f2f5);
    color: var(--text-soft, #656d78);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 85%;
    text-align: left;
    box-shadow: none;
    word-wrap: break-word;
    position: relative;
}

.msg__content--system b {
    color: var(--text, #222);
    font-weight: 600;
}

[data-theme="dark"] .msg__content--system {
    background: var(--bg-secondary, #2a2d35);
    color: var(--text-soft, #9ca3af);
}

[data-theme="dark"] .msg__content--system b {
    color: var(--text, #e5e7eb);
}

/* Кнопка редактирования правил в профиле чата */
.chatinfo-card__rules {
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--bg-secondary, #f5f6f8);
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text, #222);
}

[data-theme="dark"] .chatinfo-card__rules {
    background: var(--bg-secondary, #2a2d35);
    color: var(--text, #e5e7eb);
}

/* =========================================================================
   Приватные чаты — стили
   ========================================================================= */

/* Бейдж приватности на карточке чата */
.room-card__badge--private {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}
.room-card__badge--18 {
    background: rgba(180, 83, 9, 0.15);
    color: #b45309;
    border-color: rgba(180, 83, 9, 0.35);
    font-weight: 700;
    letter-spacing: 0.02em;
}

/* Чекбокс в модалке */
.modal__checkbox-field {
    display: flex;
    align-items: center;
    padding: 10px 0;
}

.modal__checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.modal__checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent, #4f8cff);
    cursor: pointer;
}

.modal__checkbox-text {
    font-size: 14px;
    color: var(--text, #e5e7eb);
    line-height: 1.4;
}

/* ===== Доступ к чату: @адрес / приватная ссылка ===== */
.chatinfo-card__access {
    margin: 12px 0;
    padding: 12px;
    border: 1px solid var(--border, #e2e6ea);
    border-radius: 10px;
    background: var(--primary-soft, #eef2f6);
}
.chatinfo-access__label {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
}
.chatinfo-access__row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.chatinfo-access__input {
    flex: 1;
    font-size: 13px;
    font-family: monospace;
}
.chatinfo-access__btn {
    flex: 0 0 auto;
    padding: 8px 12px;
    width: auto;
}
.chatinfo-access__btn-wide {
    margin-top: 8px;
    width: 100%;
}
.chatinfo-access__username {
    font-family: monospace;
    font-size: 15px;
    color: var(--primary-dark, #455160);
    font-weight: 600;
    margin-bottom: 8px;
}
.chatinfo-access__hint {
    font-size: 12px;
    color: var(--text-soft, #8a929c);
    margin-top: 6px;
}
.chatinfo-access__qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin: 12px 0 4px;
}
.chatinfo-access__qr-img {
    width: 160px;
    height: 160px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--border, #e6e8ec);
}
.chatinfo-media { margin: 14px 0; }
.chatinfo-media__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border, #e6e8ec);
    background: var(--bg-card, #fff);
    color: var(--text);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}
.chatinfo-media__toggle:active {
    background: var(--primary-soft, rgba(0, 0, 0, 0.05));
}
.chatinfo-media__toggle--open {
    margin-bottom: 10px;
    background: var(--primary-soft, #e8eef8);
    border-color: transparent;
}
.chatinfo-media__body.hidden { display: none !important; }
.chatinfo-media__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 10px;
}
.chatinfo-media__tab {
    border: 1px solid var(--border, #e6e8ec);
    background: var(--bg-card, #fff);
    color: var(--text-soft);
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    min-height: 34px;
    -webkit-tap-highlight-color: transparent;
}
.chatinfo-media__tab--active {
    background: var(--primary-soft, #e8eef8);
    border-color: transparent;
    color: var(--text);
    font-weight: 600;
}
.chatinfo-media__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    align-items: start;
}
.chatinfo-media__grid--list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chatinfo-media__grid > * {
    min-width: 0;
    min-height: 0;
}
.chatinfo-media__item-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg, #f0f2f5);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.chatinfo-media__item {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    padding: 0;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
    background: transparent;
    cursor: pointer;
    display: block;
}
.chatinfo-media__item img,
.chatinfo-media__thumb-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    display: block;
    background: #111;
    pointer-events: none;
    border: 0;
}
.chatinfo-media__play-badge {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.chatinfo-media__item-more {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.chatinfo-media__item-more:active {
    background: rgba(0, 0, 0, 0.65);
}
.chatinfo-media__icon {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
}
.chatinfo-media__audio {
    grid-column: 1 / -1;
    display: flex;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
    border-radius: 12px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e6e8ec);
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.chatinfo-media__audio-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    padding: 10px 8px 10px 10px;
    cursor: pointer;
    font: inherit;
}
.chatinfo-media__audio-main:active {
    background: var(--primary-soft, rgba(0, 0, 0, 0.05));
}
.chatinfo-media__audio-art {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-soft, #e8eef8);
    font-size: 20px;
    overflow: hidden;
}
.chatinfo-media__audio-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.chatinfo-media__audio-meta {
    flex: 1 1 auto;
    min-width: 0;
}
.chatinfo-media__audio-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chatinfo-media__audio-sub {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chatinfo-media__audio-play {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #2e7d32;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.chatinfo-media__audio-more {
    flex: 0 0 auto;
    width: 40px;
    border: 0;
    background: transparent;
    color: var(--text-soft);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.chatinfo-media__audio-more:active {
    background: var(--primary-soft, rgba(0, 0, 0, 0.05));
}
.chatinfo-media__menu-pop {
    position: fixed;
    z-index: 1400;
    min-width: 180px;
    padding: 6px;
    border-radius: 12px;
    background: var(--bg-elevated, #fff);
    border: 1px solid var(--border, #e6e8ec);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}
.chatinfo-media__menu-item {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    text-align: left;
    padding: 10px 14px;
    cursor: pointer;
}
.chatinfo-media__menu-item--danger {
    color: #c62828;
}
.chatinfo-media__menu-item:hover,
.chatinfo-media__menu-item:active {
    background: var(--primary-soft, rgba(0, 0, 0, 0.06));
}
[data-theme="dark"] .chatinfo-media__audio,
body.theme-dark .chatinfo-media__audio {
    background: var(--bg-soft, #1c1f24);
}
[data-theme="dark"] .chatinfo-media__menu-pop,
body.theme-dark .chatinfo-media__menu-pop {
    background: var(--bg-elevated, #222);
}
.chatinfo-media__empty {
    grid-column: 1 / -1;
    font-size: 13px;
    color: var(--text-soft);
    padding: 8px 0;
}
.chatinfo-media__more {
    display: block;
    width: 100%;
    margin-top: 10px;
    border: 1px solid var(--border, #e6e8ec);
    background: transparent;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 12px;
    cursor: pointer;
    min-height: 44px;
}
.chatinfo-media__more:disabled {
    opacity: 0.6;
    cursor: default;
}
.chatinfo-media__more[hidden] { display: none; }
[data-theme="dark"] .chatinfo-media__tab {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="dark"] .chatinfo-media__tab--active {
    background: var(--primary-soft);
}
.onboard-modal { max-width: 380px; }
.onboard__text {
    font-size: 14px;
    color: var(--text-soft);
    margin: 0 0 16px;
    line-height: 1.45;
}
.onboard__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.onboard__apk { text-align: center; text-decoration: none; }
.modal__btn--ghost {
    background: transparent;
    color: var(--text-soft);
    box-shadow: none;
}
.room-card__username {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-soft, #8a929c);
    margin-top: 2px;
}
.modal__hint {
    font-size: 12px;
    color: var(--text-soft, #8a929c);
    margin-top: 4px;
    line-height: 1.4;
}

/* ===== Главная (залогинен) ===== */
.home-main {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 14px 28px;
    -webkit-overflow-scrolling: touch;
}
.home-hello {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 4px 18px;
}
.home-hello__text { flex: 1 1 auto; min-width: 0; }
.home-hello__greet {
    font-size: 22px;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1.2;
}
.home-hello__sub {
    font-size: 13px;
    color: var(--text-soft);
    margin-top: 4px;
}
.home-hello__avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-soft);
    background: var(--primary-soft);
    flex: 0 0 auto;
}
.home-nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}
.home-nav__item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    font: inherit;
    -webkit-tap-highlight-color: transparent;
}
.home-nav__item:hover { background: var(--primary-soft); }
.home-nav__item:active { transform: scale(0.98); }
.home-nav__item--wide { grid-column: 1 / -1; }
.home-nav__icon { font-size: 22px; line-height: 1; }
.home-nav__label { font-size: 15px; font-weight: 700; color: var(--primary-dark); }
.home-nav__item { position: relative; }
.home-nav__badge {
    position: absolute;
    top: 8px;
    right: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
.home-section { margin-bottom: 18px; }
.home-section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.home-section__title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-dark);
}
.home-section__link {
    border: none;
    background: none;
    color: var(--primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
}
.notify-prompt {
    margin: 0 16px 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--primary-soft, #e8eef8);
    border: 1px solid var(--border, #e6e8ec);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.notify-prompt.hidden { display: none; }
.notify-prompt__text {
    flex: 1 1 180px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text);
}
.notify-prompt__btn {
    border: none;
    background: var(--primary, #5b6b7d);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    min-height: 40px;
}
.notify-prompt__btn.hidden { display: none; }
[data-theme="dark"] .notify-prompt {
    background: var(--primary-soft);
}

.home-news { display: flex; flex-direction: column; gap: 8px; }
.home-news__item {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
}
.home-news__title {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 0 0 4px;
}
.home-news__meta {
    font-size: 12px;
    color: var(--text-soft);
    margin-bottom: 6px;
}
.home-news__text {
    font-size: 14px;
    color: var(--text);
    white-space: pre-wrap;
    line-height: 1.4;
}
.home-news__empty {
    font-size: 14px;
    color: var(--text-soft);
    padding: 8px 2px;
}
/* Превью картинки в новостях — компактно на телефонах, клик → полный размер */
.home-news__img,
.news-item__img,
.news-form__preview {
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: 200px;
    height: auto;
    object-fit: cover;
    border-radius: 10px;
    margin-top: 8px;
    cursor: zoom-in;
    background: var(--bg-soft);
}
@media (min-width: 720px) {
    .home-news__img,
    .news-item__img,
    .news-form__preview {
        max-height: 280px;
    }
}
.news-form__image {
    margin: 10px 0;
}
.home-section--download {
    display: flex;
    justify-content: center;
    padding-top: 6px;
}
.home-apk {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-radius: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    width: 100%;
    max-width: 360px;
    box-sizing: border-box;
}
.home-apk:hover { background: var(--primary-soft); }
.home-apk__icon { font-size: 28px; line-height: 1; }
.home-apk__text { display: flex; flex-direction: column; text-align: left; line-height: 1.25; }
.home-apk__text b { font-size: 15px; color: var(--primary-dark); }
.home-apk__text small { font-size: 12px; color: var(--text-soft); }

/* ===== Кнопка скачивания Android APK на лендинге ===== */
.landing__download {
    margin-top: 18px;
    display: flex;
    justify-content: center;
}
html.balabol-app .landing__download,
html.balabol-app .home-section--download,
html.balabol-app .onboard__apk {
    display: none !important;
}
.landing__apk {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.28);
    color: #fff;
    text-decoration: none;
    backdrop-filter: blur(6px);
    transition: transform 0.15s ease, background 0.15s ease;
}
.landing__apk:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-2px);
}
.landing__apk-icon {
    font-size: 28px;
    line-height: 1;
}
.landing__apk-text {
    display: flex;
    flex-direction: column;
    text-align: left;
    line-height: 1.25;
}
.landing__apk-text b {
    font-size: 15px;
}
.landing__apk-text small {
    font-size: 12px;
    opacity: 0.8;
}

/* ----- Карта «Рядом» + временные чаты ----- */
.nearby-view-toggle {
    display: flex;
    gap: 6px;
    margin: 8px 0 12px;
}
.nearby-view-btn {
    flex: 1;
    border: 1px solid var(--border, #d5dbe3);
    background: var(--bg-soft, #f3f5f8);
    color: var(--text, #1a1d23);
    border-radius: 10px;
    padding: 8px 10px;
    font: inherit;
    cursor: pointer;
}
.nearby-view-btn.active {
    background: var(--accent, #5b6b7d);
    color: #fff;
    border-color: transparent;
}
.rooms-nearby-map,
.room-create-map {
    width: 100%;
    height: 420px;
    min-height: 320px;
    max-height: 420px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border, #d5dbe3);
    margin-top: 8px;
    z-index: 1;
    position: relative;
    background: #e8eef4;
}
.rooms-nearby-map .leaflet-container,
.room-create-map .leaflet-container {
    width: 100%;
    height: 100%;
    font: inherit;
}
#chatinfo-edit-map.room-create-map,
#room-create-map.room-create-map,
.room-create-map {
    height: 220px;
    min-height: 200px;
    max-height: 240px;
}
.map-open-room-btn {
    margin-top: 6px;
    width: auto;
    padding: 6px 10px;
}
.map-load-status {
    position: absolute;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--text-soft, #5b6b7d);
    background: rgba(232, 238, 244, 0.92);
    pointer-events: none;
}
.chat-map-marker {
    background: transparent !important;
    border: none !important;
}
.chat-map-marker__pin {
    width: 34px;
    height: 34px;
    margin: 0 auto;
    border-radius: 17px 17px 17px 4px;
    background: #5b6b7d;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    font-size: 15px;
    line-height: 1;
}
.chat-map-marker__label {
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 8px;
    background: rgba(255,255,255,.95);
    border: 1px solid rgba(0,0,0,.08);
    box-shadow: 0 1px 4px rgba(0,0,0,.12);
    font-size: 11px;
    line-height: 1.2;
    color: #1a1d23;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}
.room-card__badge--nogeo {
    background: #fde8e8;
    color: #a33;
    border-radius: 999px;
    font-size: 10px;
    padding: 1px 6px;
}
.nearby-digest {
    background: var(--bg-soft, #eef2f7);
    border: 1px solid var(--border, #d5dbe3);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text, #1a1d23);
}
.nearby-digest.hidden { display: none; }
.room-card__badge--temp {
    background: #fff3cd;
    color: #7a5b00;
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 11px;
    margin-left: 6px;
}
.digest-prefs {
    margin-top: 12px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border, #d5dbe3);
    background: var(--bg-soft, #f7f8fa);
}
.digest-prefs label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
