#tabChats {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
}

#tabChats.active {
    display: flex;
}

#tabChats .chat-container {
    height: 100%;
}

.room-pane .messages-container {
    padding: 0;
}

.rooms-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    margin: 0;
}

.room-messages {
    padding: 16px;
}

.rooms-sidebar {
    width: 320px;
    min-width: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.rooms-search-wrap {
    flex-shrink: 0;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.rooms-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 7px 12px;
}

.rooms-search-icon {
    flex-shrink: 0;
    opacity: 0.45;
    color: #fff;
}

#roomsSearchInput {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    min-width: 0;
}

#roomsSearchInput::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.rooms-search-clear {
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
    line-height: 1;
}

.rooms-search-clear:hover { color: #fff; }

.rooms-list {
    flex: 1;
    overflow-y: auto;
}

/* Mobile: поиск скрыт, выезжает свайпом вниз */
@media (max-width: 767px) {
    .rooms-search-wrap {
        max-height: 0;
        overflow: hidden;
        padding-top: 0;
        padding-bottom: 0;
        border-bottom: none;
        transition: max-height 0.22s ease, padding 0.22s ease;
    }

    .rooms-search-wrap.visible {
        max-height: 60px;
        padding-top: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .rooms-sidebar {
        width: 100%;
    }
}

.room-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 0.2s;
}

.room-card:hover {
    background: rgba(255, 255, 255, 0.08);
}

.room-card.active {
    background: rgba(0, 212, 255, 0.12);
}

.room-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-aqua-primary, #00d4ff);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.room-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.room-name {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.room-preview {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.room-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    gap: 4px;
}

.room-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.room-badge {
    background: var(--color-aqua-primary, #00d4ff);
    color: #000;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    padding: 2px 7px;
    min-width: 20px;
    text-align: center;
}

.room-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: rgba(0, 0, 0, 0.08);
}

.room-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.room-back-btn {
    display: none;
}

.room-title {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.room-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.room-unread-badge {
    background: var(--color-aqua-primary, #00d4ff);
    color: #000;
    font-size: 12px;
    font-weight: 700;
    border-radius: 10px;
    padding: 2px 8px;
    margin-left: auto;
}

.room-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.room-input-wrap {
    flex: 1;
    display: flex;
    align-items: flex-end;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    min-height: 40px;
    max-height: calc(12 * 1.4em + 20px);
    overflow: hidden;
    transition: border-color 0.2s;
}

.room-input-wrap:focus-within {
    border-color: var(--color-aqua-primary, #00d4ff);
}

.room-composer textarea {
    flex: 1;
    resize: none;
    border: none;
    background: none;
    color: #fff;
    padding: 10px 4px 10px 16px;
    font-size: 15px;
    line-height: 1.4;
    font-family: inherit;
    min-height: 40px;
    max-height: calc(12 * 1.4em + 20px);
    overflow-y: auto;
    box-sizing: border-box;
}

.room-composer textarea:focus {
    outline: none;
}

.room-composer textarea::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#roomSendBtn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    margin: 2px 4px 2px 0;
    padding: 0;
    border-radius: 50%;
    background: var(--color-aqua-primary, #00d4ff);
    color: #000;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.1s;
    align-self: flex-end;
}

#roomSendBtn:hover {
    opacity: 0.9;
}

#roomSendBtn:active {
    transform: scale(0.95);
}

/* ===== EMOJI PICKER ===== */

.emoji-toggle-btn {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    margin: 3px 0 3px 0;
    padding: 0;
    border: none;
    background: none;
    font-size: 20px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.55;
    transition: opacity 0.2s, background 0.2s;
    line-height: 1;
    align-self: flex-end;
}

.emoji-toggle-btn:hover,
.emoji-toggle-btn.active {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

.emoji-picker {
    flex-shrink: 0;
    background: #1e2a35;
    border-top: 1px solid rgba(255,255,255,0.12);
    display: flex;
    flex-direction: column;
}

@media (pointer: coarse) {
    .emoji-picker {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 200;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
    }

    .emoji-picker-open .room-composer {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
}

.emoji-picker__tabs {
    display: flex;
    gap: 4px;
    padding: 6px 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    overflow-x: auto;
    scrollbar-width: none;
}

.emoji-picker__tabs::-webkit-scrollbar { display: none; }

.emoji-tab {
    flex-shrink: 0;
    padding: 4px 8px;
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    opacity: 0.55;
    transition: opacity 0.15s, background 0.15s;
    line-height: 1;
}

.emoji-tab:hover { opacity: 0.85; }
.emoji-tab.active {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

.emoji-picker__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 8px;
    max-height: 180px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.emoji-btn {
    width: 36px;
    height: 36px;
    font-size: 20px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}

.emoji-btn:hover { background: rgba(255,255,255,0.12); }

#roomSendBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#roomSendBtn svg {
    pointer-events: none;
}

.room-start-btn {
    align-self: center;
    margin: 16px auto;
    background: var(--color-aqua-primary, #00d4ff);
    color: #000;
    border: none;
    border-radius: 24px;
    padding: 12px 32px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.3);
}

.room-start-btn:hover {
    opacity: 0.9;
}

.room-start-btn:active {
    transform: translateY(1px);
}

.room-read-only {
    padding: 10px 16px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.room-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.35);
    font-size: 15px;
}

.rooms-loading {
    text-align: center;
    padding: 24px;
    color: rgba(255, 255, 255, 0.4);
}

/* Mobile */
@media (max-width: 767px) {
    .rooms-sidebar {
        width: 100%;
    }

    .room-pane {
        display: none;
    }

    .rooms-layout--room-open .rooms-sidebar {
        display: none;
    }

    .rooms-layout--room-open .room-pane {
        display: flex;
        flex-direction: column;
    }
}

/* Author label in group/discussion messages */
.message-author {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    margin-bottom: 2px;
    padding-left: 4px;
    font-weight: 500;
}

/* Post discuss button */
.post-discuss-footer {
    margin-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 6px;
}

.post-discuss-btn {
    background: transparent;
    border: none;
    color: var(--color-aqua-primary, #00d4ff);
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
    font-family: inherit;
}

.post-discuss-btn:hover {
    text-decoration: underline;
}

.post-discuss-badge {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.post-discuss-unread {
    background: #f4a261;
    color: #000;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    margin-left: 4px;
}

/* Discussion pane */
.discussion-pane {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.discussion-parent-post {
    flex-shrink: 0;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

.discussion-parent-post::before {
    content: '\2190 Пост канала';
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 4px;
}

.discussion-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}