﻿/* ══════════════════════════════════════════
       ROOT
    ══════════════════════════════════════════ */
.pm-root {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #313338;
    /* Шрифт берём из глобальной настройки (Настройки → Внешний вид → Шрифт). */
    font-family: var(--app-font-family, 'Roboto', sans-serif);
}

/* ══════════════════════════════════════════
   ICON RAIL (левая полоска как в Discord)
══════════════════════════════════════════ */
.pm-icon-rail {
    width: 72px;
    min-width: 72px;
    background: #1e1f22;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

.pm-rail-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #5865f2;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: border-radius 0.2s, background 0.2s;
    flex-shrink: 0;
}

    .pm-rail-logo:hover {
        border-radius: 16px;
        background: #4752c4;
    }

.pm-rail-logo-inner {
    color: white;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
}

.pm-rail-divider {
    width: 32px;
    height: 2px;
    background: #35373c;
    border-radius: 1px;
    flex-shrink: 0;
}

.pm-rail-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #36393f;
    color: #96989d;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-radius 0.2s, background 0.2s, color 0.2s;
    flex-shrink: 0;
    position: relative;
}

    .pm-rail-icon:hover, .pm-rail-icon-active {
        border-radius: 16px !important;
        background: #5865f2 !important;
        color: white !important;
    }

.pm-rail-server {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #36393f;
    color: #dbdee1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: border-radius 0.2s, background 0.2s;
    flex-shrink: 0;
    overflow: hidden;
    text-align: center;
    line-height: 1;
}

.pm-rail-server-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pm-rail-server:hover {
    border-radius: 16px;
    background: #5865f2;
    color: white;
}

.pm-rail-add-server {
    color: #3ba55d;
    background: #36393f;
    border: none;
    cursor: pointer;
}

    .pm-rail-add-server:hover {
        background: #3ba55d !important;
        color: white !important;
    }

/* ══ Join-server modal ══ */
.pm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.pm-modal-box {
    background: #2b2d31;
    border-radius: 12px;
    padding: 28px 32px;
    width: 420px;
    max-width: 95vw;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: #dbdee1;
}

.pm-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #f2f3f5;
}

.pm-modal-hint {
    font-size: 13px;
    color: #949ba4;
    margin: 0;
}

.pm-modal-input {
    background: #1e1f22;
    border: 1px solid #3c3f44;
    border-radius: 6px;
    color: #dbdee1;
    font-size: 14px;
    padding: 10px 12px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

    .pm-modal-input:focus {
        border-color: #5865f2;
    }

.pm-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.pm-modal-btn {
    background: #36393f;
    border: none;
    border-radius: 6px;
    color: #dbdee1;
    padding: 8px 18px;
    font-size: 14px;
    cursor: pointer;
}

.pm-modal-btn--primary {
    background: #5865f2;
    color: #fff;
}

    .pm-modal-btn--primary:hover {
        background: #4752c4;
    }

    .pm-modal-btn--primary:disabled {
        opacity: .5;
        cursor: default;
    }

.pm-modal-btn:not(.pm-modal-btn--primary):hover {
    background: #404349;
}

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
.pm-sidebar {
    position: relative;
    width: var(--pm-sidebar-w, 240px);
    min-width: 200px;
    background: #2b2d31;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

/* Область для перетаскивания ширины сайдбара */
.pm-sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 5;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}

    .pm-sidebar-resize-handle:hover,
    .pm-sidebar-resize-handle.pm-sidebar-resize-handle--active {
        background: rgba(88, 101, 242, 0.5);
    }

.pm-sidebar-resize-grip {
    width: 2px;
    height: 40px;
    background: #4f545c;
    border-radius: 2px;
    opacity: 0;
    transition: opacity .15s;
}

    .pm-sidebar-resize-handle:hover .pm-sidebar-resize-grip,
    .pm-sidebar-resize-handle.pm-sidebar-resize-handle--active .pm-sidebar-resize-grip {
        opacity: 1;
        background: #ffffff;
    }

.pm-sidebar-header {
    padding: 16px 16px 8px;
    border-bottom: 1px solid #1e1f22;
    display: flex;
    align-items: center;
}

.pm-sidebar-title {
    color: #f2f3f5;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.pm-friends-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 8px;
}

.pm-friends-section-label {
    color: #96989d;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .02em;
    padding: 8px 8px 4px;
    text-transform: uppercase;
}

.pm-friends-section-label--toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
    transition: color .12s;
}

    .pm-friends-section-label--toggle:hover {
        color: #dcddde;
    }

.pm-section-chevron {
    flex-shrink: 0;
    transition: transform .15s ease;
    opacity: .7;
}

.pm-friends-section-label--closed .pm-section-chevron {
    transform: rotate(-90deg);
}

.pm-friends-loading, .pm-friends-empty {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px 16px;
    color: #72767d;
    font-size: 14px;
    text-align: center;
}

.pm-friend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 6px;
    margin: 1px 0;
    transition: background 0.12s;
    color: #96989d;
}

    .pm-friend-item:hover {
        background: rgba(79, 84, 92, 0.32);
        color: #dcddde;
    }

.pm-friend-active {
    background: rgba(88, 101, 242, 0.2) !important;
    color: #f2f3f5 !important;
}

.pm-friend-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.pm-friend-name {
    font-size: 15px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Read receipts (двойная галочка как в Telegram) ─────── */
.pm-msg-ticks {
    display: inline-flex;
    align-items: center;
    margin-left: 4px;
    color: #80848e;
    line-height: 0;
}
.pm-msg-ticks--read { color: #4fc3f7; }

/* Inline-галочка возле каждого собственного PM-сообщения (включая grouped).
   Позиционируется абсолютно в правом верхнем углу pm-msg-body, чтобы не
   мешать тексту и быть видимой независимо от того, есть meta-блок или нет. */
.pm-msg-tick-inline {
    position: absolute;
    top: 4px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    color: #80848e;
    line-height: 0;
    pointer-events: none;
}
.pm-msg-tick-inline--read { color: #4fc3f7; }
.pm-msg-body { position: relative; }

/* ── Forward plate (плашка «Переслано от X») ─────────────── */
.pm-msg-fwd {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 4px;
    padding: 4px 8px;
    border-left: 3px solid #5865f2;
    background: rgba(88, 101, 242, 0.08);
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    color: #b9bbbe;
}
.pm-msg-fwd b { color: #dcddde; font-weight: 600; }

/* ── Forward modal ───────────────────────────────────────── */
.pm-fwd-preview {
    margin: 8px 0 12px;
    padding: 8px 10px;
    background: rgba(0,0,0,0.2);
    border-left: 3px solid #5865f2;
    border-radius: 0 6px 6px 0;
    color: #dcddde;
    font-size: 13px;
    max-height: 64px;
    overflow: hidden;
    white-space: pre-wrap;
}
.pm-fwd-favorites { background: rgba(240, 178, 50, 0.06); }
.pm-fwd-favorites:hover { background: rgba(240, 178, 50, 0.14); }

/* Тост «Переслано → X» — позиционируется над полем ввода */
/* ─── Scroll to bottom button ────────────────────────────────── */
.chat-scroll-btn {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: #313338;
    border: 1px solid #4f545c;
    color: #dcddde;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,.5);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .18s, transform .18s;
    z-index: 10;
}
.chat-scroll-btn--visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.chat-scroll-btn:hover {
    background: #5865f2;
    border-color: #5865f2;
    color: #fff;
}

.pm-fwd-toast {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #2f3136;
    color: #f2f3f5;
    padding: 8px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    font-size: 13px;
    z-index: 1500;
    animation: pmToastIn 0.18s ease;
}

/* ══════════════════════════════════════════
   AVATARS
══════════════════════════════════════════ */
.pm-avatar {
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    font-size: 16px;
}

.pm-avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

.pm-avatar-xl {
    width: 80px;
    height: 80px;
    font-size: 32px;
    margin-bottom: 12px;
}

.pm-avatar-blue {
    background: #5865f2;
}

.pm-avatar-green {
    background: #3ba55d;
}

/* ══════════════════════════════════════════
   CHAT AREA
══════════════════════════════════════════ */
.pm-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: #313338;
    min-width: 0;
}

/* Header */
.pm-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: 56px;
    min-height: 56px;
    border-bottom: 1px solid #1e1f22;
    flex-shrink: 0;
}

/* В режиме канала справа есть абсолютно-позиционированная кнопка «участники» — отступаем */
.pm-chat-header--channel {
    padding-right: 52px;
}

.pm-chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.pm-chat-header-name {
    color: #f2f3f5;
    font-weight: 600;
    font-size: 16px;
}

.pm-chat-header-nameblock {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.pm-chat-typing {
    color: #b9bbbe;
    font-size: 11px;
    font-style: italic;
    height: 14px;
    line-height: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.pm-chat-last-seen {
    color: #b9bbbe;
    font-size: 11px;
    height: 14px;
    line-height: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.pm-conn-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #ed4245;
    font-size: 12px;
}

/* ══════════════════════════════════════════
   MESSAGES
══════════════════════════════════════════ */
.pm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
}

    /* Scrollbar */
    .pm-messages::-webkit-scrollbar {
        width: 8px;
    }

    .pm-messages::-webkit-scrollbar-track {
        background: transparent;
    }

    .pm-messages::-webkit-scrollbar-thumb {
        background: #1a1b1e;
        border-radius: 4px;
    }

/* Loading / empty states */
.pm-msgs-loading {
    display: flex;
    justify-content: center;
    padding: 48px;
}

.pm-msgs-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 16px 0 8px;
}

.pm-msgs-empty-name {
    color: #f2f3f5;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.pm-msgs-empty-hint {
    color: #96989d;
    font-size: 16px;
}

/* ── Date separator ── */
.pm-date-sep {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 20px 0 12px;
}

.pm-date-sep-line {
    flex: 1;
    height: 1px;
    background: #3f4147;
}

.pm-date-sep-label {
    color: #96989d;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    padding: 0 4px;
}

/* ── Individual message ── */
.pm-msg {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 2px 0;
    border-radius: 4px;
    margin: 0 -8px;
    padding-left: 8px;
    padding-right: 8px;
    transition: background 0.08s;
}

    .pm-msg:not(.pm-msg-grouped) {
        margin-top: 16px;
    }

    .pm-msg:hover {
        background: rgba(0,0,0,0.06);
    }

.pm-msg-av {
    width: 40px;
    height: 40px;
    font-size: 16px;
    margin-top: 1px;
    flex-shrink: 0;
}

.pm-msg-av-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* ── Quote block (rendered inside messages) ── */
.pm-quote-block {
    display: flex;
    gap: 8px;
    background: rgba(255,255,255,.06);
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 4px;
    max-width: 100%;
    overflow: hidden;
}
.pm-quote-block[data-msgid] {
    cursor: pointer;
    transition: background .12s;
}
.pm-quote-block[data-msgid]:hover { background: rgba(255,255,255,.11); }

.pm-quote-block-bar {
    width: 3px;
    min-width: 3px;
    border-radius: 2px;
    background: #5865f2;
    flex-shrink: 0;
}

.pm-quote-block-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.pm-quote-block-author {
    /* Подпись автора в цитате — на 3px меньше базового текста сообщений
       (раньше было 12px при базовом 15px). Скейлится вместе с глобальной настройкой. */
    font-size: calc(var(--app-font-size, 15px) - 3px);
    font-weight: 600;
    color: #5865f2;
}

.pm-quote-block-text {
    /* Тело цитаты — на 2px меньше базового размера сообщений. */
    font-size: calc(var(--app-font-size, 15px) - 2px);
    color: #b5bac1;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* ── Quote preview (above input) ── */
.pm-quote-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,.05);
    border-radius: 6px 6px 0 0;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.pm-quote-preview-bar {
    width: 3px;
    min-width: 3px;
    height: 32px;
    border-radius: 2px;
    background: #5865f2;
    flex-shrink: 0;
}

.pm-quote-preview-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.pm-quote-preview-author {
    font-size: 12px;
    font-weight: 600;
    color: #5865f2;
}

.pm-quote-preview-text {
    font-size: 12px;
    color: #b5bac1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pm-quote-preview-close {
    background: none;
    border: none;
    color: #949ba4;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
}

    .pm-quote-preview-close:hover {
        color: #dbdee1;
        background: rgba(255,255,255,.08);
    }

/* Spacer for grouped messages (держит выравнивание) */
.pm-msg-av-spacer {
    width: 40px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* Timestamp for grouped messages — видно при hover */
.pm-msg-hover-time {
    color: #72767d;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.1s;
    white-space: nowrap;
    padding-right: 2px;
}

.pm-msg:hover .pm-msg-hover-time {
    opacity: 1;
}

.pm-msg-body {
    flex: 1;
    min-width: 0;
}

.pm-msg-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.pm-msg-author {
    font-weight: 600;
    /* Размер берём из глобальной настройки (Настройки → Внешний вид). */
    font-size: var(--app-font-size, 15px);
    color: #f2f3f5;
}

.pm-msg-author-me {
    color: #3ba55d;
}

.pm-msg-author-other {
    color: #f2f3f5;
}

.pm-msg-time {
    color: #72767d;
    font-size: 11px;
}

.pm-bot-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: #5865f2;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 4px;
    vertical-align: middle;
    letter-spacing: .04em;
}

.pm-bot-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 4px;
    border-top: 1px solid #3a3c40;
}
.pm-bot-btn {
    background: #2b2d31;
    border: 1px solid #4e5058;
    color: #dbdee1;
    border-radius: 16px;
    padding: 4px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.pm-bot-btn:hover {
    background: #35373c;
    border-color: #f0a500;
    color: #f0a500;
}

.pm-msg-text {
    color: #dcddde;
    /* Размер сообщений — глобальная настройка (Настройки → Внешний вид). */
    font-size: var(--app-font-size, 15px);
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
    /* Не даём широким блокам (код, картинки) вызывать горизонтальный скролл страницы */
    min-width: 0;
    max-width: 100%;
}

/* ══════════════════════════════════════════
   INPUT
══════════════════════════════════════════ */
/* ── ChatPanel messages container ── */
.pm-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    /* auto, не smooth — иначе scrollTop=scrollHeight при открытии чата
       плавно анимируется с верха вниз на глазах у пользователя.
       Прыжок к сообщению по quote остаётся плавным: scrollIntoView там
       вызывается с явным behavior:'smooth'. */
    scroll-behavior: auto;
}

    .pm-msgs::-webkit-scrollbar {
        width: 8px;
    }

    .pm-msgs::-webkit-scrollbar-track {
        background: transparent;
    }

    .pm-msgs::-webkit-scrollbar-thumb {
        background: #1a1b1e;
        border-radius: 4px;
    }

.pm-input-wrap {
    padding: 0 16px 16px;
    flex-shrink: 0;
}

.pm-input-box {
    display: flex;
    align-items: flex-end;
    background: #383a40;
    border-radius: 8px;
    padding: 0 12px 0 4px;
    gap: 8px;
}

.pm-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #dcddde;
    /* Размер ввода — глобальная настройка (Настройки → Внешний вид). */
    font-size: var(--app-font-size, 15px);
    padding: 12px 0;
    caret-color: white;
    font-family: inherit;
    resize: none;
    overflow-y: hidden;
    line-height: 1.45;
}

    .pm-input::placeholder {
        color: #72767d;
    }

.pm-send-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #b9bbbe;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

    .pm-send-btn:hover:not(.pm-send-disabled) {
        color: #dcddde;
        background: rgba(255,255,255,0.06);
    }

.pm-send-disabled {
    opacity: 0.3;
    cursor: default;
}

/* ── Effect picker ────────────────────────────────────────── */
.pm-send-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.effect-picker-backdrop {
    position: fixed;
    inset: 0;
    z-index: 998;
}

.effect-picker {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    background: var(--th-bg-float, #2b2d31);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 6px 4px;
    display: flex;
    gap: 2px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
    z-index: 999;
    animation: effect-picker-in 0.18s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transform-origin: bottom right;
}

@keyframes effect-picker-in {
    from { opacity: 0; transform: scale(0.7) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.effect-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border-radius: 10px;
    color: var(--th-text, #dcddde);
    transition: background 0.12s, transform 0.12s;
    min-width: 64px;
    user-select: none;
}

.effect-btn:hover {
    background: rgba(255,255,255,0.09);
    transform: translateY(-2px);
}

.effect-btn:active {
    transform: scale(0.94);
}

.effect-icon {
    font-size: 26px;
    line-height: 1;
    display: block;
}

.effect-label {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.85;
    white-space: nowrap;
}

/* slam-flash используется JS для screen-shake оверлея */
@keyframes slam-flash {
    0%   { opacity: 1; }
    100% { opacity: 0; }
}

/* ══════════════════════════════════════════
   PLACEHOLDER (no dialog selected)
══════════════════════════════════════════ */
.pm-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.pm-placeholder-title {
    color: #f2f3f5;
    font-size: 20px;
    font-weight: 700;
}

.pm-placeholder-sub {
    color: #96989d;
    font-size: 14px;
}

/* ══ Images & links in messages ══ */
.pm-img {
    max-width: 320px;
    max-height: 280px;
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    transition: filter 0.15s;
}

    .pm-img:hover {
        filter: brightness(0.88);
    }

.pm-img-caption {
    color: #dcddde;
    font-size: 13px;
    margin-top: 4px;
}

.pm-link {
    color: #00aff4;
    text-decoration: none;
    word-break: break-all;
}

    .pm-link:hover {
        text-decoration: underline;
    }

/* ══ Back button (hidden on desktop) ══ */
.pm-back-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: #96989d;
    padding: 6px;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

    .pm-back-btn:hover {
        color: #f2f3f5;
        background: rgba(255,255,255,0.06);
    }

/* ══════════════════════════════════════════
   MOBILE — ≤ 767px
══════════════════════════════════════════ */
@media (max-width: 767px) {

    /* dvh — правильная высота с учётом адресной строки iOS/Android */
    .pm-root {
        position: relative;
        height: 100vh;
        height: 100dvh;
    }

    /* Скрываем icon rail */
    .pm-icon-rail {
        display: none;
    }

    /* Sidebar — полный экран, уезжает влево когда чат открыт */
    .pm-sidebar {
        position: absolute;
        inset: 0;
        width: 100%;
        min-width: unset;
        z-index: 10;
        transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    }

    /* На мобильных ресайз не нужен — сайдбар на весь экран */
    .pm-sidebar-resize-handle {
        display: none;
    }

    .pm-sidebar--hidden {
        transform: translateX(-100%);
        pointer-events: none;
    }

    /* Chat — полный экран, приезжает справа.
       .srv-chat-wrap должен вести себя так же, иначе на PWA/native вверху
       чата канала остаётся пустая полоса = padding-top:env(safe-area-inset-top)
       у .pm-root: обычный flex-ребёнок занимает только content-box, а
       absolute с inset:0 покрывает и padding-зону (status-bar). */
    .pm-chat-wrap,
    .srv-chat-wrap {
        position: absolute;
        inset: 0;
        z-index: 11;
        transform: translateX(100%);
        transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    }

    .pm-chat-wrap--active,
    .srv-chat-wrap--active {
        transform: translateX(0);
    }

    .pm-chat {
        position: relative;
        inset: unset;
        z-index: unset;
        transform: none;
        transition: none;
        flex: 1;
    }

    .pm-chat--active {
        transform: none;
    }

    /* Показываем кнопку назад */
    .pm-back-btn {
        display: flex;
    }

    /* Шапка чата */
    .pm-chat-header {
        padding: 0 12px;
        gap: 8px;
    }

    /* Сообщения */
    .pm-messages {
        padding: 12px 10px 6px;
    }

    /* Инпут.
       Снизу: либо высота открытой клавиатуры (--kb-offset, ставит chat.js по
       visualViewport), либо резерв под нижнюю панель адресной строки браузера.
       max() гарантирует, что мы всегда поднимаемся над тем, что выше — на iOS
       Safari layout-viewport не сжимается, поэтому без --kb-offset инпут
       уходит под клавиатуру. */
    .pm-input-wrap {
        padding: 0 10px max(var(--kb-offset, 0px), calc(var(--mobile-nav-h) + env(safe-area-inset-bottom)));
    }

    /* Аватары чуть меньше */
    .pm-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .pm-msg-av {
        width: 36px;
        height: 36px;
    }

    .pm-msg-av-spacer {
        width: 36px;
        min-width: 36px;
    }

    /* Картинки — на всю ширину */
    .pm-img {
        max-width: 100%;
    }

    /* Пустой экран */
    .pm-msgs-empty-name {
        font-size: 22px;
    }

    .pm-msgs-empty-hint {
        font-size: 14px;
    }

    /* Заголовок sidebar */
    .pm-sidebar-header {
        padding: 14px 16px 10px;
    }

    /* Друзья */
    .pm-friend-item {
        padding: 10px 12px;
    }

    .pm-friend-name {
        font-size: 15px;
    }

    /* Отступы сообщений */
    .pm-msg:not(.pm-msg-grouped) {
        margin-top: 14px;
    }

    /* Разделитель дат */
    .pm-date-sep {
        margin: 16px 0 10px;
    }

    /* Call bar — compact on mobile */
    .pm-call-bar {
        padding: 4px 8px;
        gap: 6px;
        font-size: 12px;
        margin-left: auto;
        flex-shrink: 0;
    }

    .pm-call-bar-icon {
        display: none;
    }
    /* hide phone icon to save space */

    /* Screen share not supported on most mobile browsers — hide button */
    .pm-screen-btn {
        display: none;
    }

    /* Call overlay buttons — larger touch targets */
    .pm-ov-btn {
        width: 72px;
        height: 72px;
        font-size: 13px;
    }

    .pm-call-ov-actions {
        gap: 32px;
    }

    /* Screen share panel — less height on mobile */
    .pm-screen-panel {
        min-height: 160px;
        max-height: 40vh;
    }

    /* Прячем микрофон, когда в поле есть текст */
    .pm-input:not(:placeholder-shown) ~ .pm-mic-btn {
        display: none;
    }

    /* На мобильных картинка в просмотрщике: оставляем место для кнопки закрыть сверху */
    .pm-img-viewer-img {
        max-width: 100vw;
        max-height: calc(100vh - 72px);
        max-height: calc(100dvh - 72px);
        border-radius: 0;
    }

    /* Кнопка закрыть — учитываем safe area (notch/island) */
    .pm-img-viewer-close {
        top: max(18px, env(safe-area-inset-top, 18px));
        right: max(18px, env(safe-area-inset-right, 18px));
        width: 48px;
        height: 48px;
        font-size: 24px;
    }

    /* Пока открыт просмотр изображения — снимаем transform с .pm-chat-wrap,
       иначе position:fixed у оверлея контейнится предком и не перекрывает app-rail */
    .pm-chat-wrap:has(.pm-img-viewer-overlay),
    .srv-chat-wrap:has(.pm-img-viewer-overlay) {
        transform: none;
        transition: none;
    }
}

/* ══════════════════════════════════════════
   EXTRA SMALL — ≤ 400px
══════════════════════════════════════════ */
@media (max-width: 400px) {
    .pm-chat-header-name {
        font-size: 15px;
    }

    /* .pm-msg-author / .pm-msg-text / .pm-input на мобильных НЕ переопределяем —
       размер выбирается пользователем в Настройки → Внешний вид → Размер шрифта. */

    .pm-input {
        padding: 10px 0;
    }

    .pm-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .pm-msg-av {
        width: 32px;
        height: 32px;
    }

    .pm-msg-av-spacer {
        width: 32px;
        min-width: 32px;
    }

    .pm-messages {
        padding: 10px 8px 4px;
    }

    .pm-input-wrap {
        padding: 0 8px max(var(--kb-offset, 0px), calc(var(--mobile-nav-h) + env(safe-area-inset-bottom)));
    }

    .pm-msgs-empty-name {
        font-size: 20px;
    }
}

/* ══════════════════════════════════════════
   CALL UI
══════════════════════════════════════════ */

/* Кнопка звонка в шапке */
.pm-call-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: #b5bac1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

    .pm-call-btn:hover {
        background: #3f4147;
        color: #fff;
    }

    .pm-call-btn:disabled {
        opacity: 0.4;
        cursor: default;
    }

/* Строка активного звонка в шапке */
.pm-call-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #2d7a4f;
    border-radius: 6px;
    padding: 4px 10px;
    margin-left: auto;
    color: #dcfce7;
    font-size: 13px;
    font-weight: 500;
}

.pm-call-bar-icon {
    display: flex;
    align-items: center;
    color: #86efac;
}

.pm-call-bar-time {
    min-width: 36px;
    font-variant-numeric: tabular-nums;
}

.pm-call-end-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: #dc2626;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
}

    .pm-call-end-btn:hover {
        background: #b91c1c;
    }

.pm-call-bar-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: rgba(255,255,255,0.12);
    color: #dcfce7;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

    .pm-call-bar-btn:hover {
        background: rgba(255,255,255,0.25);
    }

.pm-call-bar-btn--active {
    background: rgba(242,63,67,0.35);
    color: #fca5a5;
}

    .pm-call-bar-btn--active:hover {
        background: rgba(242,63,67,0.5);
    }

/* Оверлей звонка */
.pm-call-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(30, 31, 34, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.pm-call-overlay--outgoing {
    background: rgba(30, 31, 34, 0.85);
}

.pm-call-ov-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #5865f2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(88, 101, 242, 0.3);
    animation: pm-pulse 2s ease-in-out infinite;
}

@keyframes pm-pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(88, 101, 242, 0.3);
    }

    50% {
        box-shadow: 0 0 0 12px rgba(88, 101, 242, 0.12);
    }
}

.pm-call-ov-name {
    font-size: 22px;
    font-weight: 600;
    color: #fff;
}

.pm-call-ov-hint {
    font-size: 14px;
    color: #b5bac1;
}

.pm-call-ov-actions {
    display: flex;
    gap: 24px;
    margin-top: 8px;
}

.pm-ov-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: none;
    border-radius: 50%;
    width: 64px;
    height: 64px;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: filter 0.15s;
}

    .pm-ov-btn:hover {
        filter: brightness(1.15);
    }

.pm-ov-accept {
    background: #23a55a;
    color: #fff;
}

.pm-ov-decline {
    background: #f23f43;
    color: #fff;
}

/* ══ Онлайн-статус и бейджи ══ */
.pm-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.pm-online-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid #2b2d31;
}

.pm-online-dot--on,
.pm-online-dot--online {
    background: #23a55a;
}

.pm-online-dot--away {
    background: #f0b232;
}

.pm-online-dot--dnd {
    background: #ed4245;
}

    .pm-online-dot--dnd::after {
        content: '';
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 55%;
        height: 2px;
        background: #fff;
        border-radius: 1px;
    }

.pm-online-dot--off {
    background: #80848e;
}

.pm-friend-status {
    font-size: 11px;
    color: #80848e;
    line-height: 1;
    margin-top: 2px;
}
.pm-friend-status--activity {
    color: #57f287;
    display: flex;
    align-items: center;
    gap: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 140px;
}

.pm-unread-badge {
    margin-left: auto;
    flex-shrink: 0;
    background: #f23f43;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
    line-height: 16px;
}

/* Статус звонка (не в сети / отклонён) */
.pm-call-status-msg {
    font-size: 12px;
    color: #f87171;
    white-space: nowrap;
}

/* ══ Screen share button in call bar ══ */
.pm-screen-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: rgba(255,255,255,0.12);
    color: #dcfce7;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

    .pm-screen-btn:hover {
        background: rgba(255,255,255,0.2);
    }

.pm-screen-btn--active {
    background: #1d4ed8;
    color: #fff;
    animation: pm-screen-pulse 2s ease-in-out infinite;
}

@keyframes pm-screen-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(29,78,216,0.4);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(29,78,216,0);
    }
}

/* ══ Screen share panel ══ */
.pm-screen-panel {
    flex-shrink: 0;
    background: #1a1b1e;
    border-bottom: 1px solid #2c2e33;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    max-height: 55vh;
    position: relative;
    overflow: hidden;
}

.pm-screen-video {
    width: 100%;
    height: 100%;
    max-height: 55vh;
    object-fit: contain;
    background: #000;
    display: block;
}

.pm-screen-label {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.65);
    color: #e3e5e8;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.pm-screen-label--remote {
    color: #86efac;
}

.pm-screen-sharing-self {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #86efac;
    font-size: 15px;
    font-weight: 500;
    padding: 24px;
}

.pm-screen-stop-btn {
    border: 1px solid #dc2626;
    background: transparent;
    color: #f87171;
    border-radius: 6px;
    padding: 6px 18px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

    .pm-screen-stop-btn:hover {
        background: #dc2626;
        color: #fff;
    }

.pm-screen-remote-wrap {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
}

.pm-screen-fullscreen-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.55);
    border: none;
    border-radius: 6px;
    color: #e3e5e8;
    padding: 5px 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.pm-screen-remote-wrap:hover .pm-screen-fullscreen-btn {
    opacity: 1;
}

/* ── Overlay buttons (fullscreen + hide) on remote video ── */
.pm-screen-overlay-btns {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.pm-screen-remote-wrap:hover .pm-screen-overlay-btns {
    opacity: 1;
}

.pm-screen-overlay-btn {
    background: rgba(0,0,0,0.55);
    border: none;
    border-radius: 6px;
    color: #e3e5e8;
    padding: 5px 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

    .pm-screen-overlay-btn:hover {
        background: rgba(0,0,0,0.85);
        color: #fff;
    }

/* ── Camera PiP (picture-in-picture over remote video) ── */
.pm-camera-pip {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 140px;
    height: 90px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.25);
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    background: #000;
    z-index: 2;
}

.pm-camera-pip-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Camera solo view (when no remote video) ── */
.pm-camera-solo-wrap {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
}

    .pm-camera-solo-wrap:hover .pm-screen-overlay-btns {
        opacity: 1;
    }

.pm-camera-solo-video {
    width: 100%;
    height: 100%;
    max-height: 55vh;
    object-fit: contain;
    background: #000;
    display: block;
    transform: scaleX(-1); /* mirror the camera for a natural selfie view */
}

/* ── "Video hidden" badge ── */
.pm-video-hidden-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 8px 16px;
    color: #9ca3af;
    font-size: 13px;
}

/* ══════════════════════════════════════════
   ADD FRIEND / SEARCH
══════════════════════════════════════════ */

/* Кнопка в шапке сайдбара */
.pm-add-friend-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #96989d;
    padding: 4px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color .15s, background .15s;
    margin-left: auto;
}

    .pm-add-friend-btn:hover {
        color: #dbdee1;
        background: rgba(255,255,255,.08);
    }

.pm-add-friend-btn--active {
    color: #dbdee1;
    background: rgba(255,255,255,.1);
}

.pm-sidebar-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Панель локального поиска по списку */
.pm-local-search-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 12px 4px;
    padding: 6px 10px;
    background: #1e1f22;
    border-radius: 6px;
    border: 1px solid #2b2d31;
}

.pm-local-search-icon {
    color: #96989d;
    flex-shrink: 0;
}

.pm-local-search-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: #f2f3f5;
    font-size: 13px;
    padding: 2px 0;
}

    .pm-local-search-input::placeholder {
        color: #72767d;
    }

.pm-local-search-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: #96989d;
    padding: 2px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color .15s, background .15s;
}

    .pm-local-search-clear:hover {
        color: #dbdee1;
        background: rgba(255,255,255,.08);
    }

/* Секция запросов */
.pm-requests-section {
    padding: 8px 8px 4px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.pm-requests-label {
    font-size: 11px;
    font-weight: 700;
    color: #96989d;
    letter-spacing: .5px;
    padding: 4px 8px 6px;
}

.pm-request-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background .1s;
}

    .pm-request-item:hover {
        background: rgba(255,255,255,.06);
    }

.pm-request-name {
    flex: 1;
    font-size: 14px;
    color: #dcddde;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pm-req-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s;
}

.pm-req-accept {
    background: rgba(35,165,90,.25);
    color: #23a55a;
}

    .pm-req-accept:hover {
        background: rgba(35,165,90,.45);
    }

.pm-req-decline {
    background: rgba(237,66,69,.2);
    color: #ed4245;
}

    .pm-req-decline:hover {
        background: rgba(237,66,69,.4);
    }

/* Модал добавления друга */
.pm-add-friend-modal {
    background: #2b2d31;
    border-radius: 12px;
    padding: 24px;
    width: 420px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 16px 48px rgba(0,0,0,.6);
    animation: pmModalIn .15s ease;
}

@keyframes pmModalIn {
    from {
        opacity: 0;
        transform: scale(.96) translateY(-8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.pm-add-friend-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: #f2f3f5;
}

.pm-add-friend-hint {
    font-size: 14px;
    color: #96989d;
    margin: 0;
}

.pm-search-row {
    display: flex;
    gap: 8px;
}

.pm-search-input {
    flex: 1;
    background: #1e1f22;
    border: 1px solid #3f4147;
    border-radius: 6px;
    padding: 9px 12px;
    color: #dcddde;
    font-size: 14px;
    outline: none;
    transition: border-color .15s;
}

    .pm-search-input:focus {
        border-color: #5865f2;
    }

    .pm-search-input::placeholder {
        color: #72767d;
    }

.pm-search-btn {
    padding: 9px 18px;
    border-radius: 6px;
    border: none;
    background: #5865f2;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

    .pm-search-btn:hover:not(:disabled) {
        background: #4752c4;
    }

    .pm-search-btn:disabled {
        background: #3f4147;
        color: #72767d;
        cursor: not-allowed;
    }

.pm-search-empty {
    text-align: center;
    color: #72767d;
    font-size: 14px;
    padding: 16px 0;
}

.pm-search-results {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 260px;
    overflow-y: auto;
}

.pm-search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    transition: background .1s;
}

    .pm-search-result-item:hover {
        background: rgba(255,255,255,.06);
    }

.pm-search-result-name {
    flex: 1;
    font-size: 15px;
    color: #dcddde;
}

.pm-send-req-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: none;
    background: #5865f2;
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}

    .pm-send-req-btn:hover {
        background: #4752c4;
    }

.pm-req-sent-badge {
    font-size: 12px;
    color: #23a55a;
    background: rgba(35,165,90,.18);
    padding: 4px 10px;
    border-radius: 20px;
    flex-shrink: 0;
}

.pm-req-error-badge {
    font-size: 12px;
    color: #ed4245;
    background: rgba(237,66,69,.18);
    padding: 4px 10px;
    border-radius: 20px;
    flex-shrink: 0;
}

/* Кнопка "Начать чат" в результатах поиска */
.pm-search-result-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.pm-start-chat-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,.15);
    background: transparent;
    color: #dcddde;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    flex-shrink: 0;
}

    .pm-start-chat-btn:hover {
        background: rgba(255,255,255,.08);
        border-color: rgba(255,255,255,.25);
    }

/* Элемент недавних контактов (не-друзья) */
.pm-friend-item--nonfriend .pm-avatar {
    border: 2px solid rgba(245,158,11,.4);
}

/* Обёртка для плашки + чат-панели */
.pm-chat-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* Плашка "не в контактах" над чатом */
.pm-not-contact-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(245, 158, 11, 0.12);
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
    color: #f59e0b;
    font-size: 13px;
    flex-shrink: 0;
}

    .pm-not-contact-banner span {
        flex: 1;
    }

.pm-not-contact-add-btn {
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid rgba(245,158,11,.5);
    background: transparent;
    color: #f59e0b;
    font-size: 12px;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
    flex-shrink: 0;
}

    .pm-not-contact-add-btn:hover {
        background: rgba(245,158,11,.18);
    }

/* Тост-уведомление о запросе */
.pm-friend-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    background: #2b2d31;
    border: 1px solid #3f4147;
    border-left: 3px solid #5865f2;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
    min-width: 280px;
    max-width: 380px;
    animation: pmToastIn .2s ease;
    color: #dcddde;
    font-size: 14px;
}

@keyframes pmToastIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pm-friend-toast svg {
    color: #5865f2;
    flex-shrink: 0;
}

.pm-friend-toast span {
    flex: 1;
}

.pm-friend-toast-close {
    background: none;
    border: none;
    color: #96989d;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    flex-shrink: 0;
    transition: color .15s;
}

    .pm-friend-toast-close:hover {
        color: #f2f3f5;
    }

/* pm-avatar-orange */
.pm-avatar-orange {
    background: #ed8c00 !important;
}

/* ══════════════════════════════════════════
   DRAG-DROP / IMAGE ATTACH
══════════════════════════════════════════ */
.pm-attach-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #96989d;
    padding: 6px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color .15s;
}

    .pm-attach-btn:hover {
        color: #dbdee1;
    }

/* Кнопка "прикрепить файл" (папка) — курсор указывает на label */
.pm-file-btn { cursor: pointer; }

/* ─── Ожидающий файл (бар над полем ввода) ──────────────────── */
.pm-file-pending-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #2b2d31;
    border-top: 1px solid #1e1f22;
    font-size: 13px;
    flex-shrink: 0;
}
.pm-file-pending-icon { font-size: 22px; flex-shrink: 0; }
.pm-file-pending-info { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.pm-file-pending-name { color: #dbdee1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.pm-file-pending-size { color: #72767d; font-size: 11px; }
.pm-file-pending-error { color: #ed4245; font-size: 12px; flex: 1; }
.pm-file-toolarge {
    display: flex; align-items: center; gap: 6px; flex: 1;
    background: rgba(250,166,26,.12); border: 1px solid rgba(250,166,26,.3);
    border-radius: 6px; padding: 4px 8px; color: #faa61a; font-size: 12px;
}
.pm-file-toolarge svg { flex-shrink: 0; }
.pm-file-pending-progress { color: #72767d; font-size: 12px; }

/* Прогресс-бар загрузки файла */
.pm-file-upload-progress {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.pm-file-upload-track {
    flex: 1;
    height: 4px;
    background: #2b2d31;
    border-radius: 2px;
    overflow: hidden;
}
.pm-file-upload-bar {
    height: 100%;
    background: linear-gradient(90deg, #5865f2, #57f287);
    border-radius: 2px;
    transition: width .2s ease;
}
.pm-file-upload-bar--saving {
    background: linear-gradient(90deg, #5865f2, #57f287, #5865f2);
    background-size: 200% 100%;
    animation: pm-upload-saving 1.2s linear infinite;
    transition: none;
}
@keyframes pm-upload-saving {
    0%   { background-position: 100% 0; }
    100% { background-position:   0% 0; }
}
.pm-file-upload-pct {
    color: #72767d;
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 34px;
    text-align: right;
}
.pm-file-pending-send {
    background: #5865f2; border: none; border-radius: 50%;
    width: 30px; height: 30px; color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .15s;
}
.pm-file-pending-send:hover { background: #4752c4; }
.pm-file-pending-cancel {
    background: none; border: none; color: #72767d; cursor: pointer;
    font-size: 14px; padding: 4px 6px; border-radius: 4px;
    flex-shrink: 0; transition: color .15s;
}
.pm-file-pending-cancel:hover { color: #ed4245; }

/* ─── Карточка файла в сообщении ────────────────────────────── */
.msg-file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #2b2d31;
    border: 1px solid #3f4147;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 4px;
    max-width: 340px;
}
.msg-file-emoji { font-size: 28px; flex-shrink: 0; line-height: 1; }
.msg-file-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.msg-file-name {
    color: #dbdee1; font-size: 13px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-file-size { color: #72767d; font-size: 11px; }
.msg-file-actions { display: flex; gap: 4px; flex-shrink: 0; }
.msg-file-btn {
    background: #40444b; border: none; border-radius: 6px;
    width: 30px; height: 30px; color: #b9bbbe; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none; transition: background .15s, color .15s;
}
.msg-file-btn:hover { background: #5865f2; color: #fff; }

/* ── Inline video player ─────────────────────────────────────── */
.msg-video-wrap {
    max-width: 420px;
    border-radius: 10px;
    overflow: hidden;
    background: #1a1d23;
    border: 1px solid #3f4147;
    margin-top: 4px;
}
.msg-video-player {
    width: 100%;
    max-height: 280px;
    display: block;
    background: #000;
}
.msg-video-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    gap: 8px;
}
.msg-video-footer .msg-file-name { font-size: 12px; color: #72767d; }

/* ── VK Video embed ──────────────────────────────────────────── */
.msg-vk-embed {
    max-width: 480px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #3f4147;
    margin-top: 4px;
    background: #000;
    position: relative;
}
.msg-vk-embed iframe {
    width: 100%;
    height: 270px;
    border: none;
    display: block;
}
.msg-vk-placeholder {
    width: 100%;
    height: 270px;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
}
.msg-vk-placeholder:hover { background: #1e1e1e; }
.msg-vk-placeholder svg { opacity: 0.6; transition: opacity .15s; }
.msg-vk-placeholder:hover svg { opacity: 1; }
.msg-vk-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #2b2d31;
    border-top: 1px solid #3f4147;
    color: #b0b4c1;
    text-decoration: none;
    font-size: 12px;
    transition: background .15s, color .15s;
    cursor: pointer;
}
.msg-vk-link:hover { background: #32353b; color: #dcddde; }
.msg-vk-link svg { flex-shrink: 0; color: #5865f2; }
.msg-vk-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pm-drop-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: rgba(88, 101, 242, 0.18);
    border: 2px dashed #5865f2;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.pm-drop-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #5865f2;
    font-size: 16px;
    font-weight: 600;
}

.pm-img-preview-overlay {
    position: absolute;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pm-img-preview-card {
    background: #2b2d31;
    border-radius: 8px;
    padding: 16px;
    max-width: 480px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.pm-img-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 600;
    color: #f2f3f5;
}

.pm-img-preview-close {
    background: none;
    border: none;
    color: #96989d;
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color .15s;
}

    .pm-img-preview-close:hover {
        color: #f2f3f5;
    }

.pm-img-preview-img {
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    border-radius: 6px;
    background: #1e1f22;
}

.pm-img-preview-img-wrap {
    position: relative;
    width: 100%;
}

.pm-img-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    font-size: 13px;
    pointer-events: none;
}

.pm-img-upload-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pm-img-upload-spin 0.8s linear infinite;
}

@keyframes pm-img-upload-spin {
    to { transform: rotate(360deg); }
}

.pm-img-preview-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.pm-img-preview-cancel {
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    background: rgba(255,255,255,0.1);
    color: #dbdee1;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
}

    .pm-img-preview-cancel:hover {
        background: rgba(255,255,255,0.18);
    }

.pm-img-preview-send {
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    background: #5865f2;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
}

    .pm-img-preview-send:hover:not(:disabled) {
        background: #4752c4;
    }

    .pm-img-preview-send:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* Caption input inside image preview */
.pm-img-caption-input {
    background: #1e1f22;
    border: 1px solid #3c3f44;
    border-radius: 6px;
    color: #dbdee1;
    font-size: 14px;
    padding: 8px 12px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}

    .pm-img-caption-input:focus {
        border-color: #5865f2;
    }

    .pm-img-caption-input::placeholder {
        color: #6d6f78;
    }

/* ══ Image viewer (fullscreen) ══ */
.pm-img-viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,.9);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn .15s ease;
    cursor: zoom-out;
    outline: none;
}

@keyframes fadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

.pm-img-viewer-img {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,.7);
    cursor: default;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
    will-change: transform;
}

.pm-img-viewer-save {
    position: absolute;
    top: 18px;
    right: 74px;
    z-index: 10;
    background: rgba(0,0,0,.55);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    pointer-events: auto;
    touch-action: auto;
}
.pm-img-viewer-save:hover { background: rgba(255,255,255,.22); }

.pm-img-viewer-close {
    position: absolute;
    top: 18px;
    right: 22px;
    z-index: 10;
    background: rgba(0,0,0,.55);
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    /* Гарантируем что на мобильном кнопка кликабельна */
    pointer-events: auto;
    touch-action: auto;
}

    .pm-img-viewer-close:hover {
        background: rgba(255,255,255,.22);
    }

/* Кнопки перелистывания в viewer'е */
.pm-img-viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(0,0,0,.55);
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    transition: background .15s;
    pointer-events: auto;
    touch-action: auto;
}

    .pm-img-viewer-nav:hover {
        background: rgba(255,255,255,.25);
    }

.pm-img-viewer-prev { left: 18px; }
.pm-img-viewer-next { right: 18px; }

.pm-img-viewer-counter {
    position: absolute;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    color: #fff;
    background: rgba(0,0,0,.55);
    padding: 6px 14px;
    border-radius: 14px;
    font-size: 13px;
    pointer-events: none;
}

/* Make pm-img clickable */
.pm-img {
    cursor: zoom-in;
}

/* ══ Attachments grid в сообщении ══ */
.pm-attach-grid {
    display: grid;
    gap: 4px;
    margin: 4px 0;
    max-width: 420px;
    grid-template-columns: 1fr;
}

.pm-attach-grid--2 { grid-template-columns: 1fr 1fr; }
.pm-attach-grid--3,
.pm-attach-grid--4 { grid-template-columns: 1fr 1fr; }

.pm-attach-thumb {
    width: 100%;
    max-height: 260px;
    object-fit: cover;
    border-radius: 6px;
    cursor: zoom-in;
    display: block;
    background: #1e1f22;
}

.pm-attach-grid--1 .pm-attach-thumb { max-height: 340px; object-fit: contain; }

/* ── Избранное: чипы прицепленных (pending) вложений ── */
.pm-note-pending {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 6px 12px; max-width: 100%;
}
.pm-note-pending-chip {
    display: flex; align-items: center; gap: 8px;
    background: #2b2d31; border: 1px solid #3f4248; border-radius: 6px;
    padding: 4px 8px; max-width: 260px;
}
.pm-note-pending-chip img {
    width: 32px; height: 32px; border-radius: 4px; object-fit: cover; flex-shrink: 0;
}
.pm-note-pending-emoji { font-size: 20px; flex-shrink: 0; }
.pm-note-pending-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pm-note-pending-name {
    color: #dcddde; font-size: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pm-note-pending-size { color: #72767d; font-size: 11px; }
.pm-note-pending-rm {
    background: none; border: none; color: #72767d; cursor: pointer;
    font-size: 14px; padding: 2px 4px; flex-shrink: 0;
}
.pm-note-pending-rm:hover { color: #ed4245; }
.pm-note-pending-chip--loading {
    color: #b9bbbe; font-size: 12px; padding: 6px 10px;
}
.pm-note-pending-err { color: #ed4245; font-size: 12px; padding: 4px 8px; }

/* ══ Preview modal — сетка выбранных файлов ══ */
.pm-img-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 8px;
    padding: 12px 16px;
    max-height: 300px;
    overflow-y: auto;
}

.pm-img-preview-cell {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: #1e1f22;
}

.pm-img-preview-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pm-img-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.75);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .pm-img-preview-remove:hover { background: #ed4245; }
    .pm-img-preview-remove:disabled { opacity: .5; cursor: default; }

.pm-img-preview-add {
    aspect-ratio: 1;
    border: 2px dashed #3f4248;
    border-radius: 6px;
    background: transparent;
    color: #9aa0a6;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .15s, color .15s;
}

    .pm-img-preview-add:hover { border-color: #5865f2; color: #dcddde; }

/* ══ Channel password gate ══ */
.pm-channel-lock {
    position: absolute;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2b2d31;
}

.pm-channel-lock-card {
    width: 360px;
    max-width: 90%;
    padding: 28px 28px 24px;
    background: #1e1f22;
    border: 1px solid #3f4147;
    border-radius: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,.35);
}

.pm-channel-lock-icon {
    font-size: 40px;
    line-height: 1;
    margin-bottom: 4px;
}

.pm-channel-lock-title {
    font-size: 17px;
    font-weight: 600;
    color: #dcddde;
}

.pm-channel-lock-sub {
    font-size: 13px;
    color: #9aa0a6;
    margin-bottom: 6px;
}

.pm-channel-lock-input {
    width: 100%;
    background: #1e1f22;
    border: 1px solid #3f4147;
    color: #dcddde;
    padding: 10px 12px;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
    transition: border-color .15s;
}

    .pm-channel-lock-input:focus { border-color: #5865f2; }
    .pm-channel-lock-input:disabled { opacity: .6; }

.pm-channel-lock-error {
    color: #ed4245;
    font-size: 12px;
    align-self: flex-start;
}

.pm-channel-lock-btn {
    margin-top: 6px;
    width: 100%;
    padding: 10px 14px;
    background: #5865f2;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}

    .pm-channel-lock-btn:hover:not(:disabled) { background: #4752c4; }
    .pm-channel-lock-btn:disabled { opacity: .6; cursor: default; }

/* ══ Input topbar (fixed row above input: format toolbar left, char counter right) ══ */
.pm-input-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 30px;
    padding: 0 8px;
    gap: 8px;
    flex-shrink: 0;
}

/* ══ Format toolbar ══ */
.pm-format-toolbar {
    display: flex;
    gap: 4px;
    padding: 2px 0;
    align-items: center;
    transition: opacity .12s;
}

.pm-format-toolbar--hidden {
    opacity: 0;
    pointer-events: none;
}

.pm-fmt-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #b5bac1;
    width: 30px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, color .12s, border-color .12s;
}

    .pm-fmt-btn:hover {
        background: #36373d;
        color: #dcddde;
        border-color: #3f4147;
    }

/* ══ Mute banner (заглушен на сервере) ══ */
.pm-mute-banner {
    margin: 0 16px 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(237, 66, 69, 0.15);
    border: 1px solid rgba(237, 66, 69, 0.4);
    border-radius: 6px;
    color: #f2b4b6;
    font-size: 13px;
}

.pm-mute-icon { font-size: 16px; }

.pm-mute-text { flex: 1; }

/* ══ TODO-список в сообщении ══ */
.pm-todo {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid #3f4147;
    border-radius: 6px;
    padding: 8px 10px;
    margin-top: 2px;
    max-width: 520px;
}

.pm-todo-header {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #b5bac1;
    /* Заголовок TODO — на 3px меньше базового размера сообщений. */
    font-size: calc(var(--app-font-size, 15px) - 3px);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.pm-todo-progress {
    margin-left: auto;
    color: #949ba4;
    font-weight: 500;
    /* Счётчик прогресса — на 4px меньше базового. */
    font-size: calc(var(--app-font-size, 15px) - 4px);
}

.pm-todo-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 4px;
    border-radius: 4px;
    cursor: pointer;
    color: #dcddde;
    /* Текст пункта TODO — на 1px меньше базового размера сообщений. */
    font-size: calc(var(--app-font-size, 15px) - 1px);
    line-height: 1.4;
}

    .pm-todo-item:hover { background: rgba(255, 255, 255, 0.05); }

    .pm-todo-item input[type="checkbox"] {
        flex-shrink: 0;
        width: 15px;
        height: 15px;
        cursor: pointer;
        accent-color: #5865f2;
    }

.pm-todo-text { flex: 1; word-break: break-word; }

.pm-todo-item--done .pm-todo-text {
    text-decoration: line-through;
    color: #72767d;
}

.pm-todo-count {
    background: rgba(88, 101, 242, 0.25);
    color: #b5bac1;
    padding: 1px 7px;
    border-radius: 9px;
    /* Бэйдж счётчика — на 4px меньше базового. */
    font-size: calc(var(--app-font-size, 15px) - 4px);
    min-width: 20px;
    text-align: center;
}

/* ── Редактирование TODO (создатель списка) ───────────────────────── */
.pm-todo-edit-input {
    flex: 1;
    background: #1e1f22;
    color: #f2f3f5;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 4px;
    padding: 4px 6px;
    font-family: inherit;
    font-size: calc(var(--app-font-size, 15px) - 1px);
    outline: none;
    min-width: 0;
}

    .pm-todo-edit-input:focus {
        border-color: #5865f2;
    }

.pm-todo-icon-btn {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #b5bac1;
    background: rgba(255, 255, 255, 0.04);
    transition: background .12s, color .12s, opacity .12s;
}

    .pm-todo-icon-btn:hover {
        background: rgba(88, 101, 242, 0.20);
        color: #f2f3f5;
    }

.pm-todo-icon-btn--save {
    background: rgba(59, 165, 93, 0.20);
    color: #3ba55d;
}

    .pm-todo-icon-btn--save:hover {
        background: #3ba55d;
        color: #fff;
    }

.pm-todo-icon-btn--danger:hover {
    background: rgba(237, 66, 69, 0.20);
    color: #ed4245;
}

/* «Призрачные» кнопки рядом с текстом — видны только при наведении на пункт. */
.pm-todo-icon-btn--ghost {
    opacity: 0;
    background: transparent;
}

.pm-todo-item:hover .pm-todo-icon-btn--ghost {
    opacity: 0.75;
}

.pm-todo-icon-btn--ghost:hover {
    opacity: 1 !important;
}

.pm-todo-item--add {
    cursor: default;
}

.pm-todo-add-btn {
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    color: #b5bac1;
    border-radius: 5px;
    padding: 4px 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: calc(var(--app-font-size, 15px) - 2px);
    transition: background .12s, color .12s, border-color .12s;
    width: 100%;
    justify-content: center;
}

    .pm-todo-add-btn:hover {
        background: rgba(88, 101, 242, 0.10);
        border-color: rgba(88, 101, 242, 0.40);
        color: #f2f3f5;
    }

.pm-todo--pinned { margin-top: 6px; }

/* Компактная строка опроса/голосования в панели закреплённых — только тема */
.pm-poll-pinned {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid #3f4147;
    border-radius: 6px;
    color: #dcddde;
    font-size: 13px;
    line-height: 1.3;
}

.pm-poll-pinned-label {
    color: #b5bac1;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
}

.pm-poll-pinned-question {
    flex: 1;
    color: #f2f3f5;
    font-weight: 500;
    word-break: break-word;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ══ Poll / голосование в сообщении ══ */
.pm-poll {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid #3f4147;
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 2px;
    max-width: 520px;
}

.pm-poll-header {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #b5bac1;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pm-poll-badge {
    background: rgba(88, 101, 242, 0.25);
    color: #b5bac1;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 10px;
    text-transform: lowercase;
    letter-spacing: normal;
}

.pm-poll-progress {
    margin-left: auto;
    color: #949ba4;
    font-weight: 500;
    font-size: 11px;
    text-transform: none;
    letter-spacing: normal;
}

.pm-poll-question {
    color: #dcddde;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
}

.pm-poll-desc {
    color: #b5bac1;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

.pm-poll-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 5px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 120ms;
}

    .pm-poll-option:hover { background: rgba(255, 255, 255, 0.06); }

    .pm-poll-option input[type="radio"],
    .pm-poll-option input[type="checkbox"] {
        flex-shrink: 0;
        width: 15px;
        height: 15px;
        cursor: pointer;
        accent-color: #5865f2;
    }

.pm-poll-option--mine {
    border-color: rgba(88, 101, 242, 0.6);
    background: rgba(88, 101, 242, 0.08);
}

.pm-poll-option--correct {
    border-color: rgba(59, 165, 93, 0.7);
    background: rgba(59, 165, 93, 0.12);
}

.pm-poll-option--wrong {
    border-color: rgba(237, 66, 69, 0.7);
    background: rgba(237, 66, 69, 0.1);
}

.pm-poll-option-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.pm-poll-option-top {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.pm-poll-option-text {
    color: #dcddde;
    font-size: 14px;
    word-break: break-word;
    flex: 1;
}

.pm-poll-option-pct {
    color: #b5bac1;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.pm-poll-bar-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}

.pm-poll-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #5865f2, #7983f5);
    border-radius: 3px;
    transition: width 260ms ease-out;
}

.pm-poll-option--correct .pm-poll-bar-fill { background: linear-gradient(90deg, #3ba55d, #4fbf73); }
.pm-poll-option--wrong .pm-poll-bar-fill   { background: linear-gradient(90deg, #ed4245, #f06568); }

.pm-poll-option-count {
    background: rgba(88, 101, 242, 0.2);
    color: #b5bac1;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 11px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

/* ── Poll create modal ── */
.pm-poll-modal {
    width: min(520px, 92vw);
    max-height: 86vh;
    overflow-y: auto;
    background: #2b2d31;
    border-radius: 10px;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #dcddde;
    box-shadow: 0 12px 36px rgba(0,0,0,0.45);
}

.pm-poll-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #f2f3f5;
}

.pm-poll-field-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: #b5bac1;
    margin-top: 4px;
}

.pm-poll-input {
    width: 100%;
    background: #1e1f22;
    border: 1px solid #3f4147;
    border-radius: 6px;
    padding: 8px 10px;
    color: #f2f3f5;
    font-size: 14px;
    outline: none;
    transition: border-color 120ms;
    box-sizing: border-box;
}

    .pm-poll-input:focus { border-color: #5865f2; }

.pm-poll-textarea {
    resize: vertical;
    min-height: 40px;
    font-family: inherit;
}

.pm-poll-options-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pm-poll-option-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pm-poll-option-input { flex: 1; }

.pm-poll-correct-check {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3ba55d;
    flex-shrink: 0;
}

.pm-poll-option-del {
    background: transparent;
    color: #b5bac1;
    border: 1px solid #3f4147;
    border-radius: 5px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 120ms;
}

    .pm-poll-option-del:hover:not(:disabled) { background: rgba(237, 66, 69, 0.15); color: #ed4245; }
    .pm-poll-option-del:disabled { opacity: 0.35; cursor: not-allowed; }

.pm-poll-add-option {
    align-self: flex-start;
    background: transparent;
    color: #5865f2;
    border: 1px dashed #5865f2;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 120ms;
}

    .pm-poll-add-option:hover { background: rgba(88, 101, 242, 0.1); }

.pm-poll-toggles {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.pm-poll-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #dcddde;
}

    .pm-poll-toggle input {
        width: 16px;
        height: 16px;
        accent-color: #5865f2;
        cursor: pointer;
    }

.pm-poll-error {
    background: rgba(237, 66, 69, 0.12);
    border: 1px solid rgba(237, 66, 69, 0.4);
    color: #f0b6b7;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 13px;
}

.pm-poll-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.pm-poll-cancel,
.pm-poll-submit {
    padding: 8px 18px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 120ms;
}

.pm-poll-cancel {
    background: transparent;
    color: #b5bac1;
    border: 1px solid #3f4147;
}

    .pm-poll-cancel:hover:not(:disabled) { background: rgba(255,255,255,0.05); }

.pm-poll-submit {
    background: #5865f2;
    color: #fff;
}

    .pm-poll-submit:hover:not(:disabled) { background: #4752c4; }
    .pm-poll-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* Кнопки автора на опросе (стат / редактирование) */
.pm-poll-author-btn {
    width: 22px;
    height: 22px;
    background: rgba(88, 101, 242, 0.15);
    border: 1px solid rgba(88, 101, 242, 0.4);
    color: #b5bac1;
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 120ms;
    margin-left: 2px;
}

    .pm-poll-author-btn:hover {
        background: rgba(88, 101, 242, 0.3);
        color: #f2f3f5;
    }

/* Poll stats modal */
.pm-poll-stats-question {
    color: #f2f3f5;
    font-size: 15px;
    font-weight: 600;
    padding: 4px 0;
    border-bottom: 1px solid #3f4147;
    margin-bottom: 4px;
}

.pm-poll-stats-loading {
    color: #b5bac1;
    padding: 10px;
    text-align: center;
}

.pm-poll-stats-note {
    color: #b5bac1;
    font-size: 12px;
    font-style: italic;
    padding: 4px 0;
}

.pm-poll-stats-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 50vh;
    overflow-y: auto;
}

.pm-poll-stats-option {
    border: 1px solid #3f4147;
    border-radius: 6px;
    padding: 8px 10px;
    background: rgba(0,0,0,0.15);
}

.pm-poll-stats-option-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #dcddde;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.pm-poll-stats-option-count {
    background: rgba(88, 101, 242, 0.25);
    color: #b5bac1;
    padding: 1px 7px;
    border-radius: 9px;
    font-size: 11px;
    min-width: 20px;
    text-align: center;
}

.pm-poll-stats-voters {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 4px;
}

.pm-poll-stats-voter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 4px;
    border-radius: 4px;
    font-size: 13px;
    color: #dcddde;
}

    .pm-poll-stats-voter:hover { background: rgba(255,255,255,0.04); }

.pm-poll-stats-voter-name {
    flex: 1;
    word-break: break-word;
}

.pm-poll-stats-voter-time {
    color: #949ba4;
    font-size: 11px;
    flex-shrink: 0;
}

.pm-poll-stats-empty {
    color: #949ba4;
    font-size: 12px;
    font-style: italic;
    padding: 4px 0 0 4px;
}

/* ── Spoiler ─────────────────────────────────────────────────── */
.chat-spoiler {
    position: relative;
    display: inline-block;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    padding: 2px 5px;
    cursor: pointer;
    vertical-align: middle;
    user-select: none;
}
.chat-spoiler .chat-spoiler-inner {
    filter: blur(5px);
    pointer-events: none;
    transition: filter 0.2s;
    user-select: none;
}
.chat-spoiler .chat-spoiler-btn {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #b0b4c1;
    font-size: 11px;
    font-weight: 500;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.chat-spoiler:hover .chat-spoiler-btn { color: #dcddde; }
.chat-spoiler--revealed .chat-spoiler-inner {
    filter: none;
    pointer-events: auto;
    user-select: text;
}
.chat-spoiler--revealed .chat-spoiler-btn { display: none; }

.pm-fmt-btn--spoiler svg { vertical-align: middle; }

/* Блок кода в сообщении (``` ... ```) */
.chat-code-block {
    background: var(--th-code-bg, #1e1f22);
    border: 1px solid #404249;
    border-left: 3px solid #5865f2;
    border-radius: 4px;
    padding: 10px 14px;
    margin: 6px 0;
    font-family: Consolas, Menlo, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.55;
    color: var(--th-code-text, #dcddde);
    /* Ограничиваем блок шириной родителя, прокрутка только внутри */
    display: block;
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
}

.chat-code-block code {
    display: block;
    white-space: pre;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: none;
    padding: 0;
    border: none;
}

/* Inline code внутри сообщения */
.chat-inline-code {
    background: var(--th-code-bg, rgba(0, 0, 0, 0.45));
    color: var(--th-code-text, inherit);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: Consolas, Menlo, "Courier New", monospace;
    font-size: 0.92em;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.pm-screen-fullscreen-btn:hover {
    background: rgba(0,0,0,0.85);
    color: #fff;
}
/* ══ Server rail image ══ */
.pm-rail-server-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* ══ Server choice modal ══ */
.pm-server-choice-box {
    width: 460px;
    text-align: center;
}

.pm-server-choice-btns {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 8px;
}

.pm-server-choice-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: #1e1f22;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 20px 12px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    color: #dbdee1;
}

    .pm-server-choice-btn:hover {
        border-color: #5865f2;
        background: #2b2d31;
    }

.pm-server-choice-label {
    font-size: 14px;
    font-weight: 600;
    color: #f2f3f5;
}

.pm-server-choice-hint {
    font-size: 12px;
    color: #949ba4;
}

/* ══ Create server modal ══ */
.pm-create-srv-modal {
    background: #2b2d31;
    border-radius: 12px;
    padding: 28px 32px;
    width: 440px;
    max-width: 95vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: #dbdee1;
}

.pm-create-srv-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #1e1f22;
    border: 2px dashed #4e5058;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: border-color .15s;
}

    .pm-create-srv-img:hover {
        border-color: #5865f2;
    }

.pm-create-srv-img-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pm-create-srv-img-hover {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #fff;
    font-weight: 600;
}

.pm-create-srv-img:hover .pm-create-srv-img-hover {
    display: flex;
}

.pm-modal-field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pm-modal-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    color: #b5bac1;
    text-transform: uppercase;
}

/* ── Message edit/delete ── */
.pm-msg {
    position: relative;
}

.pm-msg-actions {
    position: absolute;
    right: 8px;
    top: -14px;
    background: #2b2d31;
    border: 1px solid #3c3f44;
    border-radius: 6px;
    display: flex;
    gap: 2px;
    padding: 3px 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
    z-index: 10;
}

.pm-msg-action-btn {
    background: none;
    border: none;
    color: #b5bac1;
    cursor: pointer;
    border-radius: 4px;
    padding: 3px 5px;
    display: flex;
    align-items: center;
    transition: color .15s, background .15s;
}

    .pm-msg-action-btn:hover {
        color: #dbdee1;
        background: rgba(255,255,255,.08);
    }

.pm-msg-action-btn--danger:hover {
    color: #ed4245;
    background: rgba(237,66,69,.1);
}

.pm-msg-deleted {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #6d6f78;
    font-style: italic;
    font-size: 13px;
    background: rgba(255,255,255,.03);
    border-radius: 4px;
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,.05);
}

.pm-msg-edited {
    font-size: 10px;
    color: #6d6f78;
    margin-left: 4px;
    font-style: italic;
}

.pm-msg-edit-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.pm-msg-edit-input {
    background: #1e1f22;
    border: 1px solid #5865f2;
    border-radius: 6px;
    color: #dbdee1;
    font-size: 14px;
    padding: 8px 10px;
    resize: none;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.4;
}

/* ── Profile rail button & popup ── */
.pm-rail-spacer {
    flex: 1;
}

.pm-rail-profile-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 12px;
    flex-shrink: 0;
}

.pm-rail-profile-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #5865f2;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-radius 0.2s, background 0.2s;
    flex-shrink: 0;
}

    .pm-rail-profile-btn:hover {
        border-radius: 16px;
        background: #4752c4;
    }

.pm-profile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999;
}

.pm-profile-popup {
    position: fixed;
    bottom: 70px;
    left: 80px;
    z-index: 1000;
    background: #18191c;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 12px;
    width: 240px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    animation: pm-popup-in 0.15s cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes pm-popup-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pm-profile-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 2px 8px;
}

.pm-profile-popup-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #5865f2;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
}

.pm-profile-popup-info {
    overflow: hidden;
}

.pm-profile-popup-name {
    color: #f2f3f5;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pm-profile-popup-sub {
    color: #43b581;
    font-size: 12px;
    margin-top: 2px;
}

.pm-profile-popup-divider {
    height: 1px;
    background: rgba(255,255,255,0.07);
    margin: 4px 0 8px;
}

.pm-profile-popup-logout {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: none;
    color: #ed4245;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 7px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    text-align: left;
}

    .pm-profile-popup-logout:hover {
        background: rgba(237,66,69,0.15);
    }

/* ── Reactions ── */
.pm-msg-reactions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    min-height: 24px;
    position: relative;
}

.pm-reaction-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 2px 8px;
    cursor: pointer;
    color: #dcddde;
    font-size: 13px;
    transition: background 0.15s;
    line-height: 1.4;
}

    .pm-reaction-btn:hover {
        background: rgba(255,255,255,0.12);
        border-color: rgba(255,255,255,0.2);
    }

.pm-reaction-btn--mine {
    background: rgba(88,101,242,0.25);
    border-color: rgba(88,101,242,0.5);
    color: #fff;
}

.pm-reaction-count {
    font-size: 11px;
    color: #b9bbbe;
}

.pm-reaction-btn--mine .pm-reaction-count {
    color: #c9cdff;
}

/* pm-reaction-add-btn убран — кнопка реакции теперь в pm-msg-actions */

.pm-msg-action-emoji-wrap {
    position: relative;
}

.pm-emoji-picker {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    background: #2f3136;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 200;
    box-shadow: 0 6px 24px rgba(0,0,0,0.55);
    /* На узких экранах не выходим за viewport. */
    width: min(340px, calc(100vw - 16px));
}

/* ── Стикер-пикер (Noto Emoji GIF) ── */
.pm-sticker-picker {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    background: #2f3136;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 6px;
    z-index: 200;
    box-shadow: 0 6px 24px rgba(0,0,0,0.55);
    width: min(340px, calc(100vw - 16px));
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pm-sticker-cats {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding-bottom: 6px;
}

.pm-sticker-cat-btn {
    flex: 1;
    background: none;
    border: none;
    border-radius: 6px;
    padding: 4px;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity .12s, background .12s;
    line-height: 1;
}
.pm-sticker-cat-btn:hover { opacity: 0.8; background: rgba(255,255,255,.06); }
.pm-sticker-cat-btn--active { opacity: 1; background: rgba(255,255,255,.1); }

.pm-sticker-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    max-height: 240px;
    overflow-y: auto;
    padding: 2px;
}

.pm-sticker-btn {
    background: none;
    border: none;
    border-radius: 8px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .12s, transform .1s;
}
.pm-sticker-btn:hover { background: rgba(255,255,255,.1); transform: scale(1.15); }
.pm-sticker-btn img { display: block; }

/* Стикеры внутри emoji-пикера (вкладка 🎞) */
.pm-sticker-grid--inline {
    grid-template-columns: repeat(7, 1fr) !important;
}
.pm-sticker-inline-btn {
    padding: 3px !important;
}
.pm-sticker-inline-btn img {
    display: block;
    border-radius: 4px;
}

/* Стикер в теле сообщения */
.msg-noto-sticker {
    display: block;
    width: 48px;
    height: 48px;
    border-radius: 4px;
    margin: 2px 0;
}

/* .pm-sticker-picker mobile-rule consolidated with .pm-emoji-picker —
   см. правило @media (max-width: 767px) ниже. */

.pm-emoji-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 22px;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.1s, transform 0.08s;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    .pm-emoji-btn:hover {
        background: rgba(255,255,255,0.10);
        transform: scale(1.15);
    }

    .pm-emoji-btn:active {
        transform: scale(0.92);
    }

/* ── Tabs ── */
.pm-emoji-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 2px 4px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    overflow-x: auto;
    scrollbar-width: thin;
}

    .pm-emoji-tabs::-webkit-scrollbar {
        height: 4px;
    }

    .pm-emoji-tabs::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.15);
        border-radius: 2px;
    }

.pm-emoji-tab {
    flex-shrink: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 18px;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .12s;
    opacity: 0.6;
    line-height: 1;
}

    .pm-emoji-tab:hover {
        background: rgba(255,255,255,0.08);
        opacity: 0.9;
    }

    .pm-emoji-tab.pm-emoji-tab--active {
        background: rgba(88, 101, 242, 0.25);
        opacity: 1;
    }

/* ── Grid (прокручиваемая) ── */
.pm-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    max-height: 280px;
    overflow-y: auto;
    padding: 4px 2px;
    scrollbar-width: thin;
}

    .pm-emoji-grid::-webkit-scrollbar {
        width: 6px;
    }

    .pm-emoji-grid::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.18);
        border-radius: 3px;
    }

/* ── Анимированные смайлы (живут в picker'е) ── */
.pm-emoji-btn--anim {
    overflow: hidden;
}

.emoji-anim {
    display: inline-block;
    transform-origin: center center;
    will-change: transform;
}

.emoji-anim--bounce  { animation: emoji-bounce 1.4s ease-in-out infinite; }
.emoji-anim--tada    { animation: emoji-tada 1.6s ease-in-out infinite; }
.emoji-anim--spin    { animation: emoji-spin 2.4s linear infinite; }
.emoji-anim--pulse   { animation: emoji-pulse 1.2s ease-in-out infinite; }
.emoji-anim--shake   { animation: emoji-shake 1.0s ease-in-out infinite; }
.emoji-anim--wiggle  { animation: emoji-wiggle 1.2s ease-in-out infinite; }
.emoji-anim--swing   { animation: emoji-swing 1.8s ease-in-out infinite; }
.emoji-anim--float   { animation: emoji-float 2.2s ease-in-out infinite; }
.emoji-anim--rocket  { animation: emoji-rocket 1.8s ease-in-out infinite; }
.emoji-anim--flame   { animation: emoji-flame 0.8s ease-in-out infinite; }
.emoji-anim--heartbeat { animation: emoji-heartbeat 1.0s ease-in-out infinite; }

@keyframes emoji-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

@keyframes emoji-tada {
    0%       { transform: scale(1) rotate(0); }
    10%, 20% { transform: scale(0.9) rotate(-6deg); }
    30%, 50%, 70%, 90% { transform: scale(1.15) rotate(6deg); }
    40%, 60%, 80% { transform: scale(1.15) rotate(-6deg); }
    100%     { transform: scale(1) rotate(0); }
}

@keyframes emoji-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@keyframes emoji-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.25); }
}

@keyframes emoji-shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-3px) rotate(-4deg); }
    40%      { transform: translateX(3px) rotate(4deg); }
    60%      { transform: translateX(-3px) rotate(-4deg); }
    80%      { transform: translateX(3px) rotate(4deg); }
}

@keyframes emoji-wiggle {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(-12deg); }
    75%      { transform: rotate(12deg); }
}

@keyframes emoji-swing {
    0%, 100% { transform: rotate(-6deg); }
    50%      { transform: rotate(6deg); }
}

@keyframes emoji-float {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50%      { transform: translateY(-5px) rotate(2deg); }
}

@keyframes emoji-rocket {
    0%, 100% { transform: translate(0, 0) rotate(-15deg); }
    50%      { transform: translate(2px, -5px) rotate(-25deg); }
}

@keyframes emoji-flame {
    0%, 100% { transform: scale(1) translateY(0); }
    50%      { transform: scale(1.1) translateY(-2px); }
}

@keyframes emoji-heartbeat {
    0%, 100% { transform: scale(1); }
    14%, 42% { transform: scale(1.25); }
    28%, 56% { transform: scale(1); }
}

/* Эмодзи-сообщение целиком (1-3 символа без текста) показываем крупно */
.pm-msg-text--emoji-only {
    font-size: 42px;
    line-height: 1.1;
    padding: 4px 0;
}

    .pm-msg-text--emoji-only .emoji-anim {
        display: inline-block;
        margin: 0 2px;
    }

/* В реакциях анимированный смайл — без лишнего overflow и с базовым размером */
.pm-reaction-btn .emoji-anim {
    display: inline-block;
    line-height: 1;
}

/* На узких экранах picker'ы (реакции и инпут) анкорятся к viewport,
   а не к родителю-кнопке — иначе при кнопке не в правом краю экрана
   picker уезжает за левый край. Берём весь mobile-брейкпоинт (≤767px),
   чтобы и на планшетах в портрете picker не вылезал. */
@media (max-width: 767px) {
    .pm-emoji-picker,
    .pm-input-emoji-picker,
    .pm-sticker-picker {
        position: fixed;
        left: 8px;
        right: 8px;
        /* Поднимаем picker над клавиатурой (--kb-offset ставит chat.js по visualViewport)
           и над панелью ввода (~60px). Если клавиатуры нет — отступ от низа viewport
           равен высоте input-бара плюс резерв под адресную строку. */
        bottom: calc(var(--kb-offset, 0px) + 60px + env(safe-area-inset-bottom));
        top: auto;
        width: auto;
        max-width: none;
        /* Доступная высота = весь viewport минус клавиатура минус панель ввода
           минус шапка чата (~64px). Гарантирует, что сетка эмодзи полностью видна. */
        max-height: calc(100dvh - var(--kb-offset, 0px) - 140px);
    }

    .pm-emoji-grid {
        grid-template-columns: repeat(7, 1fr);
        max-height: none; /* родительский max-height уже ограничивает */
    }

    /* Стикеры внутри picker'а: на узких экранах форсируем картинки тянуться
       по ячейке, чтобы 32px GIF не вылезал за границы маленькой ячейки на узких
       экранах (Galaxy Fold в свёрнутом виде, iPhone SE и т.п.). */
    .pm-sticker-inline-btn img,
    .pm-sticker-btn img {
        width: 100%;
        height: auto;
        max-width: 32px;
    }
}

.pm-msg-edit-hint {
    font-size: 11px;
    color: #6d6f78;
}

/* ══ Pinned messages — header button ══ */
.pm-pin-header-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #b5bac1;
    cursor: pointer;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    transition: color .15s, background .15s;
}

    .pm-pin-header-btn:hover,
    .pm-pin-header-btn--active {
        color: #fff;
        background: rgba(255,255,255,.08);
    }

.pm-pin-header-btn--empty {
    color: #4e5058;
    cursor: default;
}

    .pm-pin-header-btn--empty:hover {
        color: #4e5058;
        background: none;
    }

.pm-pin-header-count {
    background: #5865f2;
    color: #fff;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    padding: 0 5px;
    min-width: 16px;
    text-align: center;
}

/* ══ Pinned messages panel ══ */
.pm-pinned-panel {
    position: absolute;
    top: 56px;
    right: 0;
    z-index: 50;
    width: 340px;
    max-height: 420px;
    overflow-y: auto;
    background: #2b2d31;
    border: 1px solid #1e1f22;
    border-radius: 0 0 0 8px;
    box-shadow: -4px 4px 16px rgba(0,0,0,.5);
    display: flex;
    flex-direction: column;
}

.pm-pinned-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 700;
    color: #b5bac1;
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.pm-pinned-panel-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #72767d;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

    .pm-pinned-panel-close:hover {
        color: #dbdee1;
    }

.pm-pinned-item {
    position: relative;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,.04);
}

    .pm-pinned-item:last-child {
        border-bottom: none;
    }

.pm-pinned-item-meta {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 3px;
}

.pm-pinned-item-author {
    font-size: 13px;
    font-weight: 600;
    color: #f2f3f5;
}

.pm-pinned-item-time {
    font-size: 11px;
    color: #72767d;
}

.pm-pinned-item-content {
    font-size: 13px;
    color: #b5bac1;
    white-space: pre-wrap;
    word-break: break-word;
    padding-right: 20px;
}

.pm-pinned-img {
    display: block;
    max-width: 100%;
    max-height: 160px;
    width: auto;
    height: auto;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: zoom-in;
    object-fit: cover;
}

.pm-pinned-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.pm-pinned-item-content .pm-quote-block {
    margin: 0 0 6px 0;
}

.pm-pinned-item-content a {
    color: #00a8fc;
    word-break: break-all;
}

.pm-pinned-item-unpin {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #72767d;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity .15s, color .15s;
}

.pm-pinned-item:hover .pm-pinned-item-unpin {
    opacity: 1;
}

.pm-pinned-item-unpin:hover {
    color: #ed4245;
}

/* Кнопка "В чат" в панели закреплённых */
.pm-pinned-jump-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    padding: 2px 8px;
    font-size: 11px;
    color: #5865f2;
    background: transparent;
    border: 1px solid #3c3f45;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}
.pm-pinned-item:hover .pm-pinned-jump-btn {
    opacity: 1;
}
.pm-pinned-jump-btn:hover {
    background: #5865f2;
    color: #fff;
    border-color: #5865f2;
}

/* Оверлей «Поиск сообщения...» */
.pm-jump-overlay {
    position: absolute;
    top: 56px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 120;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    background: #2b2d31;
    border: 1px solid #3c3f45;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    font-size: 13px;
    color: #b5bac1;
    pointer-events: none;
}
.pm-jump-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #4e5058;
    border-top-color: #5865f2;
    border-radius: 50%;
    animation: chat-spin 0.7s linear infinite;
    flex-shrink: 0;
}

/* Подсветка найденного сообщения */
@keyframes pm-msg-highlight-fade {
    0%   { background: rgba(88, 101, 242, 0.25); }
    70%  { background: rgba(88, 101, 242, 0.15); }
    100% { background: transparent; }
}
.pm-msg--highlight {
    animation: pm-msg-highlight-fade 2.5s ease forwards;
    border-radius: 6px;
}

/* ══ Pin badge on message ══ */
.pm-msg-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pm-msg-pin-badge {
    color: #faa61a;
    display: inline-flex;
    align-items: center;
    opacity: .7;
}

/* ══ Pin button in action toolbar ══ */
.pm-msg-action-btn--pinned {
    color: #faa61a !important;
}

    .pm-msg-action-btn--pinned:hover {
        color: #ffb83a !important;
    }

/* ══════════════════════════════════════════
   ИЗБРАННОЕ (FAVORITES / PERSONAL NOTES)
══════════════════════════════════════════ */

/* Золотой аватар для Избранного */
.pm-avatar-gold {
    background: linear-gradient(135deg, #f5a623, #c8913e) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

/* Кнопка Избранного в сайдбаре — чуть выделяется */
.pm-favorites-item {
    border-bottom: 1px solid rgba(255,255,255,.04);
    margin-bottom: 6px;
    padding-bottom: 14px;
}

/* Подзаголовок в шапке чата (для Избранного) */
.pm-chat-header-sub {
    font-size: 11px;
    color: #80848e;
    line-height: 1;
}

/* Заметка: строка */
.fav-note {
    position: relative;
}

    /* Чтобы кнопки действий на заметке были справа */
    .fav-note .pm-msg-actions {
        right: auto;
        left: -4px;
        top: 2px;
    }

/* ══ ChatPanel — недостающие классы ══ */

/* Typing indicator */
.pm-typing {
    padding: 2px 16px 4px;
    font-size: 12px;
    color: #949ba4;
    min-height: 20px;
    font-style: italic;
}

/* Inline edit box */
.pm-edit-box {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Многострочный textarea редактирования.
   Авторесайз делает JS (autoResizeTextarea) — ставит height по scrollHeight
   до 4 строк, дальше включается вертикальный скролл. */
.pm-edit-textarea {
    width: 100%;
    box-sizing: border-box;
    background: #1e1f22;
    color: #f2f3f5;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: inherit;
    /* Размер берём из глобальной настройки (Настройки → Внешний вид). */
    font-size: var(--app-font-size, 15px);
    line-height: 1.45;
    resize: none;
    outline: none;
    overflow-y: hidden;
    min-height: 34px;
    max-height: 120px;
}

    .pm-edit-textarea:focus {
        border-color: #5865f2;
    }

.pm-edit-hint {
    font-size: 11px;
    color: #949ba4;
    padding: 0 2px;
}

/* Строка с кнопками «Сохранить/Отмена» — видима на телефонах, где нет клавиатурных шорткатов */
.pm-edit-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.pm-edit-btn {
    border: none;
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s;
}

.pm-edit-btn--save {
    background: #5865f2;
    color: #fff;
}
.pm-edit-btn--save:hover { background: #4752c4; }

.pm-edit-btn--cancel {
    background: transparent;
    color: #b9bbbe;
}
.pm-edit-btn--cancel:hover { background: rgba(79, 84, 92, 0.3); color: #dcddde; }

.pm-edit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pm-edit-img-wrap {
    position: relative;
    display: inline-block;
    align-self: flex-start;
    border-radius: 6px;
    overflow: hidden;
    background: #1e1f22;
}

.pm-edit-img {
    display: block;
    max-width: 240px;
    max-height: 200px;
    object-fit: contain;
}

.pm-edit-img-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
}

.pm-edit-img-remove:hover {
    background: #ed4245;
}

.pm-edit-actions .pm-edit-hint { margin-left: auto; }
@media (max-width: 640px) {
    .pm-edit-actions .pm-edit-hint { display: none; }
}

/* Reactions row */
.pm-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

/* Message body / meta wrappers (unified ChatPanel) */
.pm-msg-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.pm-msg-meta {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

/* ── Add-channel button in sidebar ── */
.srv-add-ch-btn {
    background: none;
    border: none;
    color: #949ba4;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 4px;
    transition: color .15s;
}

    .srv-add-ch-btn:hover {
        color: #dbdee1;
    }

/* ── Own author name color ── */
.pm-msg-author--mine {
    color: #3ba55d;
}

.pm-msg-author--bot {
    color: #f0a500;
}

/* ── Server members right panel ── */
.srv-root {
    display: flex;
}

/* Бейдж «ГОСТЬ» в заголовке сервера — показывается, когда пользователь
   не участник, но открыл канал с включённым IsGuestReadable. */
.srv-guest-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 9px;
    font-weight: 700;
    color: #b5bac1;
    background: #3a3c41;
    border-radius: 4px;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

/* ── Ban banner: показывается вместо сайдбара/чата при заходе на сервер,
      где пользователь забанен ── */
.srv-banned-overlay {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e1f22;
    padding: 24px;
}

.srv-banned-card {
    max-width: 360px;
    text-align: center;
    background: #2b2d31;
    border: 1px solid #3a3c41;
    border-radius: 8px;
    padding: 28px 24px;
    color: #dbdee1;
}

.srv-banned-title {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 6px;
}

.srv-banned-sub {
    font-size: 14px;
    color: #b5bac1;
}

.srv-members-panel {
    width: 220px;
    min-width: 220px;
    background: #2b2d31;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 8px 0 16px;
    flex-shrink: 0;
}

    .srv-members-panel::-webkit-scrollbar {
        width: 6px;
    }

    .srv-members-panel::-webkit-scrollbar-track {
        background: transparent;
    }

    .srv-members-panel::-webkit-scrollbar-thumb {
        background: #1a1b1e;
        border-radius: 3px;
    }

.srv-members-header {
    padding: 16px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    color: #949ba4;
    letter-spacing: .4px;
    text-transform: uppercase;
}

.srv-member-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 4px;
    margin: 0 4px;
    cursor: default;
    transition: background .12s;
}

    .srv-member-item:hover {
        background: rgba(255,255,255,.06);
    }

.srv-member-name {
    font-size: 13px;
    color: #dbdee1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.srv-member-owner {
    color: #f0b132;
}

.srv-members-close-fab { display: none; }

@media (max-width: 700px) {
    .srv-members-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 500;
        width: 260px;
        max-width: 85vw;
        overflow-y: auto;
        box-shadow: -4px 0 16px rgba(0,0,0,.5);
    }

    .srv-members-close-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 24px;
        right: 24px;
        z-index: 501;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: #4f545c;
        border: none;
        color: #fff;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,.4);
    }

    .srv-members-close-fab:hover {
        background: #686d75;
    }
}

/* ══════════════════════════════════════════
   SERVER PAGE — мобильная адаптация (≤ 767px)
══════════════════════════════════════════ */
@media (max-width: 767px) {

    /* Сайдбар каналов на мобильном — на весь экран, уезжает влево при выборе канала.
       Базовые правила .pm-sidebar / .pm-sidebar--hidden уже есть выше; здесь только
       специфика server-page. */

    /* Заголовок сервера: больше тач-цели у иконок-кнопок. */
    .srv-header { padding: 12px !important; }
    .srv-hdr-btn {
        width: 36px;
        height: 36px;
        padding: 0;
    }

    /* Каналы в сайдбаре — больше отступ для удобного тапа. */
    .srv-ch-item { padding: 10px 12px; }

    /* Кнопка «+» для создания канала — крупнее. */
    .srv-add-ch-btn {
        font-size: 18px;
        padding: 2px 8px;
    }

    /* Кнопка тоггла участников и крестик «выйти из канала» —
       сдвигаем вниз, чтобы не наезжали на back-кнопку шапки. */
    .srv-members-toggle-btn {
        top: 10px;
        right: 8px;
        width: 36px;
        height: 36px;
    }

    /* На мобильном скрываем кнопку создания опроса из заголовка канала — освобождаем место */
    .pm-chat-header--channel .pm-hdr-icon-btn {
        display: none;
    }
    .pm-pin-header-btn {
        flex-shrink: 0;
    }

    /* Голосовые тайлы — меньше padding, чтобы помещались на узком экране. */
    .srv-voice-tile {
        padding: 12px;
        min-width: 88px;
    }
    .srv-voice-tile-av {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
    .srv-voice-active { padding: 16px; gap: 16px; }
    .srv-voice-active-grid { gap: 10px; }

    /* Voice-кнопки управления — крупнее тач-цели. */
    .srv-vc-btn {
        padding: 12px 18px;
        font-size: 14px;
    }

    /* Voice lobby — компактнее. */
    .srv-voice-lobby { padding: 16px; gap: 12px; }
    .srv-voice-lobby-icon { font-size: 56px; }
    .srv-voice-lobby-name { font-size: 18px; }

    /* Бейдж «ГОСТЬ» — меньше шрифт на узком. */
    .srv-guest-tag { font-size: 8px; padding: 1px 5px; }

    /* Ban-карта — меньше padding, чтобы помещалась. */
    .srv-banned-card { padding: 22px 18px; }
}

/* ── Server header: full actions (desktop) / ⋮ menu (mobile) ── */
.srv-hdr-full-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.srv-hdr-more-wrap {
    display: none;
    position: relative;
    flex-shrink: 0;
}

@media (max-width: 767px) {
    .srv-hdr-full-actions    { display: none; }
    .srv-hdr-more-wrap       { display: flex; }
    .srv-members-toggle-btn  { display: none !important; }
}

/* ══ Server.razor — voice channel & members toggle ══ */

.srv-chat-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Кнопка закрытия голосового вида */
.srv-voice-close-btn {
    background: none;
    border: none;
    color: #949ba4;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 14px;
    transition: color .15s, background .15s;
    margin-left: auto;
}

    .srv-voice-close-btn:hover {
        color: #dbdee1;
        background: rgba(255,255,255,.08);
    }

/* Кнопка тоггла участников — абсолютно в верхнем правом углу чата */
.srv-members-toggle-btn {
    position: absolute;
    top: 14px;
    right: 12px;
    background: none;
    border: none;
    color: #949ba4;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, background .15s;
    z-index: 10;
}

    .srv-members-toggle-btn:hover {
        color: #dbdee1;
        background: rgba(255,255,255,.08);
    }

.srv-members-toggle-btn--active {
    color: #fff;
    background: rgba(88,101,242,.3);
}

/* ── Voice lobby ── */
.srv-voice-lobby {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    color: #dbdee1;
}

.srv-voice-lobby-icon {
    font-size: 64px;
}

.srv-voice-lobby-name {
    font-size: 22px;
    font-weight: 700;
}

.srv-voice-lobby-hint {
    font-size: 13px;
    color: #949ba4;
    margin-top: 8px;
}

.srv-voice-lobby-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.srv-voice-lobby-user {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.srv-voice-lobby-av {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #5865f2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    overflow: hidden;
}

.srv-voice-lobby-av-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.srv-voice-join-btn {
    margin-top: 16px;
    padding: 10px 28px;
    background: #3ba55d;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}

    .srv-voice-join-btn:hover {
        background: #2d8049;
    }

.srv-voice-join-row {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.srv-voice-join-row .srv-voice-join-btn { margin-top: 0; }

.srv-voice-meeting-btn {
    padding: 10px 22px;
    background: #5865f2;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}

.srv-voice-meeting-btn:hover {
    background: #4752c4;
}

/* ── Create meeting dialog ── */
.meeting-dialog {
    background: #2b2d31;
    border-radius: 8px;
    width: min(90vw, 460px);
    max-height: 80vh;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    color: #dbdee1;
    display: flex;
    flex-direction: column;
}

.meeting-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #3c3f44;
    font-size: 16px;
    font-weight: 600;
    color: #f2f3f5;
}

.meeting-dialog-body {
    padding: 14px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.meeting-dialog-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #b9bbbe;
    letter-spacing: .5px;
}

.meeting-dialog-search {
    background: #1e1f22;
    border: 1px solid #3c3f44;
    border-radius: 6px;
    color: #dbdee1;
    font-size: 14px;
    padding: 8px 12px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
}
.meeting-dialog-search:focus { border-color: #5865f2; }

.meeting-dialog-friend-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 320px;
    overflow-y: auto;
}

.meeting-dialog-friend {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .12s;
}
.meeting-dialog-friend:hover { background: rgba(79, 84, 92, .25); }
.meeting-dialog-friend--picked { background: rgba(88, 101, 242, .18); }

.meeting-dialog-friend input[type=checkbox] { accent-color: #5865f2; }
.meeting-dialog-friend-name { font-size: 14px; color: #dbdee1; }

.meeting-dialog-loading,
.meeting-dialog-empty {
    color: #949ba4;
    font-size: 13px;
    padding: 8px 0;
}

.meeting-dialog-hint {
    font-size: 13px;
    color: #b9bbbe;
}

.meeting-dialog-link {
    display: flex;
    gap: 6px;
}
.meeting-dialog-link input {
    flex: 1;
    background: #1e1f22;
    border: 1px solid #3c3f44;
    border-radius: 6px;
    color: #dbdee1;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
}

.meeting-dialog-actions {
    padding: 12px 16px;
    border-top: 1px solid #3c3f44;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.meeting-dialog-actions--wrap { flex-wrap: wrap; }
.meeting-dialog--narrow { width: min(92vw, 420px); }

/* ══ Страница "Мои встречи" ══ */
.my-meetings {
    max-width: 820px;
    margin: 0 auto;
    padding: 24px 20px 80px;
    color: #dbdee1;
}
.my-meetings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 12px;
}
.my-meetings-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
}
.my-meetings-group-title {
    margin: 20px 0 8px;
    font-size: 12px;
    font-weight: 700;
    color: #b5bac1;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.my-meetings-empty {
    text-align: center;
    color: #96989d;
    padding: 36px 12px;
    font-size: 14px;
}
.my-meeting-row {
    display: flex;
    gap: 12px;
    background: #2b2d31;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    align-items: flex-start;
}
.my-meeting-row--live {
    border-color: rgba(87, 242, 135, .35);
    box-shadow: 0 0 0 1px rgba(87, 242, 135, .15);
}
.my-meeting-row-main { flex: 1; min-width: 0; }
.my-meeting-row-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.my-meeting-row-meta {
    margin-top: 4px;
    font-size: 12px;
    color: #96989d;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.my-meeting-row-desc {
    margin-top: 6px;
    font-size: 13px;
    color: #b5bac1;
    white-space: pre-wrap;
    word-break: break-word;
}
.my-meeting-row-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.my-meeting-live-pill {
    background: #57f287;
    color: #1e1f22;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: .04em;
}
.my-meeting-host-pill {
    background: rgba(88, 101, 242, .25);
    color: #c9cdfb;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Tabs "Сейчас / Запланировать" в CreateMeetingDialog */
.meeting-dialog-when-tabs {
    display: flex;
    gap: 6px;
    background: rgba(0,0,0,.25);
    padding: 4px;
    border-radius: 8px;
}
.meeting-dialog-when-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: #b5bac1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.meeting-dialog-when-tab:hover { color: #dbdee1; }
.meeting-dialog-when-tab--on {
    background: #5865f2;
    color: #fff;
}

/* ══ Meeting room ══ */
.meeting-room {
    min-height: 100vh;
    background: #1e1f22;
    color: #dbdee1;
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.meeting-room-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
}

.meeting-chat-panel {
    width: 320px;
    flex: 0 0 320px;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    background: #2b2d31;
    border-left: 1px solid #1e1f22;
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
}

.meeting-chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #1e1f22;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    gap: 8px;
}

.meeting-chat-header-title { flex: 1; }

.meeting-chat-close-btn,
.meeting-chat-toggle-btn,
.meeting-chat-save-btn {
    background: transparent;
    border: none;
    color: #b5bac1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
    transition: background .12s, color .12s;
}
.meeting-chat-close-btn:hover,
.meeting-chat-toggle-btn:hover,
.meeting-chat-save-btn:hover:not(:disabled) { background: #4f545c; color: #fff; }
.meeting-chat-save-btn:disabled { opacity: .4; cursor: not-allowed; }
.meeting-chat-save-btn--done { color: #3ba55d; }
.meeting-chat-save-btn--done:hover { color: #3ba55d; }

.meeting-chat-toggle-btn {
    position: relative;
    padding: 6px 10px;
    font-size: 15px;
    background: #4f545c;
    color: #fff;
}

.meeting-chat-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ed4245;
    color: #fff;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    min-width: 16px;
    text-align: center;
    line-height: 14px;
}

.meeting-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meeting-chat-empty {
    color: #949ba4;
    font-size: 13px;
    text-align: center;
    margin: auto 12px;
}

.meeting-chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    padding: 6px 10px;
    border-radius: 8px;
    background: #383a40;
    color: #dbdee1;
    font-size: 13px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.meeting-chat-msg--mine {
    align-self: flex-end;
    background: #5865f2;
    color: #fff;
}

.meeting-chat-msg-head {
    font-size: 11px;
    color: #b5bac1;
    margin-bottom: 2px;
    display: flex;
    gap: 6px;
    align-items: baseline;
}
.meeting-chat-msg--mine .meeting-chat-msg-head { color: #d8dbff; }

.meeting-chat-msg-name { font-weight: 600; }
.meeting-chat-msg-time { font-size: 10px; opacity: .7; }

.meeting-chat-msg-text { white-space: pre-wrap; }

.meeting-chat-input-row {
    display: flex;
    gap: 6px;
    padding: 8px;
    border-top: 1px solid #1e1f22;
    background: #2b2d31;
}

.meeting-chat-input {
    flex: 1;
    resize: none;
    background: #1e1f22;
    border: 1px solid #1e1f22;
    color: #dbdee1;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-family: inherit;
    min-height: 36px;
    max-height: 120px;
    outline: none;
}
.meeting-chat-input:focus { border-color: #5865f2; }

.meeting-chat-send-btn {
    background: #5865f2;
    border: none;
    color: #fff;
    padding: 0 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s;
}
.meeting-chat-send-btn:hover:not(:disabled) { background: #4752c4; }
.meeting-chat-send-btn:disabled { opacity: .5; cursor: default; }

/* ── Floating chat-toggle (FAB) ── */
.meeting-chat-fab {
    position: fixed;
    right: 16px;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: #5865f2;
    color: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
    cursor: pointer;
    z-index: 2400;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .12s, transform .12s;
}
.meeting-chat-fab:hover  { background: #4752c4; }
.meeting-chat-fab:active { transform: scale(.96); }

.meeting-chat-fab-icon { font-size: 22px; line-height: 1; }

.meeting-chat-fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    padding: 2px 6px;
    background: #ed4245;
    color: #fff;
    border: 2px solid #1e1f22;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
}

.meeting-chat-fab--unread {
    animation: meeting-chat-fab-pulse 1.6s ease-out infinite;
}
@keyframes meeting-chat-fab-pulse {
    0%   { box-shadow: 0 6px 18px rgba(0, 0, 0, .45),
                       0 0 0 0 rgba(237, 66, 69, 0.55); }
    70%  { box-shadow: 0 6px 18px rgba(0, 0, 0, .45),
                       0 0 0 14px rgba(237, 66, 69, 0); }
    100% { box-shadow: 0 6px 18px rgba(0, 0, 0, .45),
                       0 0 0 0 rgba(237, 66, 69, 0); }
}

@media (max-width: 720px) {
    .meeting-chat-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(360px, 100vw);
        z-index: 2500;
        box-shadow: -4px 0 20px rgba(0, 0, 0, .55);
    }
    .meeting-chat-fab {
        right: 12px;
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }
}

.meeting-room-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #2b2d31;
    border-radius: 8px;
}

.meeting-reconnect-banner {
    background: #faa61a;
    color: #2b2d31;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.meeting-room-titlewrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.15;
    min-width: 0;
}
.meeting-room-title { font-size: 17px; font-weight: 600; color: #fff; }
.meeting-room-id {
    font-size: 11px;
    color: #949ba4;
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.meeting-room-count {
    margin-left: auto;
    font-size: 12px;
    color: #949ba4;
}

.meeting-room-invite-btn {
    padding: 7px 16px;
    border-radius: 6px;
    border: none;
    background: #5865f2;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s;
}
.meeting-room-invite-btn:hover { background: #4752c4; }
.meeting-room-invite-btn--secondary { background: #4f545c; }
.meeting-room-invite-btn--secondary:hover { background: #5d6269; }

.meeting-dialog-friend-tag {
    margin-left: auto;
    font-size: 11px;
    color: #3ba55d;
    font-weight: 600;
}
.meeting-dialog-friend:disabled { opacity: .65; cursor: default; }

.meeting-room-status {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #949ba4;
    font-size: 14px;
    text-align: center;
}

.meeting-room-status-detail {
    font-size: 12px;
    color: #ed4245;
    margin-top: 8px;
    max-width: 480px;
}

.meeting-room-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    align-content: start;
}

/* Speaker view: один большой тайл сверху, остальные в полоске thumbnails */
.meeting-room-grid--speaker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: flex-start;
}
.meeting-room-grid--speaker .meeting-tile {
    flex: 0 0 auto;
    width: 140px;
    min-height: 100px;
    padding: 8px 6px;
    gap: 4px;
}
.meeting-room-grid--speaker .meeting-tile-name {
    font-size: 11px;
    max-width: 130px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}
.meeting-room-grid--speaker .meeting-tile--main {
    order: -1;
    flex: 1 1 100%;
    width: 100%;
    min-height: 50vh;
    padding: 18px 12px;
    gap: 8px;
}
.meeting-room-grid--speaker .meeting-tile--main .meeting-tile-name { font-size: 14px; max-width: none; }
.meeting-room-grid--speaker .meeting-tile--main .meeting-tile-video,
.meeting-room-grid--speaker .meeting-tile--main .mt-camera-video {
    max-height: 60vh;
}

/* Pin кнопка в bottom-left угле плитки */
.meeting-tile-pin {
    position: absolute;
    bottom: 6px;
    left: 6px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.45);
    color: #fff;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, background .12s;
    z-index: 5;
}
.meeting-tile:hover .meeting-tile-pin,
.meeting-tile-pin--on { opacity: 1; }
.meeting-tile-pin:hover { background: rgba(0,0,0,.75); }
.meeting-tile-pin--on { background: #5865f2; }
.meeting-tile-pin--on:hover { background: #4752c4; }
.meeting-tile--pinned { /* визуальный маркер pinned-тайла */
    box-shadow: 0 0 0 2px #5865f2, 0 0 10px rgba(88,101,242,.35);
}

/* На малых экранах thumb-плитки чуть меньше */
@media (max-width: 720px) {
    .meeting-room-grid--speaker .meeting-tile { width: 110px; min-height: 80px; }
    .meeting-room-grid--speaker .meeting-tile--main { min-height: 40vh; }
    .meeting-tile-pin { width: 30px; height: 30px; opacity: 1; } /* всегда видна на мобиле, у hover нет смысла */
}

.meeting-tile {
    background: #2b2d31;
    border-radius: 10px;
    padding: 18px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 2px solid transparent;
    transition: border-color .15s, box-shadow .12s ease;
    position: relative;
}
.meeting-tile--me   { border-color: #5865f2; }
.meeting-tile--host { border-color: #faa61a; }
.meeting-tile--guest{ border-color: #949ba4; }

/* Активный говорящий — зелёное свечение поверх любого border-color */
.meeting-tile--speaking {
    box-shadow: 0 0 0 2px #3ba55d, 0 0 16px rgba(59,165,93,.55);
}

.meeting-tile-av {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #5865f2;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    overflow: hidden;
}

.meeting-tile-av-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.meeting-tile-name {
    font-size: 14px;
    text-align: center;
    color: #dbdee1;
}

.meeting-tile-tag {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    background: #5865f2;
    color: #fff;
    text-transform: uppercase;
}
.meeting-tile-tag--guest { background: #4f545c; }

.meeting-tile-muted {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 16px;
}

.meeting-tile-screen {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 16px;
}

.meeting-tile-video,
.meeting-tile .mt-camera-video {
    width: 100%;
    max-width: 220px;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #000;
    border-radius: 8px;
    display: block;
    cursor: zoom-in;
}
.meeting-tile-video:fullscreen,
.meeting-tile .mt-camera-video:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    object-fit: contain;
    cursor: zoom-out;
}
.mt-screen-video:fullscreen { cursor: zoom-out; }
.meeting-tile-video--hidden { display: none; }

/* Когда у пира есть видео — JS вставляет <video class="mt-camera-video"> внутрь tile,
   а аватар не рендерится (см. _peersWithCamera). */
.meeting-tile .mt-camera-video { margin-bottom: 6px; }

/* ── Screen-share area ── */
.mt-screen-share-wrap {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
}
.mt-screen-share-wrap--hidden { display: none; }

.mt-screen-share-area {
    min-height: 200px;
    max-height: 65vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.mt-screen-share-toolbar {
    position: absolute;
    top: 8px;
    left: 12px;
    right: 12px;
    background: rgba(0,0,0,.55);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mt-fullscreen-btn {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.mt-fullscreen-btn:hover { background: rgba(255,255,255,.28); }

.mt-screen-share-area .mt-screen-video {
    max-width: 100%;
    max-height: 65vh;
    object-fit: contain;
    background: #000;
}

.meeting-room-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
    background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,.18) 100%);
    border-radius: 14px;
}

.meeting-ctl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 18px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: rgba(79, 84, 92, 0.85);
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background .15s, transform .12s, box-shadow .15s, border-color .15s;
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.meeting-ctl-btn:hover:not(:disabled) {
    background: rgba(93, 98, 105, 0.95);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.28);
}
.meeting-ctl-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.meeting-ctl-btn:focus-visible {
    outline: none;
    border-color: rgba(255,255,255,.45);
    box-shadow: 0 0 0 3px rgba(88,101,242,.35);
}
.meeting-ctl-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Цветовые варианты — все поверх базы */
.meeting-ctl-btn--off          { background: #faa61a; color: #1e1f22; }
.meeting-ctl-btn--off:hover:not(:disabled)    { background: #f5b333; }
.meeting-ctl-btn--leave        { background: #ed4245; }
.meeting-ctl-btn--leave:hover:not(:disabled)  { background: #d63b3e; }
.meeting-ctl-btn--hand-on      { background: #faa61a; color: #1e1f22; }
.meeting-ctl-btn--hand-on:hover:not(:disabled){ background: #f5b333; }
.meeting-ctl-btn--on           { background: #5865f2; color: #fff; }
.meeting-ctl-btn--on:hover:not(:disabled)     { background: #6772f4; }
.meeting-ctl-btn--ptt          { background: rgba(79,84,92,.85); color: #fff; }
.meeting-ctl-btn--ptt-active   { background: #3ba55d; color: #fff; box-shadow: 0 0 0 2px rgba(59,165,93,.35); }

/* Touch-and-hold PTT кнопка: на мобиле — большая «зажми чтобы говорить» */
.meeting-ctl-btn--ptt-hold {
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
.meeting-ctl-btn--ptt-hold.meeting-ctl-btn--ptt-active {
    animation: meeting-ptt-pulse 1.4s ease-in-out infinite;
}
@keyframes meeting-ptt-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(59,165,93,.35); }
    50%      { box-shadow: 0 0 0 6px rgba(59,165,93,.18); }
}


/* ── Reactions popup ── */
.meeting-ctl-react-wrap {
    position: relative;
    display: inline-flex;
    align-items: stretch;
}
.meeting-ctl-react-wrap > .meeting-ctl-btn { flex: 1 1 auto; }
.meeting-react-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #2b2d31;
    border: 1px solid #1e1f22;
    border-radius: 10px;
    padding: 8px;
    display: flex;
    gap: 4px;
    box-shadow: 0 8px 24px rgba(0,0,0,.55);
    z-index: 60;
    animation: meeting-react-popup-in .15s ease-out;
    max-width: calc(100vw - 16px);
    overflow-x: auto;
}
.meeting-react-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 22px;
    line-height: 1;
    transition: background .12s, transform .12s;
}
.meeting-react-btn:hover {
    background: rgba(88,101,242,.18);
    transform: scale(1.18);
}
@keyframes meeting-react-popup-in {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Live captions overlay ── */
.meeting-captions-overlay {
    width: min(92%, 760px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
}
.meeting-caption-line {
    align-self: center;
    background: rgba(0,0,0,.74);
    color: #fff;
    padding: 7px 14px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.35;
    max-width: 100%;
    text-shadow: 0 1px 3px rgba(0,0,0,.7);
    transition: opacity .2s;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.meeting-caption-line--interim { opacity: .68; font-style: italic; }
.meeting-caption-line--final   { opacity: 1; }
.meeting-caption-name {
    font-weight: 700;
    margin-right: 6px;
    color: #5fd0ff;
}

@media (max-width: 720px) {
    .meeting-captions-overlay { width: 96%; }
    .meeting-caption-line { font-size: 13.5px; padding: 6px 10px; }
}

/* ── Host moderation: tile menu ── */
.meeting-tile-mod {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 5;
}
.meeting-tile-mod-btn {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background .12s;
}
.meeting-tile-mod-btn:hover { background: rgba(0,0,0,.75); }

.meeting-tile-mod-menu {
    position: absolute;
    top: 30px;
    left: 0;
    background: #2b2d31;
    border: 1px solid #1e1f22;
    border-radius: 10px;
    padding: 6px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,.55);
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: 30;
    animation: meeting-react-popup-in .15s ease-out;
}
.meeting-tile-mod-menu button {
    background: transparent;
    border: none;
    color: #dbdee1;
    text-align: left;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background .12s;
}
.meeting-tile-mod-menu button:hover { background: rgba(88,101,242,.18); }
.meeting-tile-mod-menu--danger { color: #ed4245 !important; }
.meeting-tile-mod-menu--danger:hover { background: rgba(237,66,69,.12) !important; }

.meeting-room-invite-btn--on {
    background: #faa61a !important;
    color: #1e1f22 !important;
}
.meeting-room-invite-btn--on:hover { background: #d28b14 !important; }

.meeting-toast--mod { border-left: 4px solid #faa61a; }

/* ── Controls «More» popup ── */
.meeting-more-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #2b2d31;
    border: 1px solid #1e1f22;
    border-radius: 12px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 240px;
    max-width: calc(100vw - 16px);
    box-shadow: 0 12px 32px rgba(0,0,0,.6);
    z-index: 60;
    animation: meeting-react-popup-in .15s ease-out;
}
.meeting-more-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: none;
    color: #dbdee1;
    text-align: left;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13.5px;
    transition: background .12s;
}
.meeting-more-item:hover:not(:disabled) { background: rgba(88,101,242,.18); }
.meeting-more-item:disabled { opacity: .5; cursor: not-allowed; }
.meeting-more-item--on { background: rgba(88,101,242,.22); color: #fff; }
.meeting-more-icon { font-size: 16px; width: 22px; text-align: center; }
.meeting-more-label { flex: 1; }
.meeting-more-state {
    font-size: 11.5px;
    color: #949ba4;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.meeting-more-item--on .meeting-more-state { color: #5fd0ff; }

/* ── Device picker popup ── */
.meeting-device-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #2b2d31;
    border: 1px solid #1e1f22;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,.6);
    z-index: 60;
    width: min(92vw, 340px);
    max-width: calc(100vw - 16px);
    animation: meeting-react-popup-in .15s ease-out;
}
.meeting-device-popup-title {
    font-size: 13px;
    font-weight: 700;
    color: #dbdee1;
    margin-bottom: 2px;
}
.meeting-device-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #b9bbbe;
}
.meeting-device-row select {
    background: #1e1f22;
    border: 1px solid #3c3f44;
    border-radius: 8px;
    color: #dbdee1;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
    transition: border-color .12s;
}
.meeting-device-row select:focus { border-color: #5865f2; }
.meeting-device-popup-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 2px;
}

/* ── Raised-hand badge ── */
.meeting-tile-hand {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(250,166,26,.92);
    color: #1e1f22;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,.35);
    animation: meeting-hand-pulse 1.6s ease-in-out infinite;
    z-index: 4;
}
/* Если в этой же плитке есть host-меню ⋮ (тоже top-left) — сдвигаем hand правее */
.meeting-tile:has(.meeting-tile-mod) .meeting-tile-hand { left: 42px; }
@keyframes meeting-hand-pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.12); }
}

/* ── Network quality bars ── */
.meeting-tile-netq {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 4px 5px;
    border-radius: 5px;
    background: rgba(0,0,0,.4);
    z-index: 4;
}
.meeting-tile-netq-bar {
    width: 3px;
    background: rgba(255,255,255,.22);
    border-radius: 1px;
    transition: background .2s;
}
.meeting-tile-netq-bar:nth-child(1) { height: 5px; }
.meeting-tile-netq-bar:nth-child(2) { height: 8px; }
.meeting-tile-netq-bar:nth-child(3) { height: 11px; }

.meeting-tile-netq--3 .meeting-tile-netq-bar { background: #3ba55d; }
.meeting-tile-netq--2 .meeting-tile-netq-bar:nth-child(1),
.meeting-tile-netq--2 .meeting-tile-netq-bar:nth-child(2) { background: #faa61a; }
.meeting-tile-netq--1 .meeting-tile-netq-bar:nth-child(1) { background: #ed4245; }
.meeting-tile-netq--0 .meeting-tile-netq-bar:nth-child(1) { background: #ed4245; }
/* score 0 — мигаем «нет соединения», 1 — статически красный */
.meeting-tile-netq--0 { animation: meeting-netq-pulse 1.6s ease-in-out infinite; }
@keyframes meeting-netq-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .4; }
}

/* ── Floating emoji reactions ── */
.meeting-reactions-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 3;
}
.meeting-reaction-float {
    position: absolute;
    bottom: 8px;
    left: 50%;
    font-size: 36px;
    line-height: 1;
    opacity: 0;
    transform: translateX(-50%);
    animation: meeting-reaction-rise 2.6s ease-out forwards;
    will-change: transform, opacity;
    text-shadow: 0 2px 8px rgba(0,0,0,.45);
}
@keyframes meeting-reaction-rise {
    0%   { transform: translate(-50%, 10px) scale(.5); opacity: 0; }
    15%  { transform: translate(-50%, 0)    scale(1);  opacity: 1; }
    80%  { transform: translate(-50%, -120px) scale(1.05); opacity: 1; }
    100% { transform: translate(-50%, -160px) scale(1.15); opacity: 0; }
}

.meeting-room-listen-only {
    padding: 10px 16px;
    border-radius: 8px;
    background: #faa61a;
    color: #2b2d31;
    font-size: 13px;
    font-weight: 600;
}

/* ── Recording indicators ── */
.meeting-rec-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(237, 66, 69, 0.14);
    border: 1px solid rgba(237, 66, 69, 0.45);
    color: #ed4245;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
}
.meeting-rec-banner-text { color: #f3a4a6; font-weight: 500; }
.meeting-rec-banner .meeting-rec-dot {
    width: 10px;
    height: 10px;
}

.meeting-rec-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ed4245;
    box-shadow: 0 0 0 0 rgba(237, 66, 69, 0.6);
    animation: meeting-rec-pulse 1.4s ease-out infinite;
    vertical-align: middle;
}

@keyframes meeting-rec-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(237, 66, 69, 0.65); opacity: 1; }
    70%  { box-shadow: 0 0 0 8px rgba(237, 66, 69, 0); opacity: 0.85; }
    100% { box-shadow: 0 0 0 0 rgba(237, 66, 69, 0); opacity: 1; }
}

.meeting-tile-rec {
    position: absolute;
    bottom: 6px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(237, 66, 69, 0.92);
    color: #fff;
    padding: 2px 8px 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
}
.meeting-tile-rec .meeting-rec-dot {
    background: #fff;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7);
    animation-name: meeting-rec-pulse-white;
}

@keyframes meeting-rec-pulse-white {
    0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
    70%  { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

.meeting-ctl-btn--rec {
    background: #ed4245;
    color: #fff;
}
.meeting-ctl-btn--rec:hover:not(:disabled) { background: #d63b3e; }
.meeting-ctl-btn--rec .meeting-rec-dot {
    background: #fff;
    animation-name: meeting-rec-pulse-white;
}

.meeting-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: #2b2d31;
    color: #dbdee1;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 3000;
    max-width: calc(100vw - 24px);
    word-break: break-word;
}
.meeting-toast button {
    background: transparent;
    border: none;
    color: #949ba4;
    cursor: pointer;
    font-size: 18px;
}

/* ── Mobile adaptation for the meeting room ── */
@media (max-width: 720px) {
    .meeting-room-main {
        padding: 8px;
        gap: 8px;
        padding-top: calc(8px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }
    .meeting-room-header {
        padding: 8px 10px;
        gap: 6px;
        flex-wrap: wrap;
        row-gap: 6px;
    }
    .meeting-room-title { font-size: 14px; }
    .meeting-room-id    { font-size: 10px; max-width: 160px; }
    .meeting-room-count {
        margin-left: auto;
        font-size: 11px;
        white-space: nowrap;
    }
    .meeting-room-invite-btn {
        padding: 5px 10px;
        font-size: 11px;
        flex: 1 1 auto;
        min-width: 0;
    }
    .meeting-rec-banner {
        padding: 5px 10px;
        font-size: 12px;
    }
    .meeting-room-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }
    .meeting-tile {
        padding: 12px 6px;
        gap: 6px;
    }
    .meeting-tile-av { width: 48px; height: 48px; font-size: 18px; }
    .meeting-tile-name { font-size: 12px; }
    .meeting-tile-tag { font-size: 9px; padding: 1px 5px; }
    .meeting-tile-video, .meeting-tile .mt-camera-video {
        max-width: 100%;
    }
    .mt-screen-share-area { max-height: 38vh; }

    .meeting-room-controls {
        flex-wrap: wrap;
        gap: 6px;
        padding: 6px 0;
    }
    .meeting-room-controls {
        gap: 6px;
        padding: 8px 4px;
        border-radius: 10px;
    }
    .meeting-ctl-btn {
        min-height: 40px;
        padding: 0 12px;
        font-size: 12.5px;
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
    }
    .meeting-ctl-react-wrap { flex: 1 1 calc(50% - 6px); }
    .meeting-ctl-react-wrap > .meeting-ctl-btn { width: 100%; }
    .meeting-ctl-btn--leave { flex-basis: 100%; }
    .meeting-room-listen-only {
        font-size: 11px;
        padding: 8px 12px;
        flex-basis: 100%;
        text-align: center;
    }

    /* Toast прижимаем к низу с учётом FAB */
    .meeting-toast {
        right: 12px;
        left: 12px;
        bottom: 12px;
        font-size: 12px;
    }
}

@media (max-width: 380px) {
    .meeting-room-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    .meeting-ctl-btn {
        font-size: 11.5px;
        padding: 0 10px;
        min-height: 38px;
    }
    .meeting-room-invite-btn { font-size: 10px; padding: 4px 8px; }
    .meeting-react-popup { padding: 6px; }
    .meeting-react-btn { font-size: 20px; padding: 3px 6px; }
}

/* ── Guest join landing ── */
.meeting-join {
    min-height: 100vh;
    background: #1e1f22;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.meeting-join-card {
    background: #2b2d31;
    color: #dbdee1;
    padding: 28px 28px 24px;
    border-radius: 12px;
    width: min(92vw, 380px);
    box-shadow: 0 8px 32px rgba(0,0,0,.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.meeting-join-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(88,101,242,.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.meeting-join-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.meeting-join-hint {
    font-size: 14px;
    color: #b9bbbe;
    line-height: 1.45;
}

.meeting-join-status {
    font-size: 14px;
    color: #949ba4;
    padding: 8px 0;
}

.meeting-join-input {
    width: 100%;
    box-sizing: border-box;
    background: #1e1f22;
    border: 1px solid #3c3f44;
    border-radius: 6px;
    color: #dbdee1;
    padding: 10px 14px;
    font-size: 15px;
    outline: none;
}
.meeting-join-input:focus { border-color: #5865f2; }

.meeting-join-error {
    color: #ed4245;
    font-size: 13px;
    align-self: flex-start;
}

.meeting-join-btn {
    width: 100%;
    padding: 11px;
    border-radius: 6px;
    border: none;
    background: #5865f2;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: background .12s;
}
.meeting-join-btn:hover:not(:disabled) { background: #4752c4; }
.meeting-join-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Pre-join lobby ── */
.meeting-lobby {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    gap: 18px;
    color: #dbdee1;
}

.meeting-lobby-title {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
}

.meeting-lobby-subtitle {
    font-size: 14px;
    color: #b9bbbe;
    text-align: center;
}

.meeting-lobby-content {
    display: flex;
    gap: 24px;
    align-items: stretch;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 920px;
}

.meeting-lobby-preview {
    flex: 1 1 480px;
    min-width: 280px;
    max-width: 560px;
    aspect-ratio: 16 / 9;
    background: #111214;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 6px 24px rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
}

.meeting-lobby-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* зеркальное отображение для self-view */
}
.meeting-lobby-video--hidden { display: none; }

.meeting-lobby-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: #5865f2;
    color: #fff;
    font-size: 32px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.meeting-lobby-avatar .meeting-tile-av-img {
    width: 100%; height: 100%; object-fit: cover; border-radius: 50%;
}

.meeting-lobby-level-row {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,.55);
    padding: 8px 12px;
    border-radius: 8px;
}

.meeting-lobby-level-icon { font-size: 14px; }

.meeting-lobby-level-bar {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,.12);
    border-radius: 3px;
    overflow: hidden;
}

.meeting-lobby-level-fill {
    height: 100%;
    background: linear-gradient(90deg, #3ba55d 0%, #faa61a 70%, #ed4245 100%);
    transition: width .08s linear;
}

.meeting-lobby-settings {
    flex: 1 1 280px;
    min-width: 260px;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #2b2d31;
    padding: 18px;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,.35);
}

.meeting-lobby-error {
    color: #ed4245;
    font-size: 13px;
    background: rgba(237,66,69,.1);
    border: 1px solid rgba(237,66,69,.35);
    border-radius: 6px;
    padding: 8px 10px;
}

.meeting-lobby-toggles {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.meeting-lobby-toggle {
    flex: 1 1 0;
    min-width: 130px;
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: background .12s, opacity .12s;
}
.meeting-lobby-toggle--on  { background: #4f545c; }
.meeting-lobby-toggle--on:hover  { background: #5d6269; }
.meeting-lobby-toggle--off { background: #ed4245; }
.meeting-lobby-toggle--off:hover { background: #c03537; }
.meeting-lobby-toggle:disabled { opacity: .5; cursor: not-allowed; }

.meeting-lobby-devices {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meeting-lobby-device-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #b9bbbe;
}
.meeting-lobby-device-row select {
    background: #1e1f22;
    border: 1px solid #3c3f44;
    border-radius: 6px;
    color: #dbdee1;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
}
.meeting-lobby-device-row select:focus { border-color: #5865f2; }
.meeting-lobby-device-row select:disabled { opacity: .5; cursor: not-allowed; }

.meeting-lobby-join-btn {
    margin-top: auto;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: #5865f2;
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: background .12s;
}
.meeting-lobby-join-btn:hover:not(:disabled) { background: #4752c4; }
.meeting-lobby-join-btn:disabled { opacity: .6; cursor: not-allowed; }

@media (max-width: 720px) {
    .meeting-lobby-content { flex-direction: column; gap: 16px; }
    .meeting-lobby-preview { width: 100%; max-width: 100%; }
    .meeting-lobby-settings { max-width: 100%; }
    .meeting-lobby-title { font-size: 18px; }
}

/* ── Toast: meeting invite ── */
.meeting-invite-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: #2b2d31;
    color: #dbdee1;
    padding: 14px 16px;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,.55);
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 280px;
    max-width: 360px;
    z-index: 3000;
    border: 1px solid #5865f2;
    animation: meeting-invite-fade-in .25s ease;
}

@keyframes meeting-invite-fade-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.meeting-invite-toast-text {
    font-size: 14px;
    color: #dbdee1;
}

.meeting-invite-toast-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Напоминание о начале — отличается цветом рамки, чтобы юзер видел разницу
   между «вас пригласили» и «начнётся через N минут». Если оба тоста показаны
   одновременно — reminder располагаем выше через отступ. */
.meeting-invite-toast--reminder {
    border-color: #f0b132;
    bottom: 110px;
}

/* ── Voice active ── */
.srv-voice-active {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 24px;
}

.srv-voice-active-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
}

.srv-voice-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: rgba(255,255,255,.05);
    border-radius: 12px;
    min-width: 100px;
}

.srv-voice-tile--me {
    border: 2px solid #3ba55d;
}

.srv-voice-tile-av {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #5865f2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
}

.srv-voice-tile-av-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.srv-voice-tile-name {
    font-size: 13px;
    color: #dbdee1;
}

/* Voice controls */
.srv-voice-controls {
    display: flex;
    gap: 12px;
}

.srv-vc-btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    background: #4e5058;
    color: #fff;
    transition: background .15s;
}

    .srv-vc-btn:hover {
        background: #5d6069;
    }

.srv-vc-btn--active {
    background: #f04747;
}

    .srv-vc-btn--active:hover {
        background: #c03034;
    }

.srv-vc-btn--danger {
    background: #da373c;
}

    .srv-vc-btn--danger:hover {
        background: #c03034;
    }

/* ══ Screen share area ══ */
.srv-screen-share-area {
    width: 100%;
    background: #111;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 160px;
    max-height: 55vh;
    flex-shrink: 0;
}

.srv-screen-share-area--hidden {
    display: none;
}

/* видео вставляется через JS — растягиваем его */
.srv-screen-share-area video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    object-fit: contain;
    border-radius: 0;
}

.srv-screen-share-self-label {
    padding: 12px 16px;
    color: #b5bac1;
    font-size: 13px;
    font-style: italic;
    text-align: center;
}

.srv-screen-share-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
    z-index: 10;
}

.srv-screen-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    background: rgba(0,0,0,.65);
    color: #fff;
    backdrop-filter: blur(4px);
    transition: background .15s;
}

    .srv-screen-btn:hover {
        background: rgba(0,0,0,.85);
    }

.srv-screen-btn--stop {
    color: #f04747;
}

    .srv-screen-btn--stop:hover {
        background: rgba(240,71,71,.2);
    }

/* Кнопка демонстрации экрана (активная) */
.srv-vc-btn--screen {
    background: #5865f2;
}

    .srv-vc-btn--screen:hover {
        background: #4752c4;
    }

/* ── Members panel voice sections ── */
.srv-members-voice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.srv-members-voice-count {
    background: rgba(88,101,242,.25);
    color: #5865f2;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    min-width: 18px;
    text-align: center;
}

.pm-avatar-green {
    background: #3ba55d;
}

/* ══ @Mention inline ══ */
.pm-mention {
    color: #7289da;
    background: rgba(114,137,218,.15);
    border-radius: 3px;
    padding: 0 2px;
    cursor: default;
}

.pm-mention--me {
    color: #faa61a;
    background: rgba(250,166,26,.15);
}

/* ══ @Mention dropdown ══ */
.pm-mention-dropdown {
    background: #2b2d31;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    padding: 4px 0;
    margin-bottom: 4px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

.pm-mention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #dcddde;
    transition: background .1s;
}

    .pm-mention-item:hover,
    .pm-mention-item--active {
        background: #404249;
    }

.pm-mention-av {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #5865f2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}
.pm-mention-name { font-weight: 500; }


/* ══════════════════════════════════════════
   CALL WIDGET (FloatingCallBar + Overlay)
══════════════════════════════════════════ */

/* ── Incoming / Outgoing overlay ── */
.cw-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0,0,0,0.75);
    display: flex; align-items: center; justify-content: center;
    animation: cw-fade-in 0.2s ease;
}
@keyframes cw-fade-in { from { opacity: 0 } to { opacity: 1 } }

/* ── Drop reason banner — показываем когда звонок прервался по сбою ── */
.cw-drop-banner {
    position: fixed;
    top: 16px; left: 50%; transform: translateX(-50%);
    z-index: 2100;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px 10px 12px;
    max-width: calc(100vw - 32px);
    background: #c62828; color: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,.35);
    cursor: pointer;
    font-size: 14px; line-height: 1.3;
    animation: cw-drop-slide-in .25s cubic-bezier(.2,.7,.3,1);
}
.cw-drop-banner svg { flex: 0 0 auto; opacity: .9; }
.cw-drop-text { flex: 1; min-width: 0; }
.cw-drop-close {
    flex: 0 0 auto;
    background: transparent; color: #fff; opacity: .8;
    border: none; cursor: pointer;
    font-size: 22px; line-height: 1;
    padding: 0 2px; margin-left: 4px;
}
.cw-drop-close:hover { opacity: 1; }
@keyframes cw-drop-slide-in {
    from { opacity: 0; transform: translate(-50%, -16px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

.cw-ov-card {
    background: #2b2d31;
    border-radius: 16px;
    padding: 36px 40px 28px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    min-width: 260px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.cw-ov-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg,#5865f2,#7c4dff);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-weight: 700; color: #fff;
    box-shadow: 0 0 0 4px rgba(88,101,242,.25);
    position: relative;
}
.cw-ov-name  { font-size: 20px; font-weight: 700; color: #fff; }
.cw-ov-hint  { font-size: 13px; color: #96989d; }
.cw-ov-actions { display: flex; gap: 20px; margin-top: 8px; }

.cw-ov-btn {
    width: 56px; height: 56px; border-radius: 50%; border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform 0.15s, filter 0.15s;
}
.cw-ov-btn:hover { transform: scale(1.1); filter: brightness(1.15); }
.cw-ov-decline { background: #ed4245; color: #fff; }
.cw-ov-accept  { background: #3ba55c; color: #fff; }

/* ── Floating active call bar ── */
.cw-bar {
    position: fixed;
    bottom: 24px; right: 24px;
    z-index: 1900;
    background: #2b2d31;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 10px 0 10px 10px;
    display: flex; align-items: stretch;
    box-shadow: 0 8px 32px rgba(0,0,0,0.45);
    user-select: none;
    min-width: 220px;
    overflow: hidden;
    animation: cw-slide-in 0.25s cubic-bezier(.22,.68,0,1.2);
}
@keyframes cw-slide-in {
    from { opacity: 0; transform: translateY(20px) scale(0.95) }
    to   { opacity: 1; transform: translateY(0)   scale(1) }
}

/* Хэндл для перетаскивания */
.cw-drag-handle {
    width: 20px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: grab; flex-shrink: 0; border-radius: 4px;
    color: #72767d;
    transition: background 0.15s;
}
.cw-drag-handle:hover  { background: rgba(255,255,255,0.07); }
.cw-drag-handle:active { cursor: grabbing; }

/* Правая вертикальная drag-ручка (только мобильный) */
.cw-drag-handle-right {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 24px;
    align-self: stretch;
    flex-shrink: 0;
    cursor: grab;
    background: rgba(255,255,255,0.05);
    touch-action: none;
    margin-left: 4px;
}
.cw-drag-handle-right span {
    display: block;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
}
.cw-drag-handle-right:active { background: rgba(255,255,255,0.10); cursor: grabbing; }

@media (max-width: 767px) {
    .cw-drag-handle-right { display: flex; }
    .cw-drag-handle       { display: none; }
}

/* Аватар + имя + таймер */
.cw-bar-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.cw-bar-avatar {
    width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg,#5865f2,#7c4dff);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff;
    position: relative;
    transition: box-shadow .15s ease, transform .15s ease;
}

/* ─── Индикация говорящего ─────────────────────────────────────
   Класс ставит bimflowWebRtc на любые элементы с data-pm-speaker="local|remote",
   когда RMS звука превышает порог. Сияющий КВАДРАТ обводит круглый аватар —
   достигается через ::after с rounded-corners 6px и пульсирующим glow. */
.pm-speaking::after {
    content: '';
    position: absolute;
    inset: -5px;
    border: 2px solid #57f287;
    border-radius: 6px;
    pointer-events: none;
    animation: pmSpeakPulse 1.2s ease-in-out infinite;
}
@keyframes pmSpeakPulse {
    0%, 100% {
        box-shadow: 0 0 8px 1px rgba(87, 242, 135, 0.55);
        opacity: 0.9;
    }
    50% {
        box-shadow: 0 0 18px 3px rgba(87, 242, 135, 0.95);
        opacity: 1;
    }
}
.cw-bar-texts { display: flex; flex-direction: column; min-width: 0; }
.cw-bar-name  { font-size: 13px; font-weight: 600; color: #e3e5e8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-bar-time  { font-size: 11px; color: #57f287; font-variant-numeric: tabular-nums; }

/* Кнопки управления */
.cw-bar-btns { display: flex; align-items: center; gap: 6px; flex-shrink: 0; padding-right: 6px; }

.cw-btn {
    width: 32px; height: 32px; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.06);
    color: #b5bac1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.cw-btn:hover         { background: rgba(255,255,255,0.14); color: #e3e5e8; }
.cw-btn--active       { background: rgba(88,101,242,.28); color: #7289da; }
.cw-btn--active:hover { background: rgba(88,101,242,.44); }
.cw-btn--end          { background: rgba(237,66,69,.18); color: #ed4245; }
.cw-btn--end:hover    { background: #ed4245; color: #fff; }
.cw-btn--rec          { background: rgba(237,66,69,.22); color: #ed4245; }
.cw-btn--rec:hover    { background: rgba(237,66,69,.36); }

/* ── Встроенная панель звонка в ChatPanel (видна когда мы в чате собеседника
   активного звонка; плавающая плашка в этот момент скрыта). ── */
.pm-call-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin: 0;
    background: linear-gradient(180deg, rgba(88,101,242,.12), rgba(88,101,242,.06));
    border-bottom: 1px solid rgba(88,101,242,.22);
    flex-wrap: wrap;
    flex-shrink: 0;
}
.pm-call-bar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    color: #dcddde;
    font-size: 13px;
}
.pm-call-bar-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #43b581;
    box-shadow: 0 0 0 2px rgba(67,181,129,.25);
}
.pm-call-bar-dot.pm-speaking {
    background: #5dd0a8;
    box-shadow: 0 0 0 3px rgba(67,181,129,.45);
}
.pm-call-bar-time {
    font-weight: 600;
    color: #f5f5f6;
    font-variant-numeric: tabular-nums;
}
.pm-call-bar-rec {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(237,66,69,.18);
    color: #ed4245;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .5px;
}
.pm-call-bar-hint {
    color: #b9bbbe;
    font-size: 12px;
    font-style: italic;
}
.pm-call-bar-btns {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.pm-call-vol-wrap { position: relative; }
.pm-call-vol-popup {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #1e1f22;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px;
    padding: 10px 12px;
    z-index: 700;
    min-width: 240px;
    box-shadow: 0 8px 28px rgba(0,0,0,.5);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pm-call-captions {
    padding: 6px 12px 10px;
    background: linear-gradient(180deg, rgba(88,101,242,.06), transparent);
    border-bottom: 1px solid rgba(255,255,255,.04);
}
.pm-call-captions .cw-caption-line {
    background: rgba(20,22,26,.75);
}

@media (max-width: 600px) {
    .pm-call-bar { gap: 8px; padding: 6px 8px; }
    .pm-call-bar-info { font-size: 12px; }
    .pm-call-bar-hint { display: none; }
}

/* ── Subtitles overlay (показ реплик собеседника поверх плашки звонка) ── */
.cw-captions-overlay {
    position: fixed;
    bottom: 96px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(720px, 92vw);
    z-index: 9998;
    pointer-events: none;
}
.cw-caption-line {
    background: rgba(20, 22, 26, 0.86);
    color: #f5f5f6;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.35;
    box-shadow: 0 4px 16px rgba(0,0,0,.32);
    backdrop-filter: blur(6px);
}
.cw-caption-line--interim { opacity: .72; font-style: italic; }
.cw-caption-name { font-weight: 600; color: #b9bbbe; margin-right: 6px; }
.cw-caption-text { color: #f5f5f6; word-break: break-word; }
.cw-rec-dot {
    display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    background: #ed4245; box-shadow: 0 0 0 2px rgba(237,66,69,.25);
    animation: cw-rec-pulse 1.2s ease-in-out infinite;
}
@keyframes cw-rec-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .35; }
}
.cw-btn:disabled      { opacity: .35; cursor: default; pointer-events: none; }

/* ── Volume overlay panel ──────────────────────────────── */
.cw-vol-overlay {
    position: fixed;
    bottom: 80px;          /* над плашкой */
    left: 50%;
    transform: translateX(-50%);
    z-index: 2100;
    animation: cwVolIn .18s ease;
}
@keyframes cwVolIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.cw-vol-panel {
    background: #1e1f22;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 14px;
    padding: 14px 18px 12px;
    min-width: 280px;
    max-width: 340px;
    box-shadow: 0 8px 32px rgba(0,0,0,.6);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cw-vol-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.cw-vol-panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #e3e5e8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cw-vol-panel-close {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.08);
    color: #949ba4;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.cw-vol-panel-close:hover { background: rgba(255,255,255,.16); color: #fff; }

/* Строка со слайдером */
.cw-vol-panel-track {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #b5bac1;
}
.cw-vol-panel-slider-wrap {
    position: relative;
    flex: 1;
    height: 20px;
    display: flex;
    align-items: center;
}
.cw-vol-panel-slider {
    position: relative;
    width: 100%;
    z-index: 1;
    accent-color: #5865f2;
    cursor: pointer;
    margin: 0;
}
.cw-vol-panel-slider:disabled { opacity: .35; cursor: default; }
.cw-vol-panel-pct {
    font-size: 12px;
    font-weight: 700;
    color: #5865f2;
    min-width: 36px;
    text-align: right;
}

/* Кнопка мьют */
.cw-vol-panel-mute {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,.07);
    color: #b5bac1;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.cw-vol-panel-mute:hover    { background: rgba(255,255,255,.13); color: #fff; }
.cw-vol-panel-mute--on      { background: rgba(237,66,69,.2); color: #ed4245; }
.cw-vol-panel-mute--on:hover { background: rgba(237,66,69,.35); }

/* Кнопка/попап громкости на тайле участника */
.srv-tile-vol-wrap { position: relative; }

.srv-tile-vol-btn {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.45);
    color: #b5bac1;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.srv-tile-vol-btn:hover      { background: rgba(0,0,0,.7); color: #fff; }
.srv-tile-vol-btn--muted     { background: rgba(237,66,69,.35); color: #ed4245; }
.srv-tile-vol-btn--muted:hover { background: rgba(237,66,69,.6); }

.srv-vol-popup {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    background: #1e1f22;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px;
    padding: 8px 10px;
    z-index: 500;
    min-width: 150px;
    box-shadow: 0 4px 16px rgba(0,0,0,.5);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.srv-vol-popup--up { bottom: calc(100% + 6px); top: auto; }

.srv-vol-popup-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.srv-vol-val {
    font-size: 11px;
    color: #949ba4;
    min-width: 34px;
    text-align: right;
}
.srv-vol-slider {
    flex: 1;
    accent-color: #5865f2;
    cursor: pointer;
}
.srv-vol-mute-btn {
    width: 100%;
    padding: 5px 8px;
    border: none;
    border-radius: 6px;
    background: rgba(255,255,255,.07);
    color: #b5bac1;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    transition: background .15s;
}
.srv-vol-mute-btn:hover     { background: rgba(255,255,255,.13); color: #fff; }
.srv-vol-mute-btn--on       { background: rgba(237,66,69,.2); color: #ed4245; }
.srv-vol-mute-btn--on:hover { background: rgba(237,66,69,.35); }

/* Запись о звонке в ленте сообщений */
.pm-msg-call {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(88,101,242,.10);
    color: #b5bac1;
    font-size: 13px;
}
.pm-msg-call--missed {
    background: rgba(237,66,69,.10);
    color: #ed4245;
}
.pm-msg-call-icon { display: inline-flex; }
.pm-msg-call-title { font-weight: 600; }
.pm-msg-call-dur {
    color: #96989d;
    font-variant-numeric: tabular-nums;
    margin-left: 4px;
}
.pm-msg-call--missed .pm-msg-call-dur { color: rgba(237,66,69,.7); }

/* Запись о передаче файла (P2P / через сервер) — светло-жёлтая плашка по аналогии со звонком.
   Компонуется в две строки: заголовок (иконка + "Передача файла" + бейдж P2P/сервер + размер)
   и оригинальное имя файла (полностью, с переносом по словам). */
.pm-msg-file {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(250, 204, 21, .14);
    border: 1px solid rgba(250, 204, 21, .35);
    color: #f5e6a8;
    font-size: 13px;
    max-width: 100%;
}
.pm-msg-file--p2p {
    background: rgba(250, 204, 21, .18);
    border-color: rgba(250, 204, 21, .45);
}
.pm-msg-file-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.pm-msg-file-icon  { display: inline-flex; color: #f0c14b; }
.pm-msg-file-title { font-weight: 600; }
.pm-msg-file-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.pm-msg-file-badge--p2p {
    background: #43b581;
    color: #0c1e15;
}
.pm-msg-file-badge--relay {
    background: rgba(255,255,255,.12);
    color: #c9c9c9;
}
.pm-msg-file-name  {
    color: #fff;
    font-weight: 500;
    word-break: break-all;            /* длинные имена без пробелов всё равно переносятся */
    overflow-wrap: anywhere;
    line-height: 1.3;
}
.pm-msg-file-size {
    color: #d6c690;
    font-variant-numeric: tabular-nums;
    margin-left: auto;                /* выталкиваем размер вправо */
}

/* Превью удалённой демонстрации экрана в плавающей плашке */
.cw-screen-preview {
    width: 100%;
    max-width: 360px;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    margin-top: 8px;
    overflow: hidden;
    cursor: pointer;
}
.cw-screen-preview video {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
}
.cw-bar--with-screen {
    flex-direction: column;
    align-items: stretch;
    min-width: 260px;
}
.cw-bar-row {
    display: flex; align-items: center; gap: 10px; flex: 1;
}
.cw-bar--with-screen .cw-bar-row {
    gap: 10px;
}

/* Self-view собственной камеры в плавающей плашке звонка.
   --pip  — поверх удалённой демонстрации экрана (как PiP в чате),
   --solo — отдельным превью когда удалённого экрана нет.        */
.cw-self-cam video {
    width: 100%; height: 100%;
    display: block;
}
.cw-self-cam--pip video {
    object-fit: cover;
}
.cw-self-cam--solo video {
    object-fit: contain;
    background: #000;
    transform: scaleX(-1); /* mirror the camera for a natural selfie view */
}
.cw-self-cam--pip {
    position: absolute;
    right: 8px; bottom: 8px;
    width: 28%;
    max-width: 140px;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.25);
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
    z-index: 2;
}
.cw-self-cam--solo {
    position: relative;
    width: 100%;
    max-width: 360px;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 8px;
    margin-top: 8px;
    overflow: hidden;
}
.cw-self-cam-label {
    position: absolute;
    left: 8px; top: 8px;
    padding: 2px 8px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: 11px;
    border-radius: 4px;
    pointer-events: none;
}

/* cw-screen-preview — родитель для PiP, нужен relative чтобы абсолютка прикрепилась к нему */
.cw-screen-preview { position: relative; }
@media (max-width: 600px) {
    .cw-self-cam--solo { max-width: none; }
}

/* Мобильная адаптация: занимаем всю ширину у нижнего края, чтобы панель
   всегда была видна независимо от сохранённой позиции */
@media (max-width: 600px) {
    .cw-bar {
        left: 8px !important;
        right: 8px !important;
        top: auto !important;
        min-width: 0;
        width: auto;
        padding: 8px 0 8px 8px;
    }
    .cw-bar .cw-drag-handle { display: none; }
    .cw-bar-name { font-size: 12px; }
    .cw-btn { width: 36px; height: 36px; }  /* удобнее для пальца */
    .cw-screen-preview { max-width: none; }
    /* Демонстрация экрана на телефоне фактически бесполезна (getDisplayMedia
       либо не поддерживается, либо шарит весь экран целиком), плюс панели не
       хватает места — убираем кнопку. */
    .cw-btn--screen { display: none; }
}

/* ── Кликабельный ник (открывает профиль) ─────────────────── */
.pm-msg-author--click {
    cursor: pointer;
}
.pm-msg-author--click:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ── User profile bottom-sheet ───────────────────────────── */
.uprof-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.uprof-sheet {
    background: var(--th-bg-secondary, #232428);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: 0 -4px 32px rgba(0,0,0,.5);
    animation: uprofSlideUp .22s cubic-bezier(.32,.72,0,1);
}

@keyframes uprofSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.uprof-handle-bar {
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,.18);
    border-radius: 2px;
    margin: 10px auto 0;
}

/* Баннер */
.uprof-banner {
    position: relative;
    height: 110px;
    margin-top: 8px;
    background: linear-gradient(135deg, #5865f2, #7b68ee);
    flex-shrink: 0;
}

.uprof-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0,0,0,.4);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.uprof-close:hover { background: rgba(0,0,0,.65); }

/* Аватар торчит из баннера */
.uprof-avatar-wrap {
    position: absolute;
    bottom: -36px;
    left: 20px;
}

.uprof-avatar {
    width: 76px !important;
    height: 76px !important;
    font-size: 26px !important;
    border: 4px solid var(--th-bg-secondary, #232428) !important;
    box-sizing: content-box !important;
}

/* Тело */
.uprof-body {
    padding: 44px 20px 24px;
}

.uprof-loading {
    padding: 32px 0;
    color: #949ba4;
    font-size: 14px;
    text-align: center;
}

.uprof-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--th-text, #f2f3f5);
    line-height: 1.2;
}

.uprof-sub {
    font-size: 13px;
    color: #949ba4;
    margin-top: 3px;
}

.uprof-section {
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--th-bg-tertiary, #2b2d31);
    border-radius: 10px;
}
.uprof-section-text {
    font-size: 14px;
    color: var(--th-text, #dcddde);
    white-space: pre-wrap;
}

/* Общие друзья */
.uprof-mutual {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}
.uprof-mutual-avatars {
    display: flex;
}
.uprof-mutual-av {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--th-bg-secondary, #232428);
    margin-left: -6px;
    background: #5865f2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    flex-shrink: 0;
}
.uprof-mutual-av:first-child { margin-left: 0; }
.uprof-mutual-label {
    font-size: 13px;
    color: #949ba4;
}

/* Кнопки действий */
.uprof-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.uprof-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 12px;
    border: none;
    border-radius: 10px;
    background: var(--th-bg-tertiary, #2b2d31);
    color: var(--th-text, #f2f3f5);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: filter .15s;
}
.uprof-btn:hover { filter: brightness(1.15); }
.uprof-btn--primary {
    background: var(--th-accent, #5865f2);
}

/* Инфо-строка */
.uprof-info-block {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 11px 14px;
    background: var(--th-bg-tertiary, #2b2d31);
    border-radius: 10px;
    font-size: 13px;
    color: #949ba4;
}

/* На широких экранах — карточка в центре, не на всю ширину */
@media (min-width: 600px) {
    .uprof-overlay { align-items: center; }
    .uprof-sheet   { border-radius: 16px; max-height: 80vh; }
}

/* ══ Chat search ══ */

/* Header search/icon button */
.pm-hdr-icon-btn {
    background: none;
    border: none;
    color: #949ba4;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.pm-hdr-icon-btn:hover {
    color: #dbdee1;
    background: rgba(255,255,255,.08);
}
.pm-hdr-icon-btn--active {
    color: #fff;
    background: rgba(88,101,242,.25);
}

/* Search panel (same style as pinned panel) */
.pm-search-panel {
    background: #2b2d31;
    border-bottom: 1px solid #1e1f22;
    max-height: 380px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Info panel — фото / аудио / файлы / ссылки */
.pm-info-panel {
    background: #2b2d31;
    border-bottom: 1px solid #1e1f22;
    max-height: 460px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.pm-info-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; border-bottom: 1px solid #1e1f22;
}
.pm-info-panel-title { color: #f2f3f5; font-size: 14px; font-weight: 600; }
.pm-info-tabs {
    display: flex; gap: 4px; padding: 8px 8px 0;
    border-bottom: 1px solid #1e1f22; flex-wrap: wrap;
}
.pm-info-tab {
    background: transparent; border: none; color: #b9bbbe;
    font-size: 13px; padding: 6px 10px; cursor: pointer; border-radius: 4px 4px 0 0;
    transition: background .12s, color .12s;
}
.pm-info-tab:hover { background: rgba(255,255,255,.04); color: #f2f3f5; }
.pm-info-tab--active { background: #1e1f22; color: #f2f3f5; }
.pm-info-body { flex: 1; overflow-y: auto; padding: 10px 14px; }
.pm-info-empty { color: #b9bbbe; font-size: 13px; text-align: center; padding: 20px 0; }
.pm-info-load-sentinel { display: flex; justify-content: center; align-items: center; padding: 12px 0; min-height: 24px; }
.pm-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 4px;
}
.pm-info-image {
    aspect-ratio: 1; overflow: hidden; border-radius: 4px;
    background: #1e1f22; display: block;
}
.pm-info-image img { width: 100%; height: 100%; object-fit: cover; }
.pm-info-row {
    padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.04);
    color: #dbdee1; font-size: 13px;
}
.pm-info-row:last-child { border-bottom: none; }
.pm-info-row--link { display: block; color: #00aff4; text-decoration: none; }
.pm-info-row--link:hover { text-decoration: underline; }
.pm-info-row-name { word-break: break-all; }
.pm-info-row-date { color: #80848e; font-size: 11px; margin-top: 2px; }
.pm-info-row audio { display: block; width: 100%; margin-top: 6px; }

.pm-search-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #1e1f22;
}

.pm-search-input {
    flex: 1;
    background: #1e1f22;
    border: 1px solid #3c3f44;
    border-radius: 4px;
    color: #dbdee1;
    font-size: 14px;
    padding: 5px 10px;
    outline: none;
    min-width: 0;
}
.pm-search-input:focus { border-color: #5865f2; }

.pm-search-clear-btn {
    background: none;
    border: none;
    color: #949ba4;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.pm-search-clear-btn:hover { color: #dbdee1; }

.pm-search-count {
    padding: 6px 14px 2px;
    font-size: 11px;
    color: #5865f2;
    font-weight: 600;
}

.pm-search-empty {
    padding: 16px 14px;
    font-size: 13px;
    color: #5d6673;
    text-align: center;
}

.pm-search-results {
    overflow-y: auto;
    flex: 1;
}
.pm-search-results::-webkit-scrollbar { width: 4px; }
.pm-search-results::-webkit-scrollbar-thumb { background: #1a1b1e; border-radius: 2px; }

.pm-search-result-item {
    padding: 8px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,.04);
    transition: background .1s;
}
.pm-search-result-item:hover { background: rgba(255,255,255,.06); }

.pm-search-result-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}
.pm-search-result-author {
    font-size: 13px;
    font-weight: 600;
    color: #c0c4cc;
}
.pm-search-result-time {
    font-size: 11px;
    color: #5d6673;
}
.pm-search-result-text {
    font-size: 13px;
    color: #949ba4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pm-search-mark {
    background: rgba(250, 166, 26, .35);
    color: #faa61a;
    border-radius: 2px;
    padding: 0 1px;
}

/* ══ Server management UI ══ */

/* Header buttons (invite / delete server) */
.srv-hdr-btn {
    background: none;
    border: none;
    color: #949ba4;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .15s, background .15s;
    flex-shrink: 0;
}
.srv-hdr-btn:hover {
    color: #dbdee1;
    background: rgba(255,255,255,.08);
}
.srv-hdr-btn--danger:hover {
    color: #f04747;
    background: rgba(240,71,71,.12);
}

/* Channel list items */
.srv-ch-item {
    position: relative;
    padding-right: 8px !important;
}

/* Gear settings button on channel item.
   На десктопе (есть hover) — скрыта до наведения на канал.
   На тач-устройствах (hover нет) — всегда видна, иначе её нельзя нажать. */
.srv-ch-gear {
    background: none;
    border: none;
    color: #949ba4;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity .15s, color .15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.srv-ch-gear--hovered,
.srv-ch-item:hover .srv-ch-gear {
    opacity: 1;
}
@media (hover: none) {
    .srv-ch-gear { opacity: 1; }
}
.srv-ch-gear:hover {
    color: #dbdee1;
}

/* Channel badge (lock / readonly) */
.srv-ch-badge {
    font-size: 11px;
    margin-left: 2px;
    opacity: .7;
    flex-shrink: 0;
}

/* Members panel: banned state */
.srv-member-banned {
    opacity: .55;
}

/* Role badge next to name */
.srv-role-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 0 4px;
    margin-left: 4px;
    border-radius: 3px;
    vertical-align: middle;
    background: rgba(255,255,255,.08);
}
.srv-role-badge--owner { color: #f0b132; }

/* Member action buttons */
.srv-member-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity .12s;
}
.srv-member-item:hover .srv-member-actions {
    opacity: 1;
}
.srv-member-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    padding: 2px 4px;
    border-radius: 3px;
    color: #949ba4;
    line-height: 1;
    transition: background .12s, color .12s;
}
.srv-member-action-btn:hover {
    background: rgba(255,255,255,.08);
    color: #dbdee1;
}
.srv-member-action-btn--danger:hover {
    background: rgba(240,71,71,.15);
    color: #f04747;
}
.srv-member-action-btn--success:hover {
    background: rgba(59,165,93,.15);
    color: #3ba55d;
}
.srv-member-action-btn--mod:hover {
    background: rgba(88,101,242,.15);
    color: #5865f2;
}

/* Маленький цветной кружок-индикатор роли рядом с именем */
.srv-role-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-left: 5px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Voice header in members panel */
.srv-members-voice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.srv-members-voice-count {
    font-size: 11px;
    background: rgba(255,255,255,.1);
    border-radius: 8px;
    padding: 0 6px;
}

/* ── Link Preview ── */
.link-preview {
    display: flex;
    flex-direction: column;
    margin-top: 6px;
    border-left: 3px solid #5865f2;
    border-radius: 4px;
    background: rgba(255,255,255,.05);
    overflow: hidden;
    max-width: 440px;
    text-decoration: none;
    color: inherit;
    transition: background .15s;
}
.link-preview:hover { background: rgba(255,255,255,.09); }
.link-preview__img {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
}
.link-preview__body {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.link-preview__site {
    font-size: 11px;
    color: #5865f2;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.link-preview__title {
    font-size: 14px;
    font-weight: 600;
    color: #e3e5e8;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.link-preview__desc {
    font-size: 12px;
    color: #a3a6aa;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ─── Context Menu ─────────────────────────────────────────── */
.ctx-backdrop {
    position: fixed; inset: 0; z-index: 999;
}
.ctx-menu {
    position: fixed; z-index: 1000;
    min-width: 180px;
    background: #18191c;
    border: 1px solid #2e3035;
    border-radius: 6px;
    padding: 4px 0;
    box-shadow: 0 8px 32px rgba(0,0,0,.6);
    user-select: none;
}
.ctx-section-label {
    font-size: 10px;
    font-weight: 700;
    color: #72767d;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 6px 12px 2px;
}
.ctx-divider {
    height: 1px;
    background: #2e3035;
    margin: 4px 0;
}
.ctx-item {
    display: block; width: 100%;
    padding: 8px 14px;
    background: none; border: none;
    color: #dcddde;
    font-size: 14px; text-align: left;
    cursor: pointer;
    border-radius: 3px;
    transition: background .12s, color .12s;
}
.ctx-item:hover { background: #5865f2; color: #fff; }
.ctx-item--secret { color: #b9bbbe; }
.ctx-item--secret:hover { background: #45475a; color: #fff; }
.ctx-item--danger { color: #f04747; }
.ctx-item--danger:hover { background: #f04747; color: #fff; }
.ctx-item--muted { color: #72767d; font-size: 12px; }
.ctx-item--muted:hover { background: rgba(255,255,255,.06); color: #b5bac1; }

/* Форма переименования внутри контекстного меню */
.ctx-rename-wrap {
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ctx-rename-input {
    width: 100%;
    background: #1e1f22;
    border: 1px solid #3f4147;
    border-radius: 4px;
    color: #dcddde;
    font-size: 13px;
    padding: 5px 8px;
    outline: none;
    box-sizing: border-box;
}
.ctx-rename-input:focus { border-color: #5865f2; }
.ctx-rename-btns {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}
.ctx-rename-ok {
    padding: 3px 10px;
    background: #5865f2;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
}
.ctx-rename-ok:disabled { opacity: .5; cursor: default; }
.ctx-rename-cancel {
    padding: 3px 8px;
    background: none;
    border: 1px solid #3f4147;
    border-radius: 4px;
    color: #72767d;
    font-size: 12px;
    cursor: pointer;
}
.ctx-rename-cancel:hover { color: #ed4245; border-color: #ed4245; }

/* ─── Secret Chat Panel ─────────────────────────────────────── */
.secret-chat-panel {
    flex: 1; display: flex; flex-direction: column;
    height: 100%; overflow: hidden;
    background: #36393f;
}
.secret-chat-header {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px;
    background: #2f3136;
    border-bottom: 1px solid #202225;
    font-size: 14px;
    color: #dcddde;
}
.secret-chat-lock { font-size: 18px; }
.secret-chat-hint {
    font-size: 11px; color: #72767d;
}

/* ─── Secret chat header menu ─────────────────────────────── */
.sc-header-menu-wrap {
    margin-left: auto;
    position: relative;
    flex-shrink: 0;
}
.sc-header-menu-btn {
    background: none;
    border: none;
    color: #72767d;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color .15s, background .15s;
}
.sc-header-menu-btn:hover { color: #dcddde; background: rgba(255,255,255,.06); }
.sc-header-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 499;
}
.sc-header-dropdown {
    position: absolute;
    right: 0; top: calc(100% + 6px);
    z-index: 500;
    background: #18191c;
    border: 1px solid #040405;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.sc-header-dd-item {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #dcddde;
    font-size: 13px;
    text-align: left;
    padding: 8px 14px;
    cursor: pointer;
    transition: background .1s, color .1s;
}
.sc-header-dd-item:hover { background: #5865f2; color: #fff; }
.sc-header-dd-item--danger { color: #ed4245; }
.sc-header-dd-item--danger:hover { background: #ed4245; color: #fff; }
.sc-header-dd-sep { height: 1px; background: #3f4147; margin: 4px 0; }
.secret-chat-init {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 16px; color: #72767d; font-size: 14px;
}
.secret-chat-messages {
    flex: 1; overflow-y: auto;
    padding: 16px;
    display: flex; flex-direction: column; gap: 8px;
}
.sc-msg {
    max-width: 70%;
    display: flex; flex-direction: column;
    gap: 2px;
}
.sc-msg--mine  { align-self: flex-end;  align-items: flex-end; }
.sc-msg--theirs { align-self: flex-start; align-items: flex-start; }
.sc-msg-text {
    background: #40444b;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 14px; color: #dcddde;
    word-break: break-word;
}
.sc-msg--mine .sc-msg-text { background: #5865f2; }
.sc-msg-time { font-size: 10px; color: #72767d; padding: 0 4px; }
.secret-chat-input {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 12px 16px;
    background: #2f3136;
    border-top: 1px solid #202225;
}
.secret-chat-input textarea {
    flex: 1; resize: none;
    background: #40444b; border: none; border-radius: 8px;
    padding: 10px 12px;
    color: #dcddde; font-size: 14px;
    outline: none; max-height: 120px; overflow-y: auto;
}
.btn-send {
    background: #5865f2; border: none; border-radius: 50%;
    width: 36px; height: 36px;
    color: #fff; font-size: 16px;
    cursor: pointer; transition: background .15s;
    display: flex; align-items: center; justify-content: center;
}
.btn-send:hover:not(:disabled) { background: #4752c4; }
.btn-send:disabled { opacity: .4; cursor: default; }

/* ─── Read-only channel banner ──────────────────────────────── */
.pm-readonly-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #2f3136;
    border-top: 1px solid #202225;
    color: #72767d;
    font-size: 13px;
    user-select: none;
}

/* ─── @mention badges ───────────────────────────────────────── */
.pm-mention {
    display: inline-block;
    background: rgba(88,101,242,.25);
    color: #c9cdfb;
    border-radius: 4px;
    padding: 0 4px;
    font-weight: 500;
    cursor: default;
    text-decoration: none;
}
a.pm-mention:hover { text-decoration: underline; cursor: pointer; }
.pm-mention--me {
    background: rgba(250,166,26,.25);
    color: #faa61a;
}
.pm-mention--all {
    background: rgba(237,66,69,.25);
    color: #f87171;
    font-weight: 700;
}

/* ─── «Вас упомянули N раз» — плашка под заголовком чата ──── */
.pm-mentions-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 14px;
    border: 0;
    border-top: 1px solid rgba(255,255,255,.04);
    background: rgba(250,166,26,.12);
    color: #faa61a;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s;
}
.pm-mentions-bar:hover { background: rgba(250,166,26,.18); }
.pm-mentions-bar-arrow { margin-left: auto; opacity: .8; }
.pm-mentions-bar-close {
    margin-left: 4px;
    background: transparent;
    border: 0;
    color: inherit;
    opacity: .65;
    font-size: 14px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
}
.pm-mentions-bar-close:hover { opacity: 1; background: rgba(0,0,0,.18); }


/* ─── Channel icon badges (lock / readonly) ─────────────────── */
.srv-ch-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 3px;
    color: #72767d;
    flex-shrink: 0;
    opacity: .85;
}

/* ─── Friend blocked badge ───────────────────────────────────── */
.pm-blocked-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 5px;
    font-size: 10px;
    font-weight: 600;
    color: #ed4245;
    background: rgba(237,66,69,.15);
    border-radius: 3px;
    padding: 1px 4px;
    vertical-align: middle;
}

/* ─── Global checkbox style ──────────────────────────────────── */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px; height: 16px;
    min-width: 16px;
    border: 2px solid #4f545c;
    border-radius: 3px;
    background: #2b2d31;
    cursor: pointer;
    position: relative;
    transition: background .12s, border-color .12s;
    vertical-align: middle;
    flex-shrink: 0;
}
input[type="checkbox"]:checked {
    background: #5865f2;
    border-color: #5865f2;
}
input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px; top: 0px;
    width: 5px; height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}
input[type="checkbox"]:hover:not(:checked) {
    border-color: #8e9297;
}
input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(88,101,242,.4);
}

/* ── Character counter ───────────────────────────────────────── */
.pm-char-counter {
    align-self: center;
    font-size: 11px;
    color: #72767d;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color .15s;
}
.pm-char-counter--warn { color: #faa61a; }
.pm-char-counter--over { color: #ed4245; font-weight: 600; }

/* ── Limit banner (Free / Ads) ───────────────────────────────── */
.pm-limit-banner {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    margin: 0 8px 4px;
    border-radius: 6px;
    background: rgba(237, 66, 69, .15);
    border: 1px solid rgba(237, 66, 69, .35);
    color: #ed4245;
    font-size: 13px;
    font-weight: 500;
    animation: pm-banner-in .15s ease;
}
@keyframes pm-banner-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Emoji picker в инпуте ─────────────────────────────────────────────── */
.pm-input-emoji-wrap {
    position: relative;
    display: flex;
    align-items: flex-end;
    flex-shrink: 0;
}

.pm-input-emoji-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #b9bbbe;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color .15s, background .15s;
}

    .pm-input-emoji-btn:hover {
        color: #dcddde;
        background: rgba(255,255,255,.06);
    }

    .pm-input-emoji-btn:disabled {
        opacity: .4;
        cursor: default;
    }

    .pm-input-emoji-btn.pm-input-emoji-btn--active {
        color: #f2f3f5;
        background: rgba(255,255,255,.10);
    }

.pm-input-emoji-picker {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    background: #2f3136;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 200;
    box-shadow: 0 6px 24px rgba(0,0,0,0.55);
    /* На узких экранах не выходим за viewport. */
    width: min(340px, calc(100vw - 16px));
}

/* На мобильных все pickers пинуются к viewport.
   ВАЖНО: повтор правила здесь, потому что CSS читается сверху вниз — без этого
   блока десктопное правило .pm-input-emoji-picker (выше) перетирает mobile-блок
   из ~строки 4562, и picker уезжает за правый край экрана. */
@media (max-width: 767px) {
    .pm-emoji-picker,
    .pm-input-emoji-picker,
    .pm-sticker-picker {
        position: fixed;
        left: 8px;
        right: 8px;
        bottom: calc(var(--kb-offset, 0px) + 60px + env(safe-area-inset-bottom));
        top: auto;
        width: auto;
        max-width: none;
        max-height: calc(100dvh - var(--kb-offset, 0px) - 140px);
    }

    .pm-emoji-grid {
        grid-template-columns: repeat(7, 1fr);
        max-height: none;
    }

    .pm-sticker-inline-btn img,
    .pm-sticker-btn img {
        width: 100%;
        height: auto;
        max-width: 32px;
    }
}

/* ── Mic button ─────────────────────────────────────────────────────────── */
.pm-mic-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #b9bbbe;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color .15s, background .15s;
}
.pm-mic-btn:hover { color: #dcddde; background: rgba(255,255,255,.06); }
.pm-mic-btn:disabled { opacity: .4; cursor: default; }

/* ── Voice recording bar ─────────────────────────────────────────────────── */
.voice-rec-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 0 8px 4px;
    border-radius: 8px;
    background: rgba(88, 101, 242, .12);
    border: 1px solid rgba(88, 101, 242, .3);
    animation: pm-banner-in .15s ease;
}
.voice-rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ed4245;
    flex-shrink: 0;
    animation: voice-dot-pulse 1s ease-in-out infinite;
}
@keyframes voice-dot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .5; transform: scale(.75); }
}
.voice-eq-canvas {
    flex: 1;
    max-width: 140px;
    height: 28px;
    border-radius: 4px;
}
.voice-rec-timer {
    font-size: 13px;
    font-weight: 600;
    color: #5865f2;
    min-width: 36px;
    text-align: right;
}
.voice-rec-send-btn,
.voice-rec-cancel-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.voice-rec-send-btn   { background: #5865f2; color: #fff; }
.voice-rec-send-btn:hover { background: #4752c4; }
.voice-rec-cancel-btn { background: rgba(237,66,69,.15); color: #ed4245; }
.voice-rec-cancel-btn:hover { background: rgba(237,66,69,.25); }

/* ── Voice preview bar ────────────────────────────────────────────────────── */
.voice-preview-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 0 8px 4px;
    border-radius: 8px;
    background: rgba(88, 101, 242, .10);
    border: 1px solid rgba(88, 101, 242, .25);
    animation: pm-banner-in .15s ease;
}
.voice-preview-play {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #5865f2;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
}
.voice-preview-play:hover { background: #4752c4; }
.voice-preview-label {
    flex: 1;
    font-size: 13px;
    color: #dcddde;
}
.voice-preview-send {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #57f287;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
}
.voice-preview-send:hover { background: #3ba55d; }
.voice-preview-cancel {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(237,66,69,.15);
    color: #ed4245;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
}
.voice-preview-cancel:hover { background: rgba(237,66,69,.28); }

/* ── Received voice message player ──────────────────────────────────────── */
.voice-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid rgba(255,255,255,.08);
    min-width: 220px;
    max-width: 320px;
    margin: 2px 0;
}
.voice-play-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #5865f2;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
}
.voice-play-btn:hover { background: #4752c4; }
.voice-progress-wrap {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,.15);
    cursor: pointer;
    overflow: visible;
    position: relative;
    transition: height .15s;
}
.voice-progress-wrap:hover,
.voice-progress-wrap:active {
    height: 10px;
}
.voice-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: #5865f2;
    width: 0%;
    transition: width .08s linear;
    pointer-events: none;
}
.voice-time {
    flex-shrink: 0;
    font-size: 11px;
    color: #72767d;
    white-space: nowrap;
}


/* ── Member context menu ── */
.srv-member-ctx {
    position: fixed;
    z-index: 9999;
    background: #111214;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    padding: 6px;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.srv-member-ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: #dbdee1;
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 5px;
    cursor: pointer;
    text-align: left;
    transition: background .12s, color .12s;
}
.srv-member-ctx-item:hover { background: #5865f2; color: #fff; }
.srv-member-ctx-item--danger { color: #f04747; }
.srv-member-ctx-item--danger:hover { background: #f04747; color: #fff; }

/* ── Message context menu ── */
.pm-msg-ctx {
    position: fixed;
    z-index: 9999;
    background: #111214;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    padding: 6px;
    min-width: 210px;
    box-shadow: 0 8px 24px rgba(0,0,0,.6);
    user-select: none;
}
.pm-msg-ctx-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: #dbdee1;
    font-size: 13px;
    padding: 8px 10px;
    border-radius: 5px;
    cursor: pointer;
    text-align: left;
    transition: background .12s, color .12s;
}
.pm-msg-ctx-item:hover { background: #5865f2; color: #fff; }
.pm-msg-ctx-item--danger { color: #f04747; }
.pm-msg-ctx-item--danger:hover { background: #f04747; color: #fff; }
.pm-msg-ctx-sep {
    height: 1px;
    background: rgba(255,255,255,.08);
    margin: 4px 2px;
}

/* ── Bot label in PM sidebar ── */
.pm-bot-label {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .5px;
    background: #f0a500;
    color: #111;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 5px;
    vertical-align: middle;
}

/* ── Bot info popup ── */
.pm-bot-info-backdrop {
    position: fixed; inset: 0; z-index: 9998; background: rgba(0,0,0,.4);
}
.pm-bot-info-popup {
    position: fixed; z-index: 9999;
    top: 50%; left: 50%; transform: translate(-50%,-50%);
    background: #1e1f26; border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px; padding: 28px 24px 20px;
    min-width: 260px; max-width: 340px;
    box-shadow: 0 12px 40px rgba(0,0,0,.7);
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    text-align: center;
}
.pm-bot-info-close {
    position: absolute; top: 10px; right: 12px;
    background: none; border: none; color: #72767d;
    cursor: pointer; font-size: 16px;
}
.pm-bot-info-close:hover { color: #fff; }
.pm-bot-info-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    background: #f0a500; display: flex; align-items: center; justify-content: center;
    color: #fff; overflow: hidden; flex-shrink: 0;
}
.pm-bot-info-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pm-bot-info-name { font-size: 18px; font-weight: 700; color: #f2f3f5; }
.pm-bot-info-about { font-size: 13px; color: #b9bbbe; line-height: 1.5; }
.pm-bot-info-about--empty { font-style: italic; color: #72767d; }
.pm-bot-info-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.pm-bot-info-btn {
    padding: 6px 16px; border-radius: 6px; border: none;
    background: #5865f2; color: #fff; font-size: 13px; cursor: pointer;
    transition: background .15s;
}
.pm-bot-info-btn:hover { background: #4752c4; }
.pm-bot-info-btn--secondary { background: rgba(255,255,255,.1); }
.pm-bot-info-btn--secondary:hover { background: rgba(255,255,255,.18); }

/* ── Pinned drag handle ── */
.pm-pin-drag-handle {
    font-size: 14px; color: #4e5058; cursor: grab; flex-shrink: 0;
    padding: 0 2px; margin-left: auto;
    user-select: none; opacity: 0;
    transition: opacity .15s;
}
.pm-pinned-draggable:hover .pm-pin-drag-handle { opacity: 1; }
.pm-pinned-draggable { cursor: default; }
.pm-pinned-dragging { opacity: 0.4; }

/* ── Inline-кнопки бота (Telegram-style) ── */
.pm-inline-kb {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
    max-width: 360px;
}
.pm-inline-kb-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.pm-inline-kb-btn {
    flex: 1;
    min-width: 80px;
    background: rgba(88, 101, 242, .15);
    border: 1px solid rgba(88, 101, 242, .45);
    color: #adb5ff;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pm-inline-kb-btn:hover {
    background: rgba(88, 101, 242, .32);
    border-color: #5865f2;
    color: #fff;
}
.pm-inline-kb-btn:active {
    background: rgba(88, 101, 242, .5);
    transform: scale(.97);
}

/* ── AI think block ─────────────────────────────────────────── */
.ai-think-block {
    margin: 4px 0 6px;
    border: 1px solid rgba(114, 137, 218, .25);
    border-radius: 8px;
    background: rgba(114, 137, 218, .06);
    overflow: hidden;
}
.ai-think-summary {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    color: #7289da;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background .15s;
}
.ai-think-summary::-webkit-details-marker { display: none; }
.ai-think-summary::before {
    content: '▸';
    font-size: 10px;
    transition: transform .2s;
}
.ai-think-block[open] .ai-think-summary::before {
    transform: rotate(90deg);
}
.ai-think-summary:hover { background: rgba(114, 137, 218, .1); }
.ai-think-body {
    padding: 8px 12px;
    font-size: 12px;
    color: #8e9297;
    line-height: 1.55;
    border-top: 1px solid rgba(114, 137, 218, .15);
    font-style: italic;
}

/* ── Жалоба на сообщение (модалка) ──────────────────────────────────────── */
.pm-report-preview {
    background: rgba(255, 255, 255, .04);
    border-left: 3px solid #ed4245;
    border-radius: 6px;
    padding: 8px 10px;
    max-height: 120px;
    overflow-y: auto;
}

.pm-report-preview-author {
    font-weight: 600;
    font-size: 12px;
    color: #ed4245;
    margin-bottom: 2px;
}

.pm-report-preview-text {
    font-size: 13px;
    color: #b5bac1;
    white-space: pre-wrap;
    word-break: break-word;
}

.pm-report-label {
    color: #b5bac1;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 4px;
}

.pm-report-select,
.pm-report-textarea {
    background: #1e1f22;
    color: #f2f3f5;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}

    .pm-report-select:focus,
    .pm-report-textarea:focus {
        border-color: #5865f2;
    }

.pm-report-textarea {
    min-height: 80px;
    resize: vertical;
}

.pm-report-error {
    color: #ed4245;
    font-size: 13px;
    margin-top: 4px;
}

.pm-report-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* ══ Mobile Attach Sheet ══ */
.mas-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1100;
    animation: mas-fade-in .18s ease;
}

@keyframes mas-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.mas-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #2b2d31;
    border-radius: 16px 16px 0 0;
    padding: 8px 0 max(env(safe-area-inset-bottom, 12px), 12px);
    z-index: 1101;
    animation: mas-slide-up .22s cubic-bezier(.25, .46, .45, .94);
}

@keyframes mas-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.mas-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,.25);
    margin: 0 auto 16px;
}

.mas-tabs {
    display: flex;
    justify-content: space-around;
    padding: 0 8px;
    gap: 4px;
}

.mas-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 8px 6px;
    background: none;
    border: none;
    cursor: pointer;
    color: #b5bac1;
    border-radius: 12px;
    transition: background .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}

.mas-tab:active {
    background: rgba(255,255,255,.06);
    color: #fff;
}

.mas-tab-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .12s;
}

.mas-tab:active .mas-tab-icon {
    transform: scale(.92);
}

.mas-tab-icon--gallery { background: #5865f2; }
.mas-tab-icon--file    { background: #3ba55d; }
.mas-tab-icon--poll    { background: #eb459e; }

/* ── Media picker sheet (Telegram-style: live camera tile + open gallery) ── */
.mps-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 1100;
    animation: mas-fade-in .18s ease;
}

.mps-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #2b2d31;
    border-radius: 16px 16px 0 0;
    padding: 8px 12px max(env(safe-area-inset-bottom, 12px), 12px);
    z-index: 1101;
    animation: mas-slide-up .22s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 -10px 40px rgba(0,0,0,.5);
}

.mps-handle {
    width: 36px;
    height: 4px;
    background: #4e5058;
    border-radius: 2px;
    margin: 0 auto 12px;
}

.mps-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 12px;
}

.mps-tile {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: #1e1f22;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #dbdee1;
}

.mps-tile-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
}

.mps-tile-video--idle { opacity: 0; }

.mps-tile-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #b9bbbe;
    background: linear-gradient(180deg, #2b2d31 0%, #1e1f22 100%);
}

.mps-tile-hint {
    font-size: 13px;
    font-weight: 500;
}

.mps-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #4e5058;
    border-top-color: #5865f2;
    border-radius: 50%;
    animation: chat-spin 0.7s linear infinite;
}

/* Кнопка-затвор поверх живого превью (по тапу на тайл = снимок) */
.mps-shutter {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 56px;
    height: 56px;
    pointer-events: none;
}

.mps-shutter-ring,
.mps-shutter-dot {
    position: absolute;
    border-radius: 50%;
}

.mps-shutter-ring {
    inset: 0;
    border: 3px solid rgba(255,255,255,.95);
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.mps-shutter-dot {
    inset: 8px;
    background: rgba(255,255,255,.95);
}

.mps-tile:active .mps-shutter-dot { background: #f04747; }

.mps-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mps-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    border-radius: 12px;
    border: none;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.mps-action--primary {
    background: rgba(88, 101, 242, .15);
    color: #c9cdfb;
}
.mps-action--primary:active { background: rgba(88, 101, 242, .28); }

.mps-action--cancel {
    background: transparent;
    color: #b9bbbe;
}
.mps-action--cancel:active { background: rgba(255,255,255,.06); color: #fff; }

@keyframes mas-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.mas-tab-icon svg { fill: #fff; }

.mas-tab-label {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .01em;
}
