html.chat-shell-root {
    height: 100%;
    /* Масштаб интерфейса чата ~125% без браузерного zoom: rem и переведённые из px величины растут пропорционально */
    font-size: 125%;
}

body.chat-shell-body {
    min-height: 100vh;
    height: 100%;
    touch-action: manipulation;
}

.chat-hidden {
    display: none !important;
}

/* /chat — Telegram-подобная вёрстка, палитра сайта (золото / тёмный фон) */

body.chat-shell-body .chat-shell {
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.chat-shell-body #main.chat-main-outer {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-mini-footer {
    flex-shrink: 0;
    text-align: center;
    padding: 0.375rem 0.75rem 0.625rem;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: rgba(235, 230, 220, 0.42);
    background: #0e0c0a;
    border-top: 1px solid rgba(212, 175, 55, 0.12);
}

.chat-page {
    --chat-accent: #d4af37;
    --chat-accent-soft: rgba(212, 175, 55, 0.35);
    --chat-bg-deep: #12100e;
    --chat-bg-panel: #1a1814;
    --chat-bg-hover: rgba(212, 175, 55, 0.08);
    --chat-bg-active: rgba(212, 175, 55, 0.18);
    --chat-border: rgba(212, 175, 55, 0.22);
    --chat-text: #ebe6dc;
    --chat-muted: #9a9288;
    --chat-in-msg: #252320;
    --chat-out-msg: linear-gradient(145deg, rgba(90, 72, 28, 0.95) 0%, rgba(46, 38, 18, 0.98) 100%);
    --chat-pattern: rgba(212, 175, 55, 0.04);

    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
    background: var(--chat-bg-deep);
    color: var(--chat-text);
    margin: 0;
    padding: 0;
    width: 100%;
}

/* Прокрутка колёсиком/тач — без видимой полосы скролла */
.chat-page .chat-folder-rail,
.chat-page .chat-folders-screen-body,
.chat-page .chat-thread-list,
.chat-page .chat-menu-rows,
.chat-page .chat-lang-screen-body,
.chat-page .chat-balance-tooltip,
.chat-page .chat-group-add-list,
.chat-page .chat-thread-info-scroll,
.chat-page .chat-messages,
.chat-page .chat-forward-thread-list,
.chat-page .chat-emoji-popover,
.chat-page .chat-emoji-panel,
.chat-page .chat-gif-grid,
.chat-page .chat-create-group-body,
.chat-page .chat-private-body,
.chat-page .chat-private-results,
.chat-page .chat-devices-body,
.chat-page .chat-compose-field textarea {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-page .chat-folder-rail::-webkit-scrollbar,
.chat-page .chat-folders-screen-body::-webkit-scrollbar,
.chat-page .chat-thread-list::-webkit-scrollbar,
.chat-page .chat-menu-rows::-webkit-scrollbar,
.chat-page .chat-lang-screen-body::-webkit-scrollbar,
.chat-page .chat-balance-tooltip::-webkit-scrollbar,
.chat-page .chat-group-add-list::-webkit-scrollbar,
.chat-page .chat-thread-info-scroll::-webkit-scrollbar,
.chat-page .chat-messages::-webkit-scrollbar,
.chat-page .chat-forward-thread-list::-webkit-scrollbar,
.chat-page .chat-emoji-popover::-webkit-scrollbar,
.chat-page .chat-emoji-panel::-webkit-scrollbar,
.chat-page .chat-gif-grid::-webkit-scrollbar,
.chat-page .chat-create-group-body::-webkit-scrollbar,
.chat-page .chat-private-body::-webkit-scrollbar,
.chat-page .chat-private-results::-webkit-scrollbar,
.chat-page .chat-devices-body::-webkit-scrollbar,
.chat-page .chat-compose-field textarea::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: none;
    margin: 0;
}

.chat-sidebar {
    flex: 0 0 min(26vw, 23.75rem);
    min-width: 16.25rem;
    max-width: 23.75rem;
    border-right: 1px solid var(--chat-border);
    background: var(--chat-bg-panel);
    display: flex;
    flex-direction: row;
    align-items: stretch;
    min-height: 0;
}

.chat-layout--folder-left .chat-sidebar {
    flex: 0 0 min(28vw, 28.25rem);
    max-width: min(28vw, 28.25rem);
    min-width: min(20.75rem, 100%);
}

.chat-sidebar-panels {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-sidebar-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-sidebar-panel.chat-hidden {
    display: none;
}

#chat-panel-list {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Полоска папок слева: иконка + подпись; колонка и шрифт подписей +~25% к базовым rem */
.chat-folder-rail {
    flex: 0 0 5.625rem;
    width: 5.625rem;
    min-width: 5.625rem;
    max-width: 5.625rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3125rem;
    padding: 0.78125rem 0 0.9375rem;
    border-right: 1px solid rgba(212, 175, 55, 0.14);
    background: #12100e;
    overflow-x: hidden;
    overflow-y: auto;
}

.chat-folder-rail.chat-hidden {
    display: none !important;
}

.chat-folder-rail-btn {
    width: 4.375rem;
    flex-shrink: 0;
    margin: 0 auto;
    min-height: 0;
    padding: 0.625rem 0.3125rem 0.46875rem;
    border-radius: 1.09375rem;
    border: none;
    background: transparent;
    color: var(--chat-muted);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.390625rem;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}

.chat-folder-rail-btn:hover {
    background: rgba(212, 175, 55, 0.06);
    color: var(--chat-text);
}

.chat-folder-rail-btn.is-active {
    background: rgba(212, 175, 55, 0.14);
    color: var(--chat-accent);
}

.chat-folder-rail-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.4375rem;
    height: 3.4375rem;
    border-radius: 0.9375rem;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(212, 175, 55, 0.12);
    flex-shrink: 0;
}

.chat-folder-rail-btn.is-active .chat-folder-rail-icon-wrap {
    border-color: rgba(212, 175, 55, 0.45);
    background: rgba(212, 175, 55, 0.1);
    box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.2);
}

.chat-folder-rail-svg {
    width: 1.71875rem;
    height: 1.71875rem;
    display: block;
    color: currentColor;
}

.chat-folder-rail-emoji {
    font-size: 1.6875rem;
    line-height: 1;
    display: block;
}

.chat-folder-rail-letter {
    font-size: 1rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
}

.chat-folder-rail-label {
    display: block;
    width: 100%;
    max-width: 5rem;
    margin: 0 auto;
    font-size: 0.725rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
    color: inherit;
    opacity: 0.92;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-folder-rail-btn--all .chat-folder-rail-label {
    font-size: 0.675rem;
}

.chat-folders.chat-hidden-tabs {
    display: none !important;
}

.chat-folders-screen-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem 1rem 1.75rem;
}

.chat-folders-screen-desc {
    margin: 0 0 0.875rem;
    font-size: 0.84rem;
    color: var(--chat-muted);
    line-height: 1.45;
}

.chat-folders-screen-new {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 1.375rem;
    border: none;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.35) 0%, rgba(140, 112, 40, 0.45) 100%);
    color: var(--chat-text);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
}

.chat-folders-screen-new:hover {
    filter: brightness(1.08);
}

.chat-folders-screen-new:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: none;
}

.chat-folders-screen-section {
    margin: 1.125rem 0 0.625rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--chat-accent);
}

.chat-folders-settings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-folder-settings-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.625rem 0.75rem 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.35);
    transition: border-color 0.15s, background 0.15s;
}

.chat-folder-settings-row--ghost {
    opacity: 0.45;
}

.chat-folder-settings-row--drag-over {
    border-color: var(--chat-accent);
    background: var(--chat-bg-hover);
}

.chat-folder-settings-drag-spacer {
    width: 2rem;
    flex-shrink: 0;
}

.chat-folder-settings-drag {
    flex-shrink: 0;
    width: 2rem;
    height: 2.25rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--chat-muted);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.12s;
}

.chat-folder-settings-row:hover .chat-folder-settings-drag {
    opacity: 1;
}

.chat-folder-settings-drag:active {
    cursor: grabbing;
}

.chat-folder-settings-drag-icon {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 1rem;
}

.chat-folder-settings-drag-icon span {
    display: block;
    height: 0.125rem;
    border-radius: 1px;
    background: currentColor;
    opacity: 0.85;
}

.chat-folder-settings-body {
    flex: 1;
    min-width: 0;
}

.chat-folder-settings-title {
    font-size: 0.94rem;
    font-weight: 700;
    color: var(--chat-text);
    margin: 0 0 0.25rem;
}

.chat-folder-settings-meta {
    font-size: 0.78rem;
    color: var(--chat-muted);
    margin: 0;
    line-height: 1.35;
}

.chat-folder-settings-drag--mobile-hidden {
    display: none !important;
}

.chat-folder-settings-actions {
    flex-shrink: 0;
    width: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

@media (min-width: 56.3125rem) {
    .chat-folder-settings-actions:empty {
        width: 0;
        min-width: 0;
        overflow: hidden;
    }
}

.chat-folder-settings-more-btn {
    color: var(--chat-muted);
}

.chat-folder-row-menu {
    position: fixed;
    z-index: 400;
    min-width: 11.5rem;
    padding: 0.35rem 0;
    border-radius: 0.75rem;
    background: #1e1c18;
    border: 1px solid var(--chat-border);
    box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.55);
}

.chat-folder-row-menu-item {
    display: block;
    width: 100%;
    padding: 0.55rem 1rem;
    border: none;
    background: transparent;
    color: var(--chat-text);
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
}

.chat-folder-row-menu-item:hover {
    background: var(--chat-bg-hover);
}

.chat-folder-row-menu-item--danger {
    color: #f09090;
}

.chat-folder-row-menu-item--danger:hover {
    background: rgba(248, 113, 113, 0.12);
}

.chat-menu-header--folder-edit h2 {
    flex: 1;
    min-width: 0;
    font-size: 0.98rem;
}

.chat-folder-edit-more-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-folder-edit-screen-body {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.75rem 1rem 1rem;
    -webkit-overflow-scrolling: touch;
}

.chat-folder-edit-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.chat-folder-edit-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--chat-muted);
}

.chat-folder-edit-input {
    width: 100%;
    box-sizing: border-box;
    border-radius: 0.65rem;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.35);
    color: var(--chat-text);
    font-size: 1rem;
    padding: 0.65rem 0.75rem;
}

.chat-folder-edit-thread-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chat-folder-edit-thread-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.45rem;
    border-radius: 0.7rem;
    border: 1px solid rgba(212, 175, 55, 0.16);
    background: rgba(0, 0, 0, 0.28);
    cursor: pointer;
    margin: 0;
    min-height: 3rem;
}

.chat-folder-edit-thread-mid {
    flex: 1;
    min-width: 0;
}

.chat-folder-edit-thread-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--chat-text);
    line-height: 1.2;
}

.chat-folder-edit-thread-snippet {
    font-size: 0.74rem;
    color: var(--chat-muted);
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-folder-edit-thread-row .chat-folder-edit-thread-cb {
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
    accent-color: var(--chat-accent);
}

.chat-folder-edit-empty {
    margin: 0.5rem 0 0;
    font-size: 0.82rem;
    color: var(--chat-muted);
}

.chat-folder-edit-footer {
    flex-shrink: 0;
    padding: 0.65rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--chat-border);
    background: rgba(10, 9, 8, 0.95);
}

.chat-folder-edit-footer .chat-modal-btn--primary {
    width: 100%;
    justify-content: center;
}

#chat-panel-folder-edit {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-folder-placement {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.chat-folder-placement-opt {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--chat-text);
}

.chat-folder-placement-opt input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.chat-folder-placement-ui {
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 50%;
    border: 0.125rem solid rgba(212, 175, 55, 0.45);
    flex-shrink: 0;
}

.chat-folder-placement-opt input:checked + .chat-folder-placement-ui {
    border-color: var(--chat-accent);
    box-shadow: inset 0 0 0 0.25rem var(--chat-accent);
}

.chat-sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--chat-border);
    flex-shrink: 0;
    position: relative;
    z-index: 5;
}

.chat-icon-btn {
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 0.625rem;
    background: rgba(0, 0, 0, 0.35);
    color: var(--chat-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    position: relative;
    z-index: 1;
    /* Снимает 300ms задержку браузера на тапе и убирает «двойной клик» */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* :hover активируется только на устройствах с настоящим указателем (мышью).
   На тач-устройствах :hover «залипает» до второго тапа — это и приводит к
   ощущению, что первая «нажимка» только выбирает кнопку. */
@media (hover: hover) {
    .chat-icon-btn:hover {
        background: var(--chat-bg-hover);
        color: #f4d03f;
    }
}

.chat-icon-btn:active {
    background: var(--chat-bg-hover);
    color: #f4d03f;
}

.chat-icon-btn svg {
    width: 1.375rem;
    height: 1.375rem;
}

.chat-search {
    flex: 1;
    min-width: 0;
    height: 2.5rem;
    border-radius: 0.625rem;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.4);
    color: var(--chat-text);
    padding: 0 0.875rem 0 2.375rem;
    font-size: 0.92rem;
    outline: none;
}

.chat-search:focus {
    border-color: var(--chat-accent-soft);
    box-shadow: 0 0 0 1px var(--chat-accent-soft);
}

.chat-search-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.chat-search-wrap .chat-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.125rem;
    height: 1.125rem;
    opacity: 0.45;
    pointer-events: none;
}

.chat-folders {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.625rem;
    overflow-x: visible;
    overflow-y: visible;
    flex-shrink: 0;
    border-bottom: 1px solid var(--chat-border);
}

.chat-folder-tab {
    flex-shrink: 0;
    padding: 0.375rem 0.75rem;
    border-radius: 62.4375rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--chat-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.chat-folder-tab--add {
    min-width: 2.25rem;
    padding-left: 0.625rem;
    padding-right: 0.625rem;
    color: var(--chat-accent);
    border-color: var(--chat-border);
}

.chat-folder-tab--add:hover {
    background: var(--chat-bg-hover);
}

.chat-folder-tab:hover {
    color: var(--chat-text);
    background: var(--chat-bg-hover);
}

.chat-folder-tab.is-active {
    color: #1a1510;
    background: linear-gradient(135deg, #e8c96a 0%, #d4af37 100%);
    border-color: rgba(0, 0, 0, 0.2);
}

.chat-thread-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.chat-thread {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-thread--dm {
    align-items: center;
}

.chat-thread--channels {
    align-items: center;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.chat-thread--channels .chat-thread-top {
    margin-bottom: 0;
}

.chat-thread--channels .chat-thread-snippet {
    gap: 0.05rem;
}

.chat-thread--dm .chat-thread-top {
    margin-bottom: 0;
}

.chat-thread:hover {
    background: var(--chat-bg-hover);
}

.chat-thread.is-active {
    background: var(--chat-bg-active);
}

.chat-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    border: 0.125rem solid var(--chat-border);
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-avatar--guild {
    font-size: 1.1rem;
    background: linear-gradient(145deg, #3d3420, #1f1c16);
}

.chat-avatar--news {
    font-size: 1rem;
    background: linear-gradient(145deg, #4a3d18, #2a2310);
    border-color: rgba(212, 175, 55, 0.45);
}

.chat-avatar--group-initials {
    font-size: 0.95rem;
    font-weight: 800;
}

/* Общий чат «main» — без случайного цвета, в золотой гамме сайта */
.chat-avatar--main-public {
    font-size: 0.95rem;
    font-weight: 800;
    background: linear-gradient(145deg, rgba(74, 61, 24, 0.95), rgba(42, 35, 16, 0.98));
    border-color: rgba(212, 175, 55, 0.42);
    color: #f5f0e6;
}

.chat-avatar--sm.chat-avatar--group-initials {
    font-size: 0.72rem;
}

.chat-avatar--sm.chat-avatar--main-public {
    font-size: 0.72rem;
}

.chat-avatar--sm {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.62rem;
}

.chat-avatar--header {
    width: 2.75rem;
    height: 2.75rem;
}

.chat-thread-pin {
    display: inline-block;
    margin-right: 0.25rem;
    opacity: 0.85;
    font-size: 0.72rem;
}

.chat-thread-empty {
    padding: 1.25rem 0.875rem;
    color: var(--chat-muted);
    font-size: 0.82rem;
    line-height: 1.45;
    text-align: center;
}

.chat-thread-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.1rem;
}

.chat-thread-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: start;
    margin-bottom: 0;
}

.chat-thread-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 0.2rem;
    flex-shrink: 0;
    line-height: 1.25;
    min-width: 2.75rem;
    text-align: right;
}

.chat-thread-title {
    font-weight: 700;
    font-size: 0.95rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.38;
    padding-bottom: 0.06em;
}

.chat-thread-time {
    font-size: 0.75rem;
    color: var(--chat-muted);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.chat-thread-unread {
    min-width: 1.25rem;
    min-height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 62.4375rem;
    font-size: 0.68rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--chat-accent);
    color: #fff;
    box-sizing: border-box;
}

.chat-thread-unread--muted {
    background: #5a5854;
    color: rgba(255, 255, 255, 0.94);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.chat-thread-unread--placeholder {
    visibility: hidden;
    pointer-events: none;
}

.chat-thread-snippet {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 0;
    font-size: 0.8125rem;
    color: var(--chat-muted);
    line-height: 1.38;
    min-height: 0;
    overflow: hidden;
    padding-bottom: 0.04em;
}

.chat-thread-snippet--plain {
    white-space: nowrap;
    text-overflow: ellipsis;
}

.chat-thread-snippet-prefix {
    flex-shrink: 0;
    max-width: 52%;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-thread-snippet-prefix--colored {
    font-weight: 700;
}

.chat-thread-snippet-msg {
    flex: 1;
    min-width: 0;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-online-dot {
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #3ecf8e;
    margin-left: 0.375rem;
    vertical-align: middle;
}

/* Settings panel (left) */
.chat-menu-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--chat-border);
}

.chat-menu-header h2 {
    flex: 1;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.chat-menu-profile {
    text-align: center;
    padding: 1rem 0.875rem 0.75rem;
    border-bottom: 1px solid var(--chat-border);
}

.chat-menu-avatar-lg {
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    margin: 0 auto 0.625rem;
    border: 0.1875rem solid var(--chat-accent);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.5);
}

.chat-menu-avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-menu-nick {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0 0 0.375rem;
}

.chat-menu-status {
    font-size: 0.82rem;
    color: var(--chat-muted);
    margin: 0;
}

.chat-menu-rows {
    padding: 0.5rem 0;
    flex: 1;
    overflow-y: auto;
}

.chat-menu-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--chat-text);
    font-size: 0.92rem;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}

.chat-menu-row:hover {
    background: var(--chat-bg-hover);
}

.chat-menu-row .ni-placeholder {
    width: 1.5rem;
    text-align: center;
    opacity: 0.85;
}

.chat-menu-row-label {
    flex: 1;
    text-align: left;
}

.chat-menu-row-chevron {
    margin-left: auto;
    opacity: 0.45;
    font-size: 1.1rem;
}

.chat-menu-meta {
    font-size: 0.8rem;
    color: var(--chat-muted);
    margin-left: auto;
}

.chat-lang-screen-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem 1rem 1.5rem;
}

.chat-lang-screen-hint {
    margin: 0 0 0.875rem;
    font-size: 0.82rem;
    color: var(--chat-muted);
    line-height: 1.4;
}

.chat-lang-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-lang-option {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    width: 100%;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--chat-border);
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.35);
    color: var(--chat-text);
    font-size: 0.92rem;
    text-align: left;
    cursor: pointer;
}

.chat-lang-option:hover {
    background: var(--chat-bg-hover);
}

.chat-lang-option-radio {
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 50%;
    border: 0.125rem solid rgba(212, 175, 55, 0.45);
    flex-shrink: 0;
    position: relative;
}

.chat-lang-option.is-active .chat-lang-option-radio {
    border-color: var(--chat-accent);
    box-shadow: inset 0 0 0 0.25rem var(--chat-accent);
}

.chat-lang-option.is-active {
    border-color: rgba(212, 175, 55, 0.35);
}

.chat-menu-foot {
    padding: 0.75rem 0.875rem;
    border-top: 1px solid var(--chat-border);
}

.chat-balance-pill {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 0.875rem;
    border-radius: 0.75rem;
    background: linear-gradient(145deg, rgba(212, 175, 55, 0.18) 0%, rgba(60, 52, 30, 0.6) 100%);
    border: 1px solid var(--chat-border);
    cursor: default;
    position: relative;
}

.chat-balance-pill strong {
    color: var(--chat-accent);
}

.chat-balance-tooltip {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 0.5rem);
    background: #1e1c18;
    border: 1px solid var(--chat-border);
    border-radius: 0.625rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.82rem;
    z-index: 50;
    box-shadow: 0 0.75rem 2.5rem rgba(0, 0, 0, 0.55);
    max-height: 13.75rem;
    overflow-y: auto;
}

.chat-balance-pill:hover .chat-balance-tooltip,
.chat-balance-pill:focus-within .chat-balance-tooltip {
    display: block;
}

.chat-balance-tooltip-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-balance-tooltip-row:last-child {
    border-bottom: none;
}

/* Main area */
.chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: #161411;
    background-image: radial-gradient(circle at 1px 1px, var(--chat-pattern) 1px, transparent 0);
    background-size: 1.5rem 1.5rem;
    min-height: 0;
}

.chat-main-column {
    flex: 1;
    display: flex;
    min-width: 0;
    min-height: 0;
    position: relative;
    z-index: 20;
}

.chat-main-header-hit {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
    padding: 0.125rem 0.35rem;
    margin-left: -0.35rem;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-align: left;
    border-radius: 0.5rem;
}

.chat-main-header-hit:hover {
    background: rgba(255, 255, 255, 0.05);
}

.chat-main-header-hit:focus-visible {
    outline: 2px solid var(--chat-accent);
    outline-offset: 2px;
}

.chat-main-header-hit:disabled {
    cursor: default;
}

.chat-main-header-hit:disabled:hover {
    background: transparent;
}

.chat-thread-info-panel {
    flex-shrink: 0;
    width: 0;
    overflow: hidden;
    transition: width 0.22s ease;
    background: var(--chat-bg-panel);
    border-left: 1px solid var(--chat-border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-thread-info-panel--open {
    width: min(22rem, 38vw);
}

.chat-thread-info-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    min-width: 0;
    position: relative;
}

.chat-thread-info-inner--group-fab .chat-thread-info-scroll {
    padding-bottom: 4.25rem;
}

.chat-thread-info-inner--edit-dirty .chat-thread-info-scroll {
    padding-bottom: 4.25rem;
}

.chat-group-edit-save-fab {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    z-index: 4;
    width: 3.35rem;
    height: 3.35rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8c96a 0%, #b8942a 100%);
    color: #1a1510;
    box-shadow: 0 0.35rem 1.25rem rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease, filter 0.15s ease;
}

.chat-group-edit-save-fab:hover:not(:disabled) {
    transform: scale(1.05);
    filter: brightness(1.06);
}

.chat-group-edit-save-fab:active:not(:disabled) {
    transform: scale(0.97);
}

.chat-group-edit-save-fab:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.chat-group-edit-save-fab svg {
    flex-shrink: 0;
}

.chat-group-add-fab {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    z-index: 3;
    width: 3.35rem;
    height: 3.35rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8c96a 0%, #b8942a 100%);
    color: #1a1510;
    box-shadow: 0 0.35rem 1.25rem rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease, filter 0.15s ease;
}

.chat-group-add-fab:hover {
    transform: scale(1.05);
    filter: brightness(1.06);
}

.chat-group-add-fab:active {
    transform: scale(0.97);
}

.chat-group-add-fab svg {
    flex-shrink: 0;
}

.chat-group-add-overlay {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg-panel);
    border-left: 1px solid transparent;
}

.chat-group-add-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.chat-group-add-title {
    flex: 1;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
}

.chat-group-add-search-wrap {
    padding: 0.65rem 0.85rem;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-group-add-search {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.75rem;
    border-radius: 0.65rem;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.35);
    color: var(--chat-text);
    font-size: 0.88rem;
}

.chat-group-add-search::placeholder {
    color: var(--chat-muted);
}

.chat-group-add-search:focus {
    outline: none;
    border-color: var(--chat-accent);
    box-shadow: 0 0 0 1px var(--chat-accent-soft);
}

.chat-group-add-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.35rem 0.65rem 1rem;
}

.chat-group-add-empty {
    padding: 1.5rem 0.75rem;
    text-align: center;
    color: var(--chat-muted);
    font-size: 0.85rem;
    line-height: 1.45;
}

.chat-group-add-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.35rem;
    border-radius: 0.5rem;
    cursor: pointer;
    margin-bottom: 0.15rem;
}

.chat-group-add-row:hover {
    background: var(--chat-bg-hover);
}

.chat-group-add-row input[type='checkbox'] {
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
    accent-color: var(--chat-accent);
    cursor: pointer;
}

.chat-group-add-row-av {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--chat-muted);
}

.chat-group-add-row-av img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-group-add-row-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--chat-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-group-add-footer {
    flex-shrink: 0;
    padding: 0.65rem 1rem;
    border-top: 1px solid var(--chat-border);
    display: flex;
    justify-content: flex-end;
    background: rgba(0, 0, 0, 0.2);
}

.chat-group-add-submit {
    padding: 0.55rem 1.35rem;
    border-radius: 0.6rem;
    border: none;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    background: linear-gradient(135deg, #e8c96a 0%, #b8942a 100%);
    color: #1a1510;
    box-shadow: 0 0.2rem 0.65rem rgba(0, 0, 0, 0.25);
}

.chat-group-add-submit:not(:disabled):hover {
    filter: brightness(1.06);
}

.chat-group-add-row-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.chat-group-add-row-meta {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--chat-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-group-add-loading {
    padding: 1.25rem 0.75rem;
    text-align: center;
    color: var(--chat-muted);
    font-size: 0.85rem;
}

.chat-group-add-submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.chat-thread-info-toolbar {
    display: grid;
    grid-template-columns: 2.5rem 1fr 2.5rem;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--chat-border);
    flex-shrink: 0;
}

.chat-thread-info-toolbar-slot {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
}

.chat-thread-info-toolbar-slot--lead {
    justify-content: flex-start;
}

.chat-thread-info-toolbar-slot--trail {
    justify-content: flex-end;
}

.chat-thread-info-heading {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    text-align: center;
    min-width: 0;
}

.chat-thread-info-toolbar-spacer {
    width: 2.25rem;
    flex-shrink: 0;
}

.chat-thread-info-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1rem 1.25rem;
}

.chat-thread-info-hero {
    text-align: center;
    margin-bottom: 1.25rem;
}

.chat-thread-info-avatar-lg {
    width: 6.25rem;
    height: 6.25rem;
    margin: 0 auto 0.85rem;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(232, 201, 106, 0.38);
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--chat-muted);
}

.chat-thread-info-avatar-lg--initials {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.chat-thread-info-avatar-lg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-thread-info-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--chat-text);
    word-break: break-word;
}

.chat-thread-info-desc {
    margin-top: 0.65rem;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--chat-muted);
    text-align: center;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-thread-info-inner--editing .chat-group-add-fab {
    display: none;
}

.chat-thread-info-edit-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 0.5rem;
}

.chat-thread-info-channel-avatar-edit {
    position: relative;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Скрытый input[type=file]: не display:none — иначе programmatic .click() может не открыть диалог */
.chat-sr-only-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    opacity: 0;
}

.chat-group-edit-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chat-group-edit-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--chat-accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chat-group-edit-input,
.chat-group-edit-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.65rem;
    border-radius: 0.55rem;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.28);
    color: var(--chat-text);
    font-size: 0.92rem;
    font-family: inherit;
}

.chat-group-edit-textarea {
    resize: vertical;
    min-height: 4.5rem;
}

.chat-group-edit-input:focus,
.chat-group-edit-textarea:focus {
    outline: none;
    border-color: rgba(232, 201, 106, 0.55);
    box-shadow: 0 0 0 2px rgba(232, 201, 106, 0.12);
}

.chat-group-edit-hint {
    margin: -0.35rem 0 0;
    font-size: 0.78rem;
    color: var(--chat-muted);
    line-height: 1.4;
}

.chat-thread-info-hint {
    font-size: 0.82rem;
    color: var(--chat-muted);
    text-align: center;
    margin: 0.5rem 0 0;
}

.chat-thread-info-avatar-edit-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.65rem;
    border: 1px solid var(--chat-border);
    background: rgba(212, 175, 55, 0.12);
    color: var(--chat-accent);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.chat-thread-info-avatar-edit-btn:hover {
    background: rgba(212, 175, 55, 0.2);
}

.chat-thread-info-server {
    margin-top: 1rem;
}

.chat-thread-info-server-title {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--chat-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chat-thread-info-chars {
    list-style: none;
    margin: 0;
    padding: 0;
}

.chat-thread-info-char {
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.chat-thread-info-char:last-child {
    border-bottom: none;
}

.chat-thread-info-member {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-thread-info-member:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.chat-thread-info-member-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.65rem;
}

.chat-thread-info-member-av {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.35);
}

.chat-thread-info-member-av img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-thread-info-member-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--chat-text);
    min-width: 0;
}

.chat-thread-info-member-name-inner {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    min-width: 0;
}

.chat-thread-info-member-name-inner > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-thread-info-group-admin-badge {
    display: inline-block;
    margin-inline-start: 0.35rem;
    padding: 0.12rem 0.45rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #2a2418;
    background: linear-gradient(180deg, #e8c96a 0%, #c9a43d 100%);
    border-radius: 0.25rem;
    border: 1px solid rgba(90, 72, 28, 0.35);
    vertical-align: middle;
}

.chat-thread-info-member-row--ctx {
    cursor: context-menu;
}

.chat-thread-member-ctx {
    position: fixed;
    z-index: 12000;
    min-width: 12rem;
    padding: 0.35rem 0;
    margin: 0;
    list-style: none;
    background: var(--chat-panel-bg, #1e1c18);
    border: 1px solid rgba(232, 201, 106, 0.25);
    border-radius: 0.4rem;
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.45);
}

.chat-thread-member-ctx-btn {
    display: block;
    width: 100%;
    padding: 0.55rem 1rem;
    margin: 0;
    border: none;
    background: transparent;
    color: var(--chat-text, #e8e4dc);
    font: inherit;
    font-size: 0.9rem;
    text-align: start;
    cursor: pointer;
}

.chat-thread-member-ctx-btn:hover,
.chat-thread-member-ctx-btn:focus-visible {
    background: rgba(232, 201, 106, 0.12);
    outline: none;
}

.chat-thread-member-ctx-btn--danger {
    color: #f0a8a8;
}

.chat-thread-member-ctx-btn--danger:hover,
.chat-thread-member-ctx-btn--danger:focus-visible {
    background: rgba(200, 80, 80, 0.2);
}

.chat-thread-info-creator-badge {
    display: inline-block;
    margin-inline-start: 0.35rem;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.12rem 0.35rem;
    border-radius: 0.35rem;
    background: rgba(212, 175, 55, 0.22);
    color: var(--chat-accent);
    flex-shrink: 0;
}

.chat-thread-info-member-head.chat-thread-info-member-row {
    margin-bottom: 0;
}

.chat-thread-info-member-row {
    margin-bottom: 0.25rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-thread-info-member-row:last-of-type {
    border-bottom: none;
}

.chat-thread-info-members-list {
    margin-top: 0.75rem;
}

.chat-thread-info-group-actions {
    margin-top: 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.chat-thread-info-group-actions .chat-thread-info-leave-btn {
    margin-top: 0;
}

.chat-thread-info-destroy-group-btn {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(185, 28, 28, 0.55);
    background: rgba(185, 28, 28, 0.14);
    color: #fecaca;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.chat-thread-info-destroy-group-btn:hover {
    background: rgba(185, 28, 28, 0.22);
}

.chat-thread-info-leave-btn {
    margin-top: 1.35rem;
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(248, 113, 113, 0.45);
    background: rgba(248, 113, 113, 0.08);
    color: #f87171;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.chat-thread-info-leave-btn:hover {
    background: rgba(248, 113, 113, 0.14);
}

.chat-bubble-edited {
    margin-left: 0.35rem;
    font-size: 0.72em;
    font-weight: 600;
    color: var(--chat-muted);
    opacity: 0.88;
}

.chat-main-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--chat-border);
    background: rgba(22, 20, 17, 0.92);
    flex-shrink: 0;
}

.chat-main-mobile-back {
    display: none;
    flex-shrink: 0;
}

.chat-main-header-info {
    flex: 1;
    min-width: 0;
}

.chat-main-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.chat-main-sub {
    margin: 0.4rem 0 0;
    font-size: 0.78rem;
    color: var(--chat-muted);
    line-height: 1.35;
}

.chat-main-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-main-more-wrap {
    position: relative;
    flex-shrink: 0;
}

.chat-main-more-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 13.75rem;
    padding: 0.375rem 0;
    border-radius: 0.75rem;
    background: #1e1c18;
    border: 1px solid var(--chat-border);
    box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.5);
    z-index: 120;
}

.chat-main-more-item {
    display: block;
    width: 100%;
    padding: 0.625rem 1rem;
    border: none;
    background: transparent;
    color: var(--chat-text);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
}

.chat-main-more-item:hover {
    background: var(--chat-bg-hover);
}

.chat-main-more-item--danger {
    color: #f09090;
}

.chat-main-more-item--danger:hover {
    background: rgba(248, 113, 113, 0.12);
}

.chat-pinned {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--chat-muted);
    border-bottom: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    min-height: 0;
}

.chat-date-pill {
    text-align: center;
    margin: 0.75rem 0 1.125rem;
}

.chat-date-pill span {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 62.4375rem;
    background: rgba(0, 0, 0, 0.45);
    font-size: 0.78rem;
    color: var(--chat-muted);
}

.chat-msg-row {
    display: flex;
    margin-bottom: 0.75rem;
    width: 100%;
}

.chat-msg-row--out {
    justify-content: flex-end;
}

.chat-msg-cluster {
    display: flex;
    align-items: flex-end;
    gap: 0.625rem;
    max-width: min(45rem, 92%);
}

.chat-msg-cluster:not(.chat-msg-cluster--out) {
    cursor: pointer;
}

.chat-msg-cluster--out {
    flex-direction: row-reverse;
}

.chat-msg-stack {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-msg-author {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0 0.125rem;
}

.chat-msg-cluster--out .chat-msg-author {
    text-align: right;
}

.chat-empty-msgs {
    text-align: center;
    color: var(--chat-muted);
    font-size: 0.88rem;
    padding: 2rem 1rem;
}

.chat-bubble {
    max-width: min(35rem, 82%);
    border-radius: 0.75rem 0.75rem 0.75rem 0.25rem;
    padding: 0.5rem 0.75rem 0.375rem;
    font-size: 0.92rem;
    line-height: 1.45;
    background: var(--chat-in-msg);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 0.125rem 0.75rem rgba(0, 0, 0, 0.25);
}

.chat-msg-stack .chat-bubble {
    max-width: none;
    width: 100%;
}

.chat-msg-row--out .chat-bubble {
    border-radius: 0.75rem 0.75rem 0.25rem 0.75rem;
    background: var(--chat-out-msg);
    border-color: rgba(212, 175, 55, 0.25);
}

.chat-bubble-reply {
    border-left: 0.1875rem solid var(--chat-accent);
    padding: 0.375rem 0.5rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 0.375rem;
    font-size: 0.82rem;
}

.chat-bubble-reply-name {
    font-weight: 700;
    color: var(--chat-accent);
    margin-bottom: 0.125rem;
}

.chat-bubble-forward {
    border-left: 0.1875rem solid rgba(168, 156, 240, 0.65);
    padding: 0.375rem 0.5rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.375rem;
    font-size: 0.78rem;
    color: var(--chat-muted);
}

.chat-bubble-forward-name {
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.chat-bubble-forward-name:hover {
    color: var(--chat-accent);
}

.chat-bubble-body .chat-bubble-gif {
    display: block;
    max-width: min(100%, 17.5rem);
    max-height: 14rem;
    width: auto;
    height: auto;
    border-radius: 0.35rem;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.2);
}

.chat-msg-cluster--selected .chat-bubble {
    outline: 2px solid var(--chat-accent);
    outline-offset: 1px;
}

.chat-msg-cluster--selected .chat-msg-avatar {
    opacity: 0.95;
}

.chat-selection-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    margin-bottom: 0.35rem;
    border-radius: 0.35rem;
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid rgba(212, 175, 55, 0.28);
    font-size: 0.82rem;
}

.chat-selection-strip-cancel {
    flex-shrink: 0;
    padding: 0.25rem 0.55rem;
    border: none;
    border-radius: 0.3rem;
    background: rgba(0, 0, 0, 0.35);
    color: var(--chat-text);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.chat-selection-strip-cancel:hover {
    background: rgba(0, 0, 0, 0.5);
}

.chat-compose--selection .chat-compose-field .chat-icon-btn,
.chat-compose--selection .chat-compose-field .chat-attach-wrap {
    pointer-events: none;
    opacity: 0.45;
}

.chat-modal-dialog--forward {
    max-width: 22.5rem;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: min(70vh, 32rem);
    background: #1f1d1a;
    border: 1px solid rgba(212, 175, 55, 0.22);
    border-radius: 0.65rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.75);
}

.chat-forward-picker-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    padding: 0.65rem 0.5rem 0.65rem 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.2);
}

.chat-forward-picker-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0.4rem;
    background: transparent;
    color: var(--chat-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.chat-forward-picker-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--chat-text);
}

.chat-forward-picker-close:focus-visible {
    outline: 2px solid rgba(212, 175, 55, 0.55);
    outline-offset: 1px;
}

.chat-forward-picker-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0 0.25rem 0 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    color: #f2ede4;
}

.chat-forward-thread-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    padding: 0.2rem 0 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 0;
    -webkit-overflow-scrolling: touch;
}

.chat-forward-pick-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    margin: 0;
    padding: 0.55rem 0.85rem 0.55rem 0.75rem;
    border: none;
    border-radius: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
    transition: background 0.12s ease;
    touch-action: manipulation;
}

.chat-forward-pick-row:hover {
    background: rgba(212, 175, 55, 0.08);
}

.chat-forward-pick-row:focus-visible {
    outline: none;
    background: rgba(212, 175, 55, 0.12);
    box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.35);
}

.chat-forward-pick-avatar {
    flex-shrink: 0;
}

.chat-forward-pick-avatar .chat-avatar {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 0.68rem;
}

.chat-forward-pick-avatar .chat-avatar--group-initials {
    font-size: 0.82rem;
}

.chat-forward-pick-avatar .chat-avatar--main-public {
    font-size: 0.82rem;
}

.chat-forward-pick-avatar .chat-avatar--news {
    font-size: 0.88rem;
}

.chat-forward-pick-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.chat-forward-pick-primary {
    font-size: 0.92rem;
    font-weight: 600;
    color: #f5f2eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-forward-pick-secondary {
    font-size: 0.78rem;
    line-height: 1.25;
    color: rgba(196, 188, 176, 0.88);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-modal-btn--primary {
    background: rgba(212, 175, 55, 0.22);
    color: var(--chat-accent);
    border: 1px solid rgba(212, 175, 55, 0.35);
}

.chat-modal-btn--primary:hover {
    background: rgba(212, 175, 55, 0.32);
}

.chat-modal-btn--primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.chat-page.chat-selection-mode .chat-messages {
    user-select: none;
}

.chat-page--peer-export-restricted .chat-messages,
.chat-page--peer-export-restricted .chat-messages * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.chat-privacy-shield {
    position: absolute;
    inset: 0;
    z-index: 350;
    background: #000;
    pointer-events: none;
}

.chat-privacy-shield.chat-hidden {
    display: none;
}

.chat-bubble-foot {
    text-align: right;
    font-size: 0.68rem;
    color: var(--chat-muted);
    margin-top: 0.25rem;
}

.chat-compose {
    flex-shrink: 0;
    margin-top: auto;
    padding: 0.625rem 0.875rem 0.875rem;
    border-top: 1px solid var(--chat-border);
    background: rgba(18, 16, 14, 0.98);
    overflow: visible;
    position: relative;
    z-index: 30;
}

.chat-compose-inner {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    width: 100%;
    max-width: none;
    margin: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
}

.chat-compose-field {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 0.25rem;
    border: 1px solid var(--chat-border);
    border-radius: 0.875rem;
    background: rgba(0, 0, 0, 0.4);
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    overflow: visible;
    position: relative;
    z-index: 1;
}

.chat-emoji-anchor {
    position: relative;
    flex-shrink: 0;
    align-self: flex-end;
    overflow: visible;
    z-index: 2;
}

.chat-icon-btn--emoji-inline {
    width: 2.375rem;
    height: 2.375rem;
    border-radius: 0.625rem;
}

.chat-icon-btn--emoji-inline svg {
    width: 1.375rem;
    height: 1.375rem;
}

.chat-emoji-popover {
    position: absolute;
    bottom: calc(100% + 0.625rem);
    left: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0;
    width: min(17.5rem, calc(100vw - 3rem));
    max-width: min(17.5rem, calc(100vw - 3rem));
    min-height: 13.5rem;
    max-height: min(23rem, 62vh);
    overflow: hidden;
    background: #1e1c18;
    border: 1px solid var(--chat-border);
    border-radius: 0.75rem;
    box-shadow: 0 0.75rem 2.5rem rgba(0, 0, 0, 0.55);
}

.chat-emoji-popover.chat-emoji-popover--floating {
    position: fixed;
    bottom: auto;
    left: 0;
    top: 0;
    z-index: 12050;
}

.chat-emoji-popover[hidden] {
    display: none !important;
}

.chat-emoji-popover:not([hidden]) {
    display: flex;
}

.chat-emoji-popover-inner {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: 12rem;
    max-height: min(22rem, 60vh);
    overflow: hidden;
}

.chat-emoji-popover-body {
    flex: 1 1 auto;
    min-height: 9.5rem;
    max-height: min(18.5rem, 52vh);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chat-emoji-panel {
    display: none;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0.25rem;
    padding: 0.625rem;
    flex: 1 1 auto;
    min-height: 8.5rem;
    overflow-x: hidden;
    overflow-y: auto;
}

.chat-emoji-panel.is-active {
    display: flex;
}

.chat-gif-panel {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0.625rem 0.625rem;
    flex: 1 1 auto;
    min-height: 10rem;
    overflow: hidden;
}

.chat-gif-panel.is-active {
    display: flex;
    flex: 1 1 auto;
    min-height: 10.5rem;
    max-height: min(19rem, 54vh);
    overflow: hidden;
}

.chat-gif-search-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.125rem 0.5rem;
    border-radius: 0.5rem;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

.chat-gif-search-wrap svg {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    opacity: 0.55;
    color: var(--chat-muted);
}

.chat-gif-search {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--chat-text);
    font-size: 0.86rem;
    padding: 0.35rem 0;
    outline: none;
}

.chat-gif-search::placeholder {
    color: var(--chat-muted);
}

.chat-gif-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: max-content;
    align-content: start;
    gap: 0.125rem;
    flex: 1 1 auto;
    min-height: 8.75rem;
    max-height: min(14rem, 44vh);
    overflow-x: hidden;
    overflow-y: auto;
}

.chat-gif-cell {
    position: relative;
    aspect-ratio: 1;
    border: none;
    border-radius: 0.35rem;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.45);
}

.chat-gif-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-gif-cell:hover {
    filter: brightness(1.08);
}

.chat-gif-status {
    grid-column: 1 / -1;
    margin: auto;
    padding: 0.75rem 0.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--chat-muted);
    line-height: 1.35;
}

.chat-emoji-popover-tabs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.375rem 0.5rem 0.5rem;
    border-top: 1px solid rgba(212, 175, 55, 0.12);
    background: rgba(0, 0, 0, 0.22);
    flex-shrink: 0;
}

.chat-emoji-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.25rem;
    padding: 0 0.65rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--chat-muted);
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.chat-emoji-tab:hover {
    color: var(--chat-text);
    background: var(--chat-bg-hover);
}

.chat-emoji-tab.is-active {
    color: var(--chat-accent, #d4af37);
    background: rgba(212, 175, 55, 0.12);
}

.chat-emoji-tab-ico {
    font-size: 1.2rem;
    line-height: 1;
}

.chat-emoji-tab-gif-label {
    margin: 0;
    padding: 0.1rem 0.35rem;
    border-radius: 0.3rem;
    border: 1px solid currentColor;
    font-size: 0.62rem;
    line-height: 1;
}

.chat-compose-field textarea {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--chat-text);
    resize: none;
    min-height: 2.5rem;
    max-height: 4.5rem;
    padding: 0.5rem 0.25rem;
    min-width: 0;
    font-size: 0.92rem;
    line-height: 1.45;
    outline: none;
    overflow-y: auto;
}

.chat-attach-wrap {
    position: relative;
    flex-shrink: 0;
    align-self: flex-end;
    z-index: 2;
}

.chat-attach-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 0;
    min-width: 12.5rem;
    background: #1e1c18;
    border: 1px solid var(--chat-border);
    border-radius: 0.625rem;
    padding: 0.375rem 0;
    z-index: 300;
    box-shadow: 0 0.75rem 2.5rem rgba(0, 0, 0, 0.55);
}

.chat-attach-menu.chat-attach-menu--floating {
    position: fixed;
    bottom: auto;
    right: auto;
    left: 0;
    top: 0;
    z-index: 12050;
}

.chat-attach-menu.is-open {
    display: block;
}

.chat-attach-menu button {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: none;
    background: transparent;
    color: var(--chat-text);
    text-align: left;
    font-size: 0.88rem;
    cursor: pointer;
}

.chat-attach-menu button:hover {
    background: var(--chat-bg-hover);
}

.chat-compose-send {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #e8c96a 0%, #b8942a 100%);
    color: #1a1510;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    /* Мгновенный отклик на мобильных */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

@media (hover: hover) {
    .chat-compose-send:hover {
        filter: brightness(1.08);
    }
}

.chat-compose-send:active {
    filter: brightness(0.92);
    transform: scale(0.97);
}

.chat-compose-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-guest-compose-msg {
    padding: 1.125rem 1rem 1.25rem;
    font-size: 0.92rem;
    color: var(--chat-muted);
    text-align: center;
    line-height: 1.45;
}

.chat-devices-main {
    max-width: 62rem;
    margin: 0 auto;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-devices-head {
    align-items: center;
    gap: 0.75rem;
}

.chat-devices-back {
    flex-shrink: 0;
}

.chat-devices-body {
    flex: 1;
    min-height: 0;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.chat-devices-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    border: 1px solid var(--chat-border);
    border-radius: 0.8rem;
    padding: 0.8rem 0.9rem;
    background: rgba(0, 0, 0, 0.28);
}

.chat-devices-meta {
    min-width: 0;
}

.chat-devices-title {
    color: var(--chat-text);
    font-weight: 700;
    font-size: 0.95rem;
}

.chat-devices-sub,
.chat-devices-time {
    color: var(--chat-muted);
    font-size: 0.82rem;
    margin-top: 0.2rem;
}

.chat-devices-action {
    flex-shrink: 0;
}

.chat-devices-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid var(--chat-border);
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    color: var(--chat-text);
    text-decoration: none;
    white-space: nowrap;
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.chat-devices-btn--danger {
    border-color: rgba(221, 89, 89, 0.5);
    color: #f3b2b2;
}

.chat-devices-btn--ok {
    border-color: rgba(72, 191, 131, 0.45);
    color: #8de0b2;
}

.chat-devices-head-action {
    margin-left: auto;
    flex-shrink: 0;
}

.chat-reply-strip {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0.625rem;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.35);
    font-size: 0.82rem;
    color: var(--chat-muted);
}

.chat-reply-strip-inner {
    flex: 1;
    min-width: 0;
}

.chat-reply-strip-label {
    display: block;
    font-weight: 700;
    color: var(--chat-accent);
    font-size: 0.72rem;
    margin-bottom: 0.25rem;
}

.chat-reply-strip-snippet {
    display: block;
    line-height: 1.35;
}

.chat-reply-strip-close {
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.45);
    color: var(--chat-muted);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}

.chat-reply-strip-close:hover {
    color: var(--chat-text);
    background: var(--chat-bg-hover);
}

.chat-emoji-popover .chat-emoji-cell {
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    flex-shrink: 0;
}

.chat-emoji-popover .chat-emoji-cell:hover {
    background: var(--chat-bg-hover);
}

.chat-context-menu {
    position: fixed;
    z-index: 250;
    min-width: 12.5rem;
    padding: 0.375rem 0;
    background: #1e1c18;
    border: 1px solid var(--chat-border);
    border-radius: 0.625rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.55);
}

.chat-context-item {
    display: block;
    width: 100%;
    padding: 0.625rem 1rem;
    border: none;
    background: transparent;
    color: var(--chat-text);
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
}

.chat-context-item:hover {
    background: var(--chat-bg-hover);
}

.chat-context-item--danger {
    color: #e74c3c;
}

.chat-context-menu--thread {
    min-width: 15rem;
    padding: 0.35rem 0;
}

.chat-ctx-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.45rem 0.75rem;
    border: none;
    background: transparent;
    color: var(--chat-text);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    border-radius: 0.35rem;
}

.chat-ctx-row:hover {
    background: var(--chat-bg-hover);
}

.chat-ctx-row--danger {
    color: #e74c3c;
}

.chat-ctx-row--danger:hover {
    background: rgba(231, 76, 60, 0.12);
}

.chat-ctx-icon {
    flex-shrink: 0;
    width: 1.35rem;
    height: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-muted);
}

.chat-ctx-row--danger .chat-ctx-icon {
    color: #e74c3c;
}

.chat-ctx-label {
    flex: 1;
}

.chat-ctx-chevron {
    margin-left: auto;
    color: var(--chat-muted);
    font-size: 1rem;
    line-height: 1;
}

.chat-ctx-row--folder {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.75rem;
    cursor: default;
    border-radius: 0.35rem;
}

.chat-ctx-row--folder:hover {
    background: var(--chat-bg-hover);
}

.chat-ctx-submenu {
    display: none;
    position: absolute;
    left: calc(100% - 2px);
    top: -0.25rem;
    min-width: 11rem;
    padding: 0.35rem 0;
    background: #1e1c18;
    border: 1px solid var(--chat-border);
    border-radius: 0.625rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.55);
    z-index: 10;
}

.chat-ctx-row--folder:hover .chat-ctx-submenu {
    display: block;
}

.chat-ctx-sub-item {
    display: block;
    width: 100%;
    padding: 0.45rem 0.85rem;
    border: none;
    background: transparent;
    color: var(--chat-text);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
}

.chat-ctx-sub-item:hover {
    background: var(--chat-bg-hover);
}

.chat-modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.chat-modal.chat-hidden {
    display: none;
}

.chat-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.chat-modal-dialog {
    position: relative;
    width: 100%;
    max-width: 22rem;
    padding: 1.25rem 1.35rem;
    background: #252320;
    border: 1px solid var(--chat-border);
    border-radius: 0.75rem;
    box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.65);
}

.chat-modal-head {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.85rem;
}

.chat-modal-avatar {
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
}

.chat-modal-avatar .chat-modal-avatar-inner,
.chat-modal-avatar-inner {
    width: 2.75rem;
    height: 2.75rem;
}

.chat-modal-head-text {
    flex: 1;
    min-width: 0;
}

.chat-modal-head-text--solo {
    margin-bottom: 0;
}

.chat-modal-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
}

.chat-modal-body {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--chat-text);
    line-height: 1.45;
}

.chat-modal-check {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.88rem;
    cursor: pointer;
    color: var(--chat-text);
}

.chat-modal-check input {
    margin-top: 0.15rem;
}

.chat-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.chat-modal-btn {
    padding: 0.45rem 0.85rem;
    border: none;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.chat-modal-btn--ghost {
    background: transparent;
    color: #a89cf0;
}

.chat-modal-btn--ghost:hover {
    background: rgba(168, 156, 240, 0.12);
}

.chat-modal-btn--danger {
    background: transparent;
    color: #e74c3c;
}

.chat-modal-btn--danger:hover {
    background: rgba(231, 76, 60, 0.12);
}

.chat-panel-list-mode-list,
.chat-panel-list-mode-create,
.chat-panel-list-mode-private {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-create-group-header .chat-create-group-heading {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    padding-right: 2.5rem;
}

.chat-create-group-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1rem 4rem;
    position: relative;
}

.chat-create-group-avatar-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
    position: relative;
}

.chat-create-group-avatar-btn {
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    border: 2px dashed rgba(212, 175, 55, 0.35);
    background: rgba(0, 0, 0, 0.35);
    cursor: pointer;
    padding: 0;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-muted);
    transition: border-color 0.15s, background 0.15s;
}

.chat-create-group-avatar-btn:hover {
    border-color: var(--chat-accent-soft);
    color: var(--chat-accent);
}

.chat-create-group-avatar-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.chat-create-group-avatar-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chat-create-group-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.chat-private-header .chat-private-heading {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    padding-right: 2.5rem;
}

.chat-create-group-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--chat-accent);
}

.chat-create-group-title-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 0.875rem;
    border-radius: 0.75rem;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.4);
    color: var(--chat-text);
    font-size: 0.95rem;
    outline: none;
}

.chat-create-group-title-input:focus {
    border-color: var(--chat-accent-soft);
}

.chat-create-group-next {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8c96a 0%, #b8942a 100%);
    color: #1a1510;
    box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.35);
}

.chat-create-group-next:hover {
    filter: brightness(1.08);
}

.chat-create-group-next:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.chat-private-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.chat-private-field {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.chat-private-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--chat-accent);
}

.chat-private-nick-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 0.875rem;
    border-radius: 0.75rem;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.4);
    color: var(--chat-text);
    font-size: 0.95rem;
    outline: none;
}

.chat-private-nick-input:focus {
    border-color: var(--chat-accent-soft);
}

.chat-private-hint {
    margin: 0;
    font-size: 0.78rem;
    color: var(--chat-muted);
    line-height: 1.4;
}

.chat-private-status {
    margin: 0;
    font-size: 0.82rem;
    color: var(--chat-accent);
}

.chat-private-results {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chat-private-result-row {
    display: block;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border-radius: 0.625rem;
    border: 1px solid var(--chat-border);
    background: rgba(0, 0, 0, 0.28);
    color: var(--chat-text);
    cursor: pointer;
    text-align: left;
}

.chat-private-result-row:hover {
    background: var(--chat-bg-hover);
    border-color: var(--chat-accent-soft);
}

.chat-private-result-main {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.chat-private-result-av {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--chat-border);
}

.chat-private-result-name {
    font-weight: 700;
    font-size: 0.9rem;
}

.chat-private-result-meta {
    font-size: 0.76rem;
    color: var(--chat-muted);
    margin-top: 0.125rem;
}

.chat-private-empty {
    margin: 0.5rem 0 0;
    font-size: 0.88rem;
    color: var(--chat-muted);
}

.chat-list-fab-wrap {
    position: absolute;
    right: 0.875rem;
    bottom: 0.875rem;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.chat-fab-menu {
    min-width: 13.5rem;
    padding: 0.375rem 0;
    border-radius: 0.75rem;
    background: #1e1c18;
    border: 1px solid var(--chat-border);
    box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.5);
}

.chat-fab-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 1rem;
    border: none;
    background: transparent;
    color: var(--chat-text);
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
}

.chat-fab-menu-item:hover {
    background: var(--chat-bg-hover);
}

.chat-fab-menu-icon {
    flex-shrink: 0;
    opacity: 0.85;
    color: var(--chat-accent);
}

.chat-fab-toggle {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8c96a 0%, #b8942a 100%);
    color: #1a1510;
    box-shadow: 0 0.35rem 1.25rem rgba(0, 0, 0, 0.4);
}

.chat-fab-toggle:hover {
    filter: brightness(1.06);
}

.chat-fab-icon {
    display: block;
}

.chat-avatar--img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (max-width: 56.25rem) {
    .chat-compose {
        overflow-x: hidden;
        box-sizing: border-box;
        padding-left: max(0.55rem, env(safe-area-inset-left, 0px));
        padding-right: max(0.55rem, env(safe-area-inset-right, 0px));
    }

    .chat-layout {
        flex-direction: column;
        flex: 1;
        min-height: 0;
    }

    /* Список чатов на весь экран, диалог открывается по тапу */
    .chat-page:not(.chat-mobile--conversation-open) .chat-main-column {
        display: none !important;
    }

    .chat-page:not(.chat-mobile--conversation-open) .chat-sidebar {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        max-width: none;
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: none;
    }

    .chat-page.chat-mobile--conversation-open .chat-sidebar {
        display: none !important;
    }

    .chat-page.chat-mobile--conversation-open .chat-main-column {
        display: flex !important;
        flex-direction: column;
        flex: 1;
        min-height: 0;
        width: 100%;
        position: relative;
    }

    .chat-page.chat-mobile--conversation-open .chat-main {
        flex: 1;
        min-height: 0;
    }

    .chat-page.chat-mobile--conversation-open .chat-main-mobile-back {
        display: inline-flex;
    }

    /* Закрытая панель не участвует в вёрстке колонки */
    .chat-thread-info-panel:not(.chat-thread-info-panel--open) {
        display: none !important;
    }

    /* Панель «Информация» на мобильном — на весь экран области диалога */
    .chat-thread-info-panel.chat-thread-info-panel--open {
        display: flex !important;
        position: absolute;
        inset: 0;
        width: 100% !important;
        max-height: none !important;
        height: 100%;
        flex: none !important;
        z-index: 70;
        border-left: none;
        border-top: none;
        transition: none;
        box-sizing: border-box;
        box-shadow: none;
    }

    .chat-page.chat-mobile--conversation-open .chat-compose {
        margin-top: 0;
        padding-bottom: calc(0.625rem + env(safe-area-inset-bottom, 0px));
    }

    html.chat-shell-root {
        font-size: 100%;
    }

    .chat-compose-inner {
        max-width: 100%;
        box-sizing: border-box;
        gap: 0.3rem;
    }

    .chat-compose-inner,
    .chat-compose-field {
        min-width: 0;
    }

    .chat-compose-field textarea {
        min-width: 0;
        /* 16px на iOS предотвращает авто-zoom при фокусе и увод кнопки отправки за экран */
        font-size: 16px;
    }

    .chat-compose-send {
        width: 2.5rem;
        height: 2.5rem;
        flex-shrink: 0;
    }

    .chat-icon-btn--emoji-inline {
        width: 2.125rem;
        height: 2.125rem;
    }

    .chat-devices-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .chat-devices-head {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .chat-devices-head-action {
        width: 100%;
        margin-left: 0;
    }

    .chat-devices-action {
        width: 100%;
    }

    .chat-devices-btn {
        width: 100%;
    }
}

/* Модальное окно вложений (комментарий + отправка) */
.chat-attach-compose-modal.chat-modal {
    z-index: 420;
}

.chat-attach-compose-dialog {
    position: relative;
    width: 100%;
    max-width: 24rem;
    max-height: min(90vh, 40rem);
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--chat-bg-panel);
    border: 1px solid var(--chat-border);
    border-radius: 0.85rem;
    box-shadow: 0 1.25rem 3.5rem rgba(0, 0, 0, 0.72);
    overflow: hidden;
}

.chat-attach-compose-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.4rem 0.55rem 0.35rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.12);
    flex-shrink: 0;
}

.chat-attach-compose-title {
    flex: 1;
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    text-align: center;
    color: var(--chat-text);
}

.chat-attach-compose-more {
    position: relative;
    flex-shrink: 0;
}

.chat-attach-compose-popover {
    position: absolute;
    top: calc(100% + 0.25rem);
    right: 0;
    min-width: 12.5rem;
    padding: 0.25rem 0;
    background: #252320;
    border: 1px solid var(--chat-border);
    border-radius: 0.45rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.45);
    z-index: 2;
}

.chat-attach-compose-menu-item {
    display: block;
    width: 100%;
    padding: 0.45rem 0.85rem;
    border: none;
    background: transparent;
    color: var(--chat-text);
    font-size: 0.86rem;
    text-align: left;
    cursor: pointer;
}

.chat-attach-compose-menu-item:hover {
    background: var(--chat-bg-hover);
}

.chat-attach-compose-preview {
    flex: 1;
    min-height: 10rem;
    max-height: 42vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    padding: 0.5rem;
}

.chat-attach-compose-preview-media {
    width: 100%;
    height: 100%;
    max-height: 42vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-attach-compose-preview-media img,
.chat-attach-compose-preview-media video {
    max-width: 100%;
    max-height: 42vh;
    object-fit: contain;
    border-radius: 0.35rem;
}

.chat-attach-compose-preview-file {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.35rem 0.5rem;
}

.chat-attach-compose-file-thumb {
    width: 3.5rem;
    height: 3.5rem;
    object-fit: cover;
    border-radius: 0.35rem;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.25);
}

.chat-attach-compose-file-icon {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0.35rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(212, 175, 55, 0.12);
    color: var(--chat-accent);
}

.chat-attach-compose-file-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--chat-text);
    word-break: break-all;
}

.chat-attach-compose-file-size {
    font-size: 0.78rem;
    color: var(--chat-muted);
    margin-top: 0.15rem;
}

.chat-attach-compose-thumbs {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 0.4rem 0.65rem 0;
    max-height: 4.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
}

.chat-attach-compose-thumbs:empty {
    display: none;
}

.chat-attach-compose-thumb {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 0.3rem;
    object-fit: cover;
    border: 2px solid transparent;
    cursor: pointer;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
}

.chat-attach-compose-thumb.is-focus {
    border-color: var(--chat-accent);
}

.chat-attach-compose-caption-label {
    display: block;
    margin: 0;
    padding: 0.55rem 0.65rem 0.35rem;
    flex-shrink: 0;
}

.chat-attach-compose-caption {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--chat-border);
    border-radius: 0.45rem;
    padding: 0.5rem 0.6rem;
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--chat-text);
    background: rgba(0, 0, 0, 0.22);
    resize: vertical;
    min-height: 2.5rem;
    max-height: 8rem;
}

.chat-attach-compose-caption::placeholder {
    color: var(--chat-muted);
}

.chat-attach-compose-foot {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem 0.65rem 0.75rem;
    flex-shrink: 0;
}

.chat-attach-compose-send.chat-modal-btn--primary {
    background: linear-gradient(135deg, #e8c96a 0%, #b8942a 100%);
    color: #1a1510;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    padding: 0.55rem 1.15rem;
}

.chat-attach-compose-send.chat-modal-btn--primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.chat-bubble-attachments {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 0.35rem;
}

.chat-bubble-attachment-img {
    max-width: min(100%, 18rem);
    max-height: 22rem;
    border-radius: 0.35rem;
    display: block;
}

.chat-bubble-media-openable {
    cursor: zoom-in;
}

.chat-bubble-gif.chat-bubble-media-openable {
    cursor: zoom-in;
}

.chat-bubble-attachment-video-wrap {
    position: relative;
    display: inline-block;
    max-width: min(100%, 20rem);
    border-radius: 0.35rem;
    overflow: hidden;
    cursor: pointer;
    vertical-align: top;
}

.chat-bubble-attachment-video-wrap video {
    display: block;
    max-width: 100%;
    max-height: 22rem;
    border-radius: 0.35rem;
}

.chat-bubble-attachment-video-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.95);
    font-size: 2rem;
    pointer-events: none;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.chat-bubble-attachment-video {
    max-width: min(100%, 20rem);
    max-height: 22rem;
    border-radius: 0.35rem;
}

.chat-bubble-attachment-file {
    display: inline-block;
    font-size: 0.88rem;
    color: var(--chat-accent);
    text-decoration: underline;
    word-break: break-all;
}

.chat-bubble-text {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Полноэкранный просмотр фото / видео */
.chat-media-viewer {
    position: fixed;
    inset: 0;
    z-index: 415;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.92);
}

.chat-media-viewer.chat-hidden {
    display: none !important;
}

.chat-media-viewer-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
}

.chat-media-viewer-toolbar {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.65rem;
    padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
}

.chat-media-viewer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: none;
    border-radius: 0.45rem;
    background: rgba(30, 28, 24, 0.75);
    color: var(--chat-text);
    cursor: pointer;
    border: 1px solid rgba(212, 175, 55, 0.22);
}

.chat-media-viewer-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    color: var(--chat-accent);
}

#chat-media-viewer-zoom .chat-media-viewer-zoom-ico--in {
    display: block;
}

#chat-media-viewer-zoom .chat-media-viewer-zoom-ico--out {
    display: none;
}

#chat-media-viewer-zoom.is-zoomed .chat-media-viewer-zoom-ico--in {
    display: none;
}

#chat-media-viewer-zoom.is-zoomed .chat-media-viewer-zoom-ico--out {
    display: block;
}

.chat-media-viewer-stage-wrap {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    overflow: auto;
}

.chat-media-viewer-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: min-content;
    transition: transform 0.2s ease;
}

.chat-media-viewer-stage--zoomed .chat-media-viewer-img,
.chat-media-viewer-stage--zoomed .chat-media-viewer-video {
    transform: scale(1.4);
    transform-origin: center center;
}

.chat-media-viewer-img,
.chat-media-viewer-video {
    max-width: 100%;
    max-height: calc(100vh - 6rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.25rem;
}

.chat-media-viewer-video {
    background: #000;
}
