:root {
    --chat-accent: var(--my-name-color, var(--accent-color, #ff4d6d));
    --chat-accent-rgb: 255, 77, 109;
}

/* ==========================================
   КНОПКА ОТКРЫТИЯ ЧАТА
   ========================================== */
.chat-drop-btn {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 58px;
    border: 1px solid rgba(255, 77, 109, 0.35);
    border-left: none;
    background: linear-gradient(135deg, rgba(26, 29, 42, 0.88) 0%, rgba(16, 18, 26, 0.92) 100%);
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    color: #e2e8f0;
    border-radius: 0 16px 16px 0;
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 0 16px rgba(255, 77, 109, 0.15);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-drop-btn:hover {
    color: #fff;
    width: 46px;
    background: linear-gradient(135deg, rgba(38, 42, 60, 0.96) 0%, rgba(22, 25, 36, 0.96) 100%);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55), 0 0 24px rgba(255, 77, 109, 0.4);
    border-color: rgba(255, 77, 109, 0.65);
}

.chat-drop-btn.side-right {
    left: auto;
    right: 0;
    border-left: 1px solid rgba(255, 77, 109, 0.35);
    border-right: none;
    border-radius: 16px 0 0 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 0 16px rgba(255, 77, 109, 0.15);
}

.chat-drop-btn.side-right:hover {
    width: 46px;
}

.chat-drop-btn.has-unread,
.chat-drop-btn.has-notif {
    animation: dropBtnPulse 2.4s infinite;
}

@keyframes dropBtnPulse {

    0%,
    100% {
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45), 0 0 12px rgba(255, 77, 109, 0.25);
    }

    50% {
        box-shadow: 0 6px 26px rgba(0, 0, 0, 0.6), 0 0 26px rgba(255, 77, 109, 0.65);
        border-color: rgba(255, 77, 109, 0.85);
    }
}

.chat-drop-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: linear-gradient(135deg, #ff4d6d 0%, #d63a6a 100%);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(255, 77, 109, 0.6);
}

.chat-drop-btn.hidden {
    transform: translateY(-50%) translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

.chat-drop-btn.side-right.hidden {
    transform: translateY(-50%) translateX(100%);
}

.chat-drop-btn svg {
    width: 19px;
    height: 19px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 14, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.chat-overlay.show {
    opacity: 1;
    pointer-events: all;
}

/* ==========================================
   ПАНЕЛЬ
   ========================================== */
.chat-panel {
    position: fixed;
    top: 16px;
    bottom: 16px;
    width: 580px;
    background: rgba(14, 16, 23, 0.92);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #f1f3f7;
    font-family: 'MyCustomFont', sans-serif;
    border-radius: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.05);
    opacity: 0;
    transform: translateX(-40px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
        width 0.25s ease;
}

.chat-panel.open {
    opacity: 1;
    transform: translateX(0) scale(1);
    pointer-events: all;
}

.chat-panel.side-left:not(.open) {
    transform: translateX(-40px) scale(0.97);
}

.chat-panel.side-right:not(.open) {
    transform: translateX(40px) scale(0.97);
}

.chat-panel.resizing,
.chat-panel.dragging {
    transition: none;
}

/* --- Хедер --- */
.chat-panel-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: rgba(20, 23, 33, 0.85);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    user-select: none;
}

.panel-header-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    flex: 1;
    min-width: 0;
}

.panel-header-logo {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.panel-header-brand:hover .panel-header-logo {
    transform: scale(1.08) rotate(-3deg);
}

.panel-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.panel-back-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    transform: translateX(-1px);
}

.panel-back-btn svg {
    width: 19px;
    height: 19px;
}

.panel-header-title {
    font-size: 15px;
    font-weight: 600;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.25px;
}

.header-icon-btn,
.chat-panel-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.header-icon-btn:hover,
.chat-panel-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: translateY(-1px);
}

.chat-panel-close:hover {
    background: rgba(255, 77, 109, 0.2);
    color: #ff4d6d;
}

.header-icon-btn svg,
.chat-panel-close svg {
    width: 18px;
    height: 18px;
}

/* ==========================================
   POPOVER настроек (стиль AnimeHub Glass)
   ========================================== */
.layout-popover {
    position: absolute;
    top: 54px;
    right: 12px;
    width: 240px;
    background: rgba(18, 21, 31, 0.94);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 14px;
    z-index: 30;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.layout-popover.show {
    opacity: 1;
    transform: none;
    pointer-events: all;
}

.popover-title {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.layout-popover .popover-modes {
    display: flex;
    gap: 6px;
    width: 100%;
}

.layout-popover .popover-modes .panel-mode-btn {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    height: auto;
    flex-direction: column;
    gap: 6px;
    padding: 9px 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid transparent;
}

.layout-popover .popover-modes .panel-mode-btn span,
.layout-popover .popover-sides .pin-side-btn span {
    font-size: 11px;
    font-weight: 500;
    color: inherit;
}

.layout-popover .pin-side-switch {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    transition: opacity 0.3s ease;
}

.layout-popover .popover-sides {
    display: flex;
    gap: 6px;
    width: 100%;
}

.layout-popover .popover-sides .pin-side-btn {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    height: auto;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid transparent;
}

.panel-mode-btn,
.pin-side-btn {
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.panel-mode-btn:hover,
.pin-side-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
    transform: translateY(-1px);
}

.panel-mode-btn.active,
.pin-side-btn.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(var(--chat-accent-rgb), 0.25) 0%, rgba(var(--chat-accent-rgb), 0.42) 100%);
    border-color: rgba(var(--chat-accent-rgb), 0.55);
    box-shadow: 0 2px 10px rgba(var(--chat-accent-rgb), 0.25);
}

.panel-mode-btn svg,
.pin-side-btn svg {
    width: 18px;
    height: 18px;
}

/* ==========================================
   ТЕЛО ПАНЕЛИ
   ========================================== */
.chat-panel-body {
    position: relative;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* --- Закрепы сверху (общие для всех видов) --- */
.pinned-row {
    display: flex;
    gap: 10px;
    padding: 10px 12px 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.pinned-item {
    width: 56px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    position: relative;
}

.pinned-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(var(--chat-accent-rgb), 0.1) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.pinned-item:hover .pinned-avatar {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.14) 0%, rgba(var(--chat-accent-rgb), 0.2) 100%);
    transform: translateY(-2px) scale(1.04);
    border-color: rgba(var(--chat-accent-rgb), 0.45);
}

.pinned-item.active .pinned-avatar {
    box-shadow: 0 0 0 2px var(--chat-accent), 0 0 14px rgba(var(--chat-accent-rgb), 0.45);
    border-color: var(--chat-accent);
}

.pinned-item .chat-list-unread {
    position: absolute;
    top: -2px;
    right: 2px;
}

.pinned-name {
    font-size: 10.5px;
    font-weight: 500;
    color: #94a3b8;
    width: 100%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-views {
    position: relative;
    flex: 1;
    overflow: hidden;
}

/* ==========================================
   СПИСОК ЧАТОВ
   ========================================== */
.chat-list-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.chat-panel-body.chat-open .chat-list-view {
    transform: translateX(-25%);
    opacity: 0.4;
}

.chat-list-topbar {
    padding: 10px 12px 6px;
    flex-shrink: 0;
}

.chat-list-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 8px 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-list-search:focus-within {
    border-color: var(--chat-accent);
    box-shadow: 0 0 12px rgba(var(--chat-accent-rgb), 0.22);
}

.chat-list-search svg {
    width: 15px;
    height: 15px;
    color: #94a3b8;
    flex-shrink: 0;
}

.chat-list-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #f1f3f7;
    font-size: 13px;
}

.chat-list-search input::placeholder {
    color: #64748b;
}

.chat-list-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

/* ✅ Элемент списка */
.chat-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 34px 10px 14px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
    border-radius: 12px;
    margin: 3px 8px;
    position: relative;
    border: 1px solid transparent;
}

.chat-list-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.06);
    transform: translateY(-1px);
}

.chat-list-item.active {
    background: linear-gradient(135deg, rgba(var(--chat-accent-rgb), 0.14) 0%, rgba(var(--chat-accent-rgb), 0.24) 100%);
    border-left: 3px solid var(--chat-accent);
    border-color: rgba(var(--chat-accent-rgb), 0.35);
    box-shadow: 0 2px 12px rgba(var(--chat-accent-rgb), 0.12);
}

.chat-list-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(var(--chat-accent-rgb), 0.15) 100%);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chat-list-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.chat-list-name {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}

.chat-list-name-text {
    font-size: 14px;
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-list-pin {
    flex-shrink: 0;
    opacity: 0.45;
    display: flex;
    align-items: center;
}

.chat-list-pin svg {
    width: 12px;
    height: 12px;
}

.chat-list-last {
    font-size: 13px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ✅ Время сверху, непрочитанные снизу */
.chat-list-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.chat-list-time {
    font-size: 11.5px;
    color: #64748b;
}

.chat-list-unread {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--chat-accent) 0%, #f72585 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 8px rgba(var(--chat-accent-rgb), 0.45);
}

/* ✅ Три точки справа по центру */
.chat-menu-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s ease;
}

.chat-list-item:hover .chat-menu-btn {
    opacity: 1;
}

.chat-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.chat-menu-btn svg {
    width: 16px;
    height: 16px;
}

.chat-list-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 4px 16px;
}

/* ==========================================
   КОНТЕКСТНОЕ МЕНЮ ВЕТОК
   ========================================== */
.chat-ctx-menu {
    position: absolute;
    z-index: 60;
    background: rgba(20, 23, 34, 0.95);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 6px;
    min-width: 200px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75), 0 0 1px 1px rgba(255, 255, 255, 0.05);
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.chat-ctx-menu.show {
    opacity: 1;
    transform: none;
    pointer-events: all;
}

.ctx-item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px 12px;
    border-radius: 9px;
    font-size: 13px;
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.12s ease;
}

.ctx-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.ctx-item.danger {
    color: #ff5c75;
}

.ctx-item.danger:hover {
    background: rgba(255, 77, 109, 0.15);
    color: #ff758f;
}

.ctx-sep {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 4px 6px;
}

/* ==========================================
   КОНТЕКСТНОЕ МЕНЮ СООБЩЕНИЙ (ПКМ + Долгий тап)
   ========================================== */
.msg-ctx-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100001;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.msg-ctx-backdrop.show {
    opacity: 1;
    pointer-events: auto !important;
}

.msg-context-menu {
    position: fixed;
    z-index: 100002;
    background: rgba(18, 20, 29, 0.98);
    backdrop-filter: blur(28px) saturate(200%);
    -webkit-backdrop-filter: blur(28px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 8px;
    min-width: 220px;
    max-width: calc(100vw - 24px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 77, 109, 0.2);
    opacity: 0;
    transform: scale(0.92);
    transform-origin: top left;
    pointer-events: none;
    transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    font-family: inherit;
}

.msg-context-menu.show {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto !important;
}

.msg-ctx-item,
.msg-ctx-emoji-btn {
    pointer-events: auto !important;
    touch-action: manipulation;
}

.msg-ctx-reactions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    margin-bottom: 6px;
}

.msg-ctx-emoji-btn {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    padding: 6px 5px;
    cursor: pointer;
    border-radius: 8px;
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-ctx-emoji-btn:hover {
    transform: scale(1.35);
    background: rgba(255, 255, 255, 0.12);
}

.msg-ctx-emoji-btn:active {
    transform: scale(0.95);
}

.msg-ctx-sep {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    margin: 4px 0;
}

.msg-ctx-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.msg-ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: #e2e8f0;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    transition: background 0.12s ease, color 0.12s ease, transform 0.1s ease;
    font-family: inherit;
}

.msg-ctx-item svg {
    width: 17px;
    height: 17px;
    color: #94a3b8;
    flex-shrink: 0;
    transition: color 0.12s ease;
}

.msg-ctx-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.msg-ctx-item:hover svg {
    color: #ff4d6d;
}

.msg-ctx-item.danger {
    color: #ff5c75;
}

.msg-ctx-item.danger svg {
    color: #ff5c75;
}

.msg-ctx-item.danger:hover {
    background: rgba(255, 77, 109, 0.15);
    color: #ff758f;
}

/* ==========================================
   АРХИВ
   ========================================== */
.archive-tab {
    display: none;
    align-items: center;
    gap: 8px;
    margin: 8px 12px 0;
    padding: 8px 12px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: #888;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.archive-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ddd;
}

.archive-tab svg {
    width: 16px;
    height: 16px;
}

.archive-count {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: #aaa;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

.chat-archive-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    transform: translateX(100%);
    visibility: hidden;
    z-index: 2;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1),
        visibility 0s linear 0.25s;
}

.chat-archive-view.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.create-branch-btn {
    margin: 8px 12px 12px;
    padding: 10px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    background: transparent;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.create-branch-btn:hover {
    color: var(--chat-accent);
    border-color: rgba(var(--chat-accent-rgb), 0.45);
    background: rgba(var(--chat-accent-rgb), 0.08);
}

.chat-toast {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(0, 0, 0, 0.7);
    color: #ddd;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    opacity: 0;
    transition: 0.25s ease;
    z-index: 70;
    pointer-events: none;
}

.chat-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================
   ЧАТ
   ========================================== */
.chat-panel-chat {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: rgba(14, 16, 23, 0.94);
    transform: translateX(100%);
    visibility: hidden;
    z-index: 2;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0s linear 0.25s;
}

.chat-panel-chat.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Поиск по сообщениям --- */
.msg-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    background: rgba(20, 23, 33, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
}

.msg-search-bar.show {
    max-height: 54px;
    opacity: 1;
    padding: 8px 14px;
}

.msg-search-bar input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px;
    padding: 8px 12px;
    color: #f1f3f7;
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.msg-search-bar input:focus {
    border-color: rgba(255, 77, 109, 0.5);
    box-shadow: 0 0 12px rgba(255, 77, 109, 0.15);
}

.msg-search-bar input::placeholder {
    color: #64748b;
}

.msg-search-count {
    font-size: 12px;
    color: #94a3b8;
    min-width: 30px;
    text-align: center;
    flex-shrink: 0;
}

.msg-search-nav,
.msg-search-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.msg-search-nav:hover,
.msg-search-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: translateY(-1px);
}

.msg-search-nav svg {
    width: 16px;
    height: 16px;
}

.message.search-match {
    background: rgba(255, 255, 255, 0.12);
}

.message.search-current {
    box-shadow: 0 0 0 2px #ff4d6d, 0 0 18px rgba(255, 77, 109, 0.4);
}

.chat-panel-all {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 75px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background:
        radial-gradient(circle at 10% 20%, rgba(255, 77, 109, 0.04), transparent 35%),
        radial-gradient(circle at 90% 75%, rgba(99, 102, 241, 0.05), transparent 40%),
        rgba(12, 14, 20, 0.65);
}

.date-divider {
    align-self: center;
    padding: 4px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(8px);
    font-size: 11.5px;
    font-weight: 500;
    color: #9aa2b2;
    margin: 8px 0;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 32px;
    text-align: center;
    color: #64748b;
}

.chat-empty-title {
    font-size: 15px;
    color: #94a3b8;
    font-weight: 500;
}

.chat-empty span {
    font-size: 13px;
    color: #64748b;
}

.chat-panel-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(16, 18, 27, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 5;
}

.chat-panel-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-panel-input textarea {
    flex: 1;
    resize: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.05);
    color: #f1f3f7;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    max-height: 95px;
    overflow-y: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.chat-panel-input textarea:focus {
    outline: none;
    border-color: rgba(255, 77, 109, 0.55);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 16px rgba(255, 77, 109, 0.18);
}

.chat-panel-input textarea::placeholder {
    color: #64748b;
}

.chat-panel-input textarea.scrollable {
    overflow-y: auto;
}

#panel-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff4d6d 0%, #d63a6a 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(255, 77, 109, 0.4);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#panel-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(255, 77, 109, 0.6);
}

#panel-send-btn:active {
    transform: scale(0.95);
}

#panel-send-btn svg {
    width: 19px;
    height: 19px;
}

.chat-scroll-down-btn {
    position: absolute;
    bottom: 100%;
    right: 14px;
    margin-bottom: 8px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(24, 27, 39, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-scroll-down-btn.show {
    opacity: 1;
    pointer-events: all;
}

.chat-scroll-down-btn:hover {
    background: rgba(36, 40, 58, 0.96);
    color: #fff;
    transform: translateY(-2px);
    border-color: rgba(255, 77, 109, 0.4);
}

.chat-scroll-down-btn svg {
    width: 18px;
    height: 18px;
}

/* ==========================================
   ПАНЕЛЬ ОТВЕТА
   ========================================== */
.reply-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.04);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.2s ease,
        padding 0.25s ease;
}

.reply-bar.visible {
    max-height: 60px;
    opacity: 1;
    padding-top: 8px;
    padding-bottom: 8px;
    border-radius: 12px;
}

.reply-bar-accent {
    width: 3px;
    min-height: 28px;
    border-radius: 2px;
    background: #ff4d6d;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.reply-bar-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.reply-bar-name {
    font-size: 12px;
    font-weight: 600;
    color: #ff758f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

.reply-bar-text {
    font-size: 13px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-bar-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.reply-bar-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ==========================================
   ПАНЕЛЬ РЕДАКТИРОВАНИЯ (как в Telegram)
   ========================================== */
.edit-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.04);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.2s ease,
        padding 0.25s ease;
}

.edit-bar.visible {
    max-height: 60px;
    opacity: 1;
    padding-top: 8px;
    padding-bottom: 8px;
    border-radius: 12px;
}

.edit-bar-icon {
    flex-shrink: 0;
    color: #ff4d6d;
    display: flex;
    align-items: center;
}

.edit-bar-icon svg {
    width: 18px;
    height: 18px;
}

.edit-bar-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.edit-bar-title {
    font-size: 12px;
    font-weight: 700;
    color: #ff4d6d;
    margin-bottom: 2px;
}

.edit-bar-text {
    font-size: 13px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edit-bar-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.edit-bar-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ==========================================
   СООБЩЕНИЯ
   ========================================== */
.message-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: msgFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.message-wrapper.other {
    justify-content: flex-start;
}

.message-wrapper.user {
    justify-content: flex-end;
}

.message-wrapper.user .avatar-link {
    display: none !important;
}

@keyframes msgFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-wrapper.fade-out {
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.25s ease;
}

.avatar-link {
    flex-shrink: 0;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #1b1e2c;
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.message {
    display: inline-block;
    width: fit-content;
    max-width: 82%;
    min-width: 48px;
    padding: 6px 10px 6px 12px;
    border-radius: 16px 16px 16px 4px;
    background: rgba(20, 24, 36, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    position: relative;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, filter 0.15s ease;
    cursor: pointer;
    box-sizing: border-box;
    touch-action: pan-y;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

.message-wrapper.user .message {
    border-radius: 16px 16px 4px 16px;
    background: linear-gradient(135deg, rgba(var(--chat-accent-rgb), 0.22) 0%, rgba(var(--chat-accent-rgb), 0.38) 100%);
    border: 1px solid rgba(var(--chat-accent-rgb), 0.35);
    box-shadow: 0 4px 18px rgba(var(--chat-accent-rgb), 0.16), 0 2px 8px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.message.touch-pressing {
    transform: scale(0.97);
    filter: brightness(1.22);
}

.message.highlight-message {
    animation: highlightPulse 2s ease;
}

@keyframes highlightPulse {

    0%,
    100% {
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
    }

    20%,
    80% {
        box-shadow: 0 0 0 2px var(--chat-accent), 0 0 24px rgba(var(--chat-accent-rgb), 0.45);
    }
}

.message-name {
    font-family: 'MyCustomFont', sans-serif;
    font-size: 11.5px;
    font-weight: 700;
    color: #94a3b8;
    margin-bottom: 3px;
    letter-spacing: 0.2px;
    display: block;
}

.message-wrapper.user .message-name {
    display: none !important;
}

.message-name .username-link {
    color: inherit;
    text-decoration: none;
}

.message-name .username-link:hover {
    text-decoration: underline;
}

/* Контент сообщения в стиле Telegram (текст и время в одну строку при коротком тексте) */
.message-content {
    display: inline;
    position: relative;
    line-height: 1.45;
    vertical-align: baseline;
}

.message-text,
.message p {
    font-family: 'MyCustomFont', sans-serif;
    font-size: 13.5px;
    color: #f1f5f9;
    line-height: 1.45;
    margin: 0;
    word-break: break-word;
    white-space: pre-wrap;
    letter-spacing: 0.1px;
    display: inline;
    vertical-align: baseline;
}

.message-time-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
    line-height: 1;
    user-select: none;
    pointer-events: none;
    position: relative;
    top: 5px;
    vertical-align: baseline;
    font-family: 'MyCustomFont', sans-serif;
}

.msg-edit-icon {
    width: 11px;
    height: 11px;
    object-fit: contain;
    opacity: 0.65;
    vertical-align: middle;
}

.message-time {
    font-size: 11px;
    color: inherit;
    font-weight: 500;
}

.message-link {
    color: var(--chat-accent);
    text-decoration: none;
    cursor: pointer;
}

.message-link:hover {
    text-decoration: underline;
}

/* Убраны отдельные кнопки редактирования и удаления слева от сообщений */
.msg-container {
    display: contents;
}

.delete-btn,
.edit-btn {
    display: none !important;
}

/* ==========================================
   РЕПЛАЙ В СООБЩЕНИИ (компактная ширина как в Telegram)
   ========================================== */
.reply-message {
    display: block;
    width: fit-content;
    max-width: 100%;
    min-width: 120px;
    padding: 5px 8px;
    margin-bottom: 5px;
    border-left: 3px solid var(--chat-accent);
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.reply-message:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

.reply-message .reply-name {
    font-size: 11.5px;
    font-weight: 700;
    color: #cbd5e1;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.reply-message .reply-time {
    font-size: 10px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
}

.reply-message .reply-text {
    font-size: 12px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.reply-message.reply-to-self {
    border-left-color: var(--chat-accent);
}

.reply-message.reply-to-self:hover {
    background: rgba(var(--chat-accent-rgb), 0.18);
}

.reply-message.reply-to-self .reply-name {
    color: var(--chat-accent);
}

/* Выравнивание времени у сообщений с ответом как в Telegram (в правый нижний угол) */
.message.has-reply,
.message:has(.reply-message) {
    min-width: 140px;
}

.message.has-reply .message-content,
.message:has(.reply-message) .message-content {
    display: block;
    overflow: hidden;
}

.message.has-reply .message-time-wrapper,
.message:has(.reply-message) .message-time-wrapper {
    float: right;
    margin-left: 8px;
    margin-top: 10px;
}

.message.has-reply .message-content::after,
.message:has(.reply-message) .message-content::after {
    content: "";
    display: table;
    clear: both;
}

/* Всплывающее сердечко при двойном тапе */
.quick-heart-pop {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.2);
    width: 44px;
    height: 44px;
    pointer-events: none;
    z-index: 20;
    animation: quickHeartPopAnim 0.85s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.quick-heart-pop svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 12px rgba(255, 51, 102, 0.75));
}

@keyframes quickHeartPopAnim {
    0% {
        transform: translate(-50%, -50%) scale(0.2);
        opacity: 0;
    }

    25% {
        transform: translate(-50%, -50%) scale(1.35);
        opacity: 1;
    }

    55% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -90%) scale(1.25);
        opacity: 0;
    }
}

/* ==========================================
   LOGIN HINT
   ========================================== */
.chat-login-hint {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #888;
    font-size: 15px;
}

.chat-login-hint a {
    color: var(--chat-accent);
    text-decoration: none;
}

.chat-login-hint a:hover {
    text-decoration: underline;
}

/* ==========================================
   RESIZE
   ========================================== */
.chat-panel-resize {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 10;
}

.chat-panel.side-left .chat-panel-resize {
    right: 0;
}

.chat-panel.side-right .chat-panel-resize {
    left: 0;
}

.chat-panel-resize:hover,
.chat-panel.resizing .chat-panel-resize {
    background: rgba(255, 255, 255, 0.25);
}

/* ==========================================
   SCROLLBAR
   ========================================== */
.panel-scroll::-webkit-scrollbar,
.chat-panel-all::-webkit-scrollbar {
    width: 6px;
}

.panel-scroll::-webkit-scrollbar-track,
.chat-panel-all::-webkit-scrollbar-track {
    background: transparent;
}

.panel-scroll::-webkit-scrollbar-thumb,
.chat-panel-all::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.panel-scroll::-webkit-scrollbar-thumb:hover,
.chat-panel-all::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}


/* ==========================================
   БЛЮР ПАНЕЛИ ПРИ МОДАЛКЕ
   ========================================== */
.chat-panel-body.blurred .pinned-row,
.chat-panel-body.blurred .chat-views,
.chat-panel-body.blurred .chat-panel-chat,
.chat-panel-body.blurred .chat-archive-view,
.chat-panel-body.blurred .chat-branch-view {
    filter: blur(5px) brightness(0.50);
    pointer-events: none;
    transition: filter 0.3s ease;
}

/* ==========================================
   МОДАЛКА СОЗДАНИЯ ВЕТКИ
   ========================================== */
.create-branch-modal {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.create-branch-modal.show {
    opacity: 1;
}

.modal-card {
    background: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 28px 24px 22px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.create-branch-modal.show .modal-card {
    transform: scale(1) translateY(0);
}

.modal-icon {
    font-size: 40px;
    text-align: center;
    margin-bottom: 8px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: #e0e0e0;
    text-align: center;
    margin-bottom: 4px;
}

.modal-subtitle {
    font-size: 13px;
    color: #666;
    text-align: center;
    margin-bottom: 20px;
}

.modal-field {
    margin-bottom: 16px;
}

.modal-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.modal-field input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.modal-field textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.modal-field textarea:focus {
    border-color: rgba(var(--chat-accent-rgb), 0.6);
}

.modal-field textarea::placeholder {
    color: #555;
}

.modal-field input:focus {
    border-color: rgba(var(--chat-accent-rgb), 0.6);
}

.modal-field input::placeholder {
    color: #555;
}

.modal-field input.shake {
    animation: inputShake 0.4s ease;
    border-color: #ff6b6b;
}

@keyframes inputShake {

    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-8px);
    }

    40% {
        transform: translateX(8px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

/* --- Эмодзи-пикер --- */
.emoji-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.emoji-option {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 10px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid transparent;
    transition: all 0.15s ease;
}

.emoji-option:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.15);
}

.emoji-option.selected {
    border-color: var(--chat-accent);
    background: rgba(var(--chat-accent-rgb), 0.18);
    transform: scale(1.1);
}

/* --- Кнопки --- */
.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.modal-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn.cancel {
    background: rgba(255, 255, 255, 0.06);
    color: #888;
}

.modal-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

.modal-btn.create {
    background: var(--chat-accent);
    color: #fff;
}

.modal-btn.create:hover {
    background: var(--chat-accent);
    filter: brightness(1.12);
    transform: scale(1.02);
}

.modal-btn.create:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================
    КОНФЕТТИ 🎉
========================================== */
.confetti-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 40;
}

.confetti-piece {
    position: absolute;
    top: -10px;
    opacity: 0;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }

    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateY(600px) rotate(720deg) scale(0.5);
    }
}


/* ==========================================
   ПОИСК ВЕТОК
   ========================================== */
.search-section-title {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--chat-accent);
}

.search-new-branch {
    opacity: 0.85;
}

.search-new-branch:hover {
    opacity: 1;
}

.join-branch-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: var(--chat-accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.join-branch-btn:hover {
    background: var(--chat-accent);
    filter: brightness(1.12);
    transform: scale(1.05);
}

.join-branch-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.privacy-toggle {
    display: flex;
    gap: 6px;
}

.privacy-btn {
    flex: 1;
    padding: 8px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: #888;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.privacy-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.privacy-btn.active {
    border-color: var(--chat-accent);
    color: #fff;
    background: rgba(var(--chat-accent-rgb), 0.15);
}

.privacy-hint {
    font-size: 11px;
    color: #555;
    margin-top: 4px;
    text-align: center;
}

/* Кнопка очистки поиска */
.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #888;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
}

.search-clear-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.search-clear-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ccc;
}

/* Контейнер поиска — нужен position: relative */
.chat-list-search {
    position: relative;
}

/* ==========================================
   УВЕДОМЛЕНИЯ 🔔
   ========================================== */
.notif-btn {
    position: relative;
}

.notif-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 14px;
    height: 14px;
    background: #FF6B6B;
    color: #fff;
    border-radius: 7px;
    font-size: 9px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    box-sizing: border-box;
}

.notif-badge.visible:not(:empty) {
    display: flex;
}

.notif-badge:empty,
.notif-badge:not(.visible) {
    display: none !important;
}

/* Тело панели — точка отсчёта для оверлея */
.chat-panel-body {
    position: relative;
}

/* Уведомления — выпадающая панель в стиле AnimeHub Glass */
.chat-notifications-view {
    position: absolute;
    top: 54px;
    right: 12px;
    width: 350px;
    max-height: 480px;
    background: rgba(16, 18, 27, 0.95);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 35;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-notifications-view.open {
    opacity: 1;
    transform: none;
    pointer-events: all;
}

/* ==========================================
   ИНФО О ВЕТКЕ
   ========================================== */
.chat-branch-view {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    transform: translateX(100%);
    visibility: hidden;
    z-index: 2;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.25s;
}

.chat-branch-view.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.branch-info-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 22px 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.branch-info-icon {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
}

.branch-info-name {
    font-size: 16px;
    font-weight: 700;
    color: #e0e0e0;
}

.branch-info-count {
    font-size: 13px;
    color: #888;
}

.branch-add-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 12px 4px;
    padding: 11px 14px;
    border: none;
    border-radius: 12px;
    background: rgba(var(--chat-accent-rgb), 0.12);
    color: var(--chat-accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.branch-add-row:hover {
    background: rgba(var(--chat-accent-rgb), 0.22);
}

.branch-members {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px;
}

.branch-member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 12px;
}

.branch-member-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.branch-member-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.branch-member-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: #2a2a2a;
}

.online-dot {
    position: absolute;
    right: 1px;
    bottom: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #6BCB77;
    border: 2px solid #1a1a1a;
}

.branch-member-info {
    flex: 1;
    min-width: 0;
}

.branch-member-name {
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
}

.branch-member-status {
    font-size: 12px;
    color: #666;
}

.branch-member-status.online {
    color: #FF7FA0;
}

.role-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.role-badge.owner {
    background: rgba(155, 120, 255, 0.15);
    color: #9B78FF;
}

.role-badge.admin {
    background: rgba(107, 203, 119, 0.15);
    color: #6BCB77;
}

/* ==========================================
   МОДАЛКА «ДОБАВИТЬ УЧАСТНИКОВ»
   ========================================== */
.add-members-modal {
    position: absolute;
    inset: 0;
    z-index: 55;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.add-members-modal.show {
    opacity: 1;
}

.am-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 380px;
    max-height: 85%;
    position: relative;
    padding-bottom: 70px;
    /* место под плавающую кнопку */
}

.am-selected-row {
    display: none;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 10px;
    flex-shrink: 0;
}

.am-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.06);
    padding: 4px 8px 4px 4px;
    border-radius: 20px;
    flex-shrink: 0;
}

.am-chip img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.am-chip span {
    font-size: 13px;
    color: #ccc;
    font-weight: 600;
}

.am-chip-x {
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #888;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 9px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.am-chip-x:hover {
    background: rgba(255, 80, 80, 0.3);
    color: #fff;
}

.am-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 9px 12px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.am-search svg {
    width: 15px;
    height: 15px;
    color: #666;
    flex-shrink: 0;
}

.am-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #e0e0e0;
    font-size: 13px;
}

.am-search input::placeholder {
    color: #666;
}

.am-friends {
    flex: 1;
    overflow-y: auto;
    min-height: 120px;
}

.am-friend {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.am-friend:hover {
    background: rgba(255, 255, 255, 0.05);
}

.am-friend.selected {
    background: rgba(107, 203, 119, 0.08);
}

.am-friend-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.am-friend-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: #2a2a2a;
}

.am-check {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #6BCB77;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #1e1e1e;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.15s ease;
}

.am-check svg {
    width: 10px;
    height: 10px;
}

.am-friend.selected .am-check {
    opacity: 1;
    transform: scale(1);
}

.am-friend-name {
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
}

.am-send-btn {
    position: absolute;
    right: 18px;
    bottom: 14px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: #6BCB77;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.6);
    pointer-events: none;
    transition: all 0.2s ease;
    box-shadow: 0 6px 18px rgba(107, 203, 119, 0.4);
}

.am-send-btn.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: all;
}

.am-send-btn:hover {
    background: #5bb868;
}

.am-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.am-send-btn svg {
    width: 22px;
    height: 22px;
}

.notif-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding: 7px;
    gap: 6px;
    flex-shrink: 0;
}

.notif-tab {
    flex: 1;
    padding: 8px 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #94a3b8;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.notif-tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.notif-tab.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(var(--chat-accent-rgb), 0.25) 0%, rgba(var(--chat-accent-rgb), 0.45) 100%);
    border-color: rgba(var(--chat-accent-rgb), 0.5);
    box-shadow: 0 2px 8px rgba(var(--chat-accent-rgb), 0.25);
}

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    background: linear-gradient(135deg, var(--chat-accent) 0%, #f72585 100%);
    color: #fff;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 700;
    padding: 0 4px;
    margin-left: 4px;
    box-shadow: 0 1px 6px rgba(var(--chat-accent-rgb), 0.4);
}

.tab-badge:empty {
    display: none;
}

.notif-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.notif-item {
    display: flex;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 8px;
    align-items: flex-start;
    transition: all 0.15s ease;
}

.notif-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.notif-item.unread {
    background: linear-gradient(135deg, rgba(var(--chat-accent-rgb), 0.12) 0%, rgba(var(--chat-accent-rgb), 0.04) 100%);
    border-left: 3px solid var(--chat-accent);
    border-color: rgba(var(--chat-accent-rgb), 0.35);
}

.notif-icon {
    font-size: 20px;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 2px;
}

.notif-body {
    flex: 1;
    min-width: 0;
}

.notif-text {
    font-size: 13px;
    color: #e2e8f0;
    line-height: 1.45;
}

.notif-time {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
}

.invite-actions {
    display: flex;
    gap: 8px;
    margin-top: 9px;
}

.invite-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.invite-btn.accept {
    background: linear-gradient(135deg, var(--chat-accent) 0%, #f72585 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--chat-accent-rgb), 0.35);
}

.invite-btn.accept:hover {
    filter: brightness(1.12);
    transform: translateY(-1px);
}

.invite-btn.decline {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.invite-btn.decline:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.invite-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================
   НАСТРОЙКИ ВЕТКИ — стиль Telegram
   ========================================== */
.branch-settings-modal {
    position: absolute;
    inset: 0;
    z-index: 55;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.branch-settings-modal.show {
    opacity: 1;
}

.branch-settings-modal .bs-card {
    width: 100%;
    max-width: 400px;
    max-height: 90%;
    overflow-y: auto;
    position: relative;
    padding: 10px 0 20px;
    border: none;
    box-shadow: none;
    transform: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bs-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 0 6px;
}

.bs-icon {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
}

.bs-name {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    text-align: center;
}

.bs-count {
    font-size: 13px;
    color: #888;
}

.tg-card {
    background: #292929;
    border-radius: 14px;
    padding: 12px 16px;
    margin-left: 15px;
    margin-right: 15px;
}

.tg-desc {
    font-size: 14px;
    color: #e0e0e0;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.tg-caption {
    font-size: 12px;
    color: #777;
    margin-top: 6px;
}

.tg-inline-btn {
    border: none;
    background: none;
    color: var(--chat-accent);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    margin-left: 4px;
}

.tg-inline-btn:hover {
    text-decoration: underline;
}

.tg-info {
    display: flex;
    gap: 18px;
}

.tg-info-row {
    flex: 1;
    min-width: 0;
}

.tg-info-value {
    font-size: 14px;
    color: #e0e0e0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tg-menu {
    padding: 4px 0;
    display: flex;
    flex-direction: column;
}

.tg-menu-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--chat-accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease;
}

.tg-menu-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tg-menu-row.danger {
    color: #ff6b6b;
}

.tg-menu-icon {
    font-size: 16px;
}

.bs-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #888;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.bs-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Истёкшее приглашение */
.notif-item.expired {
    opacity: 0.5;
}

.notif-sub {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}


/* ==========================================
   🎨 ТЕМЫ
   ========================================== */
.message-wrapper.user .message-name,
.message-wrapper.user .message-name a {
    color: var(--my-name-color, var(--chat-accent));
}

/* --- Пресеты фонов --- */
.chat-panel-all.chat-bg-sakura {
    background: radial-gradient(circle at 20% 20%, rgba(255, 143, 177, 0.14), transparent 45%), radial-gradient(circle at 80% 70%, rgba(255, 183, 197, 0.10), transparent 40%), #17131a;
}

.chat-panel-all.chat-bg-space {
    background: radial-gradient(circle at 30% 30%, rgba(120, 80, 220, 0.22), transparent 50%), radial-gradient(circle at 75% 75%, rgba(46, 89, 166, 0.18), transparent 45%), #0b0d1a;
}

.chat-panel-all.chat-bg-matrix {
    background: repeating-linear-gradient(0deg, rgba(107, 203, 119, 0.06) 0 1px, transparent 1px 24px), repeating-linear-gradient(90deg, rgba(107, 203, 119, 0.05) 0 1px, transparent 1px 24px), #0a120c;
}

.chat-panel-all.chat-bg-pixel {
    background: repeating-conic-gradient(#1c1c22 0% 25%, #17171d 0% 50%) 0 0 / 24px 24px;
}

.chat-panel-all.chat-bg-sunset {
    background: linear-gradient(180deg, rgba(255, 107, 107, 0.14), rgba(255, 140, 66, 0.08) 50%, transparent), #1a1214;
}

.chat-panel-all.chat-bg-ocean {
    background: linear-gradient(180deg, rgba(78, 205, 196, 0.12), rgba(91, 155, 213, 0.08) 60%, transparent), #0e161a;
}

.chat-panel-all.chat-bg-vapor {
    background: repeating-linear-gradient(45deg, rgba(199, 128, 250, 0.08) 0 12px, transparent 12px 24px), repeating-linear-gradient(-45deg, rgba(78, 205, 196, 0.07) 0 12px, transparent 12px 24px), #14121c;
}

.chat-panel-all.chat-bg-mono {
    background: #141414;
}

.chat-panel-all.chat-bg-gold {
    background: radial-gradient(rgba(255, 217, 61, 0.06) 1px, transparent 1.5px) 0 0 / 18px 18px, #16130c;
}

/* мини-плитки в модалке используют те же классы */
.tm-bg-tile {
    background: #1a1a1a;
}

.tm-bg-tile.chat-bg-sakura,
.tm-bg-tile.chat-bg-space,
.tm-bg-tile.chat-bg-matrix,
.tm-bg-tile.chat-bg-pixel,
.tm-bg-tile.chat-bg-sunset,
.tm-bg-tile.chat-bg-ocean,
.tm-bg-tile.chat-bg-vapor,
.tm-bg-tile.chat-bg-mono,
.tm-bg-tile.chat-bg-gold {
    background-position: center;
}

/* переопределяем фон плиток (они не .chat-panel-all) */
.tm-bg-tile.chat-bg-sakura {
    background: radial-gradient(circle at 30% 30%, rgba(255, 143, 177, 0.35), transparent 60%), #17131a;
}

.tm-bg-tile.chat-bg-space {
    background: radial-gradient(circle at 30% 30%, rgba(120, 80, 220, 0.5), transparent 60%), #0b0d1a;
}

.tm-bg-tile.chat-bg-matrix {
    background: repeating-linear-gradient(0deg, rgba(107, 203, 119, 0.2) 0 1px, transparent 1px 6px), #0a120c;
}

.tm-bg-tile.chat-bg-pixel {
    background: repeating-conic-gradient(#2a2a33 0% 25%, #1d1d24 0% 50%) 0 0 / 12px 12px;
}

.tm-bg-tile.chat-bg-sunset {
    background: linear-gradient(180deg, rgba(255, 107, 107, 0.4), rgba(255, 140, 66, 0.25)), #1a1214;
}

.tm-bg-tile.chat-bg-ocean {
    background: linear-gradient(180deg, rgba(78, 205, 196, 0.35), rgba(91, 155, 213, 0.25)), #0e161a;
}

.tm-bg-tile.chat-bg-vapor {
    background: repeating-linear-gradient(45deg, rgba(199, 128, 250, 0.3) 0 6px, transparent 6px 12px), #14121c;
}

.tm-bg-tile.chat-bg-mono {
    background: #141414;
}

.tm-bg-tile.chat-bg-gold {
    background: radial-gradient(rgba(255, 217, 61, 0.25) 1px, transparent 1.5px) 0 0 / 6px 6px, #16130c;
}

/* --- Модалка темы --- */
.theme-modal {
    position: absolute;
    inset: 0;
    z-index: 55;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.theme-modal.show {
    opacity: 1;
}

.tm-card {
    width: 100%;
    max-width: 400px;
    max-height: 90%;
    overflow-y: auto;
    position: relative;
    padding: 22px 20px 18px;
}

.tm-section {
    margin-bottom: 16px;
}

.tm-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 8px;
}

.tm-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tm-swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.tm-swatch:hover {
    transform: scale(1.15);
}

.tm-swatch.selected {
    border-color: #fff;
    transform: scale(1.1);
}

.tm-swatch.tm-custom {
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.tm-bg-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.tm-bg-tile {
    aspect-ratio: 1;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform 0.15s ease;
}

.tm-bg-tile:hover {
    transform: scale(1.08);
}

.tm-bg-tile.selected {
    border-color: var(--chat-accent);
    box-shadow: 0 0 10px rgba(var(--chat-accent-rgb), 0.4);
    transform: scale(1.05);
}

.tm-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 13px;
    color: #ccc;
}

.tm-row input[type="range"] {
    flex: 1;
    accent-color: var(--chat-accent);
}

.tm-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.tm-check input {
    accent-color: var(--chat-accent);
}

/* --- Компактный режим --- */
.chat-panel.compact .message {
    padding: 5px 10px;
}

.chat-panel.compact .message p {
    font-size: 13px;
}

.chat-panel.compact .message-name {
    font-size: 12px;
    margin-bottom: 2px;
}

.chat-panel.compact .avatar {
    width: 28px;
    height: 28px;
}

.chat-panel.compact .chat-list-item {
    padding: 6px 34px 6px 16px;
}

.chat-panel.compact .chat-list-avatar {
    width: 40px;
    height: 40px;
    font-size: 18px;
}

.chat-panel.no-anim *,
.chat-panel.no-anim *::before,
.chat-panel.no-anim *::after {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
}


/* ==========================================
   МОДАЛКИ РЕДАКТИРОВАНИЯ ВЕТКИ
   ========================================== */
.edit-branch-modal {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.edit-branch-modal.show {
    opacity: 1;
}

.edit-branch-modal .modal-card {
    background: #1e1e1e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 28px 24px 22px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.edit-branch-modal.show .modal-card {
    transform: scale(1) translateY(0);
}


/* ==========================================
   БЛЮР РОДИТЕЛЬСКОЙ МОДАЛКИ ПРИ РЕДАКТИРОВАНИИ
   ========================================== */
.branch-settings-modal.blurred-parent .bs-card {
    filter: blur(5px) brightness(0.50);
    pointer-events: none;
    transition: filter 0.3s ease;
}

/* ==========================================
   МОДАЛКИ РЕДАКТИРОВАНИЯ (поверх настроек)
   ========================================== */
.edit-branch-modal {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.edit-branch-modal.show {
    opacity: 1;
}

/* textarea в модалке */
.modal-field textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.modal-field textarea:focus {
    border-color: rgba(var(--chat-accent-rgb), 0.6);
}

.modal-field textarea::placeholder {
    color: #555;
}

/* ==========================================
   СПИСОК УЧАСТНИКОВ В НАСТРОЙКАХ ВЕТКИ
   ========================================== */
.tg-members-card {
    padding: 0 !important;
    overflow: hidden;
}

.tg-members-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #777;
    padding: 12px 16px 8px;
}

.tg-members-list {
    display: flex;
    flex-direction: column;
}

.tg-members-list.scrollable {
    max-height: 280px;
    overflow-y: auto;
}

.tg-member-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    transition: background 0.15s ease;
}

.tg-member-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.tg-member-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.tg-member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #2a2a2a;
}

.tg-member-info {
    flex: 1;
    min-width: 0;
}

.tg-member-name {
    font-size: 14px;
    font-weight: 600;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tg-member-status {
    font-size: 12px;
    color: #666;
}

.tg-member-status.online {
    color: #FF7FA0;
}

.tg-members-empty {
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: #555;
}

/* Скроллбар для списка участников */
.tg-members-list::-webkit-scrollbar {
    width: 4px;
}

.tg-members-list::-webkit-scrollbar-track {
    background: transparent;
}

.tg-members-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.tg-members-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Модалка редактирования */
.edit-branch-modal {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.edit-branch-modal.show {
    opacity: 1;
}

/* textarea в модалке */
.modal-field textarea {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.modal-field textarea:focus {
    border-color: rgba(91, 155, 213, 0.6);
}

.modal-field textarea::placeholder {
    color: #555;
}

/* ==========================================
   РЕАКЦИИ
   ========================================== */
.message-wrapper {
    position: relative;
}

/* SVG reactions */
.rx-svg {
    width: 17px;
    height: 17px;
    display: inline-block;
    vertical-align: middle;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.msg-ctx-emoji-btn .rx-svg {
    width: 20px;
    height: 20px;
}

/* панель реакций при наведении: видна 3 секунды, затем плавно скрывается */
.reaction-picker {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%) scale(0.9);
    display: flex;
    gap: 3px;
    background: rgba(20, 23, 34, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 4px 6px;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.message-wrapper.other:hover .reaction-picker {
    animation: rxPickerShow 3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.reaction-picker:hover {
    opacity: 1 !important;
    pointer-events: auto !important;
    animation: none !important;
    transform: translateY(-50%) scale(1) !important;
}

@keyframes rxPickerShow {
    0% {
        opacity: 0;
        transform: translateY(-50%) scale(0.9);
        pointer-events: none;
    }

    8% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
        pointer-events: auto;
    }

    82% {
        opacity: 1;
        transform: translateY(-50%) scale(1);
        pointer-events: auto;
    }

    100% {
        opacity: 0;
        transform: translateY(-50%) scale(0.95);
        pointer-events: none;
    }
}

.reaction-pick-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 3px 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease;
}

.reaction-pick-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.22);
}

/* пилюли под сообщением */
.reactions-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

/* Сообщение с реакциями: стиль Telegram (реакция слева снизу, время справа снизу) */
.message.has-reactions {
    min-width: 125px;
}

.message.has-reactions .message-content {
    display: block;
    margin-bottom: 2px;
}

.message.has-reactions .reactions-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    width: 100%;
    box-sizing: border-box;
}

.message.has-reactions .reactions-row .message-time-wrapper {
    margin-left: auto;
    padding-left: 6px;
    font-size: 11px;
    position: static;
    top: 0;
    align-self: center;
    display: inline-flex;
    line-height: 1;
}

.reaction-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px 3px 6px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.15s ease;
}

.reaction-pill:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.16);
    transform: scale(1.05);
}

.reaction-pill.mine {
    background: rgba(var(--chat-accent-rgb), 0.22);
    border-color: rgba(var(--chat-accent-rgb), 0.55);
    box-shadow: 0 0 10px rgba(var(--chat-accent-rgb), 0.25);
}

.reaction-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.reaction-count {
    font-size: 11.5px;
    font-weight: 700;
    color: #f1f5f9;
}

.reaction-avatars {
    display: flex;
}

.reaction-avatars img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-left: -6px;
    object-fit: cover;
    background: #1a1d28;
}

.reaction-avatars img:first-child {
    margin-left: 0;
}


/* ==========================================
   ПАНЕЛЬ УПОМИНАНИЙ @
   ========================================== */
.mention-panel {
    display: none;
    max-height: 180px;
    overflow-y: auto;
    scrollbar-width: none;
    /* ✅ без скроллбара */
    background: rgba(30, 30, 30, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    margin: 0 10px 6px;
}

.mention-panel::-webkit-scrollbar {
    display: none;
}

.mention-panel.show {
    display: block;
}

.mention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    cursor: pointer;
    font-size: 13px;
    color: #ddd;
}

.mention-item.selected {
    background: rgba(var(--chat-accent-rgb), 0.2);
}

.mention-item img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.mention-tag {
    color: var(--my-name-color, var(--chat-accent));
    font-weight: 600;
}

.mention-notif {
    cursor: pointer;
}

.mention-tag {
    color: var(--my-name-color, var(--chat-accent));
    font-weight: 600;
    text-decoration: none;
}

.mention-tag:hover {
    text-decoration: underline;
}


/* ==========================================
   МОДЕРАЦИЯ
   ========================================== */
.chat-drop-btn.has-notif::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4d4d;
    box-shadow: 0 0 0 2px rgba(15, 15, 15, .8);
}

.chat-drop-btn.has-unread::after {
    display: none !important;
}

.member-ban-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    opacity: .5;
    margin-left: 6px;
}

.member-ban-btn:hover {
    opacity: 1;
}

.mod-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mod-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, .05);
    border-radius: 10px;
    padding: 8px 10px;
}

.mod-row img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.mod-row-info {
    flex: 1;
    min-width: 0;
}

.mod-row-x {
    border: none;
    background: rgba(255, 80, 80, .15);
    color: #ff6b6b;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    flex-shrink: 0;
}

.mod-row-x:hover {
    background: rgba(255, 80, 80, .3);
}


.member-ban-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    opacity: .5;
    margin-left: 6px;
}

.member-ban-btn:hover {
    opacity: 1;
}

.mod-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mod-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, .05);
    border-radius: 10px;
    padding: 8px 10px;
}

.mod-row img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.mod-row-info {
    flex: 1;
    min-width: 0;
}

.mod-row-x {
    border: none;
    background: rgba(255, 80, 80, .15);
    color: #ff6b6b;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    flex-shrink: 0;
}

.mod-row-x:hover {
    background: rgba(255, 80, 80, .3);
}

.service-message {
    width: fit-content;
    margin: 10px auto;
    padding: 3px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .07);
    color: #9a9a9a;
    font-size: 12px;
    text-align: center;
}


/* ==========================================
   МОБИЛЬНЫЙ АДАПТИВ ЧАТА (screens <= 768px)
   ========================================== */
@media (max-width: 768px) {
    .chat-panel {
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
        height: 100vh !important;
        height: 100dvh !important;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .chat-drop-btn {
        width: 30px;
        height: 48px;
    }

    /* На телефонах скрываем настройки расположения панели (оверлей/закрепить/свободно) */
    #layout-btn,
    .header-icon-btn#layout-btn,
    #layout-popover,
    .layout-popover {
        display: none !important;
    }

    /* 🚀 ОПТИМИЗАЦИЯ ДЛЯ ТЕЛЕФОНОВ: убираем весь блюр боковой панели, списка чатов и сообщений */
    .chat-panel,
    .chat-panel *,
    .chat-overlay,
    .chat-panel-header,
    .chat-branch-header,
    .chat-panel-bottom,
    .chat-drop-btn,
    .notif-view,
    .msg-context-menu,
    .msg-context-menu *,
    .msg-ctx-backdrop,
    .message,
    .reply-message,
    .reaction-pill,
    .reactions-row,
    .reaction-picker {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .chat-panel,
    .chat-panel-all,
    .chat-list-scroll,
    .chat-rooms-container,
    .chat-list-view {
        background: #0c0e14 !important;
    }

    .chat-overlay {
        background: rgba(0, 0, 0, 0.85) !important;
    }

    .chat-panel-header,
    .chat-branch-header,
    .chat-panel-bottom {
        background: #0f121a !important;
        border-color: rgba(255, 255, 255, 0.08) !important;
    }

    .message-wrapper {
        animation: none !important;
        contain: none !important;
        content-visibility: visible !important;
        touch-action: pan-y;
    }

    .message-wrapper:not(.user) .message {
        background: #181b26 !important;
    }

    .reply-message {
        background: #202433 !important;
    }

    .msg-context-menu {
        z-index: 100002 !important;
        background: #141722 !important;
        border: 1px solid rgba(255, 255, 255, 0.14) !important;
    }

    .msg-ctx-backdrop {
        z-index: 100001 !important;
        background: rgba(0, 0, 0, 0.75) !important;
    }

    .message-wrapper.user .avatar-link {
        display: none !important;
    }

    .chat-panel-all,
    .chat-list-scroll {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
    }

    .msg-context-menu.show {
        pointer-events: auto !important;
    }

    .msg-ctx-backdrop.show {
        pointer-events: auto !important;
    }
}