/* 
  OkatomoNeo Chat Page Styles
  - Layout & Sidebar
  - Message Bubbles
  - User Interaction Elements
  - Profile Modal
*/

.chat-wrapper {
    display: flex;
    height: calc(100vh - 56px);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar-rooms {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-room-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-secondary);
    transition: all .15s;
    cursor: pointer;
    text-decoration: none;
}

.sidebar-room-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-room-item.active {
    background: var(--accent-glow);
    color: var(--text-primary);
    font-weight: 500;
}

.sidebar-hash {
    color: var(--text-muted);
    font-size: 16px;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.back-link {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color .15s;
}

.back-link:hover {
    color: var(--text-primary);
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Chat Header */
.chat-header {
    padding: 14px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chat-header-icon {
    font-size: 22px;
}

.chat-header-info h2 {
    font-size: 16px;
    font-weight: 600;
}

.chat-header-info p {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-header-members {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.btn-leave {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 101, 132, 0.1);
    border: 1px solid rgba(255, 101, 132, 0.3);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    margin-left: 12px;
}

.btn-leave:hover {
    background: var(--error);
    color: #fff;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    background-image: 
        radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.04) 1px, transparent 0);
    background-size: 32px 32px;
}

.message-group {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: message-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes message-pop {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-group.own {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
    align-self: flex-end;
}

.message-group.own .msg-avatar {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
}

.msg-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.message-group.own .msg-body {
    align-items: flex-end;
}

.msg-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
}

.message-group.own .msg-meta {
    flex-direction: row-reverse;
}

.msg-level-badge {
    background: rgba(108, 99, 255, 0.15);
    color: var(--accent-light);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 10px;
}

.msg-username {
    font-weight: 700;
    font-size: 12px;
    color: var(--text-secondary);
}

.message-group.own .msg-username {
    color: var(--accent-light);
}

.msg-bubble {
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.6;
    word-break: break-word;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.msg-bubble:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.message-group.other .msg-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}

.message-group.own .msg-bubble {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* Admin highlights (Orange) */
.message-group.admin-msg .msg-username {
    color: #f59e0b;
}

.message-group.admin-msg .msg-bubble {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}

.message-group.admin-msg.own .msg-bubble {
    background: #f59e0b;
    color: #fff;
    /* Admin specific fixed color is fine if orange is dark enough, but let's be safe */
    border: none;
}

.message-group.admin-msg .msg-bubble.whisper {
    border-color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.1) !important;
}

.message-group.admin-msg .whisper-label {
    color: #f59e0b;
}

/* Date divider */
.date-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.date-divider.admin-notice {
    color: #f59e0b;
    font-weight: 600;
    font-size: 12px;
}

.date-divider.admin-notice span {
    background: rgba(245, 158, 11, 0.05);
    padding: 2px 10px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
}

.date-divider::before,
.date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.date-divider.admin-notice::before,
.date-divider.admin-notice::after {
    background: #f59e0b;
    opacity: 0.3;
    height: 2px;
}

/* Empty messages */
.messages-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    gap: 8px;
}

.messages-empty .emoji {
    font-size: 48px;
}

.empty-state .emoji {
    font-size: 32px;
    margin-bottom: 8px;
}


/* Joined Rooms (Compact List) */
.joined-rooms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 40px;
}

.joined-room-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 20px 12px 24px; /* Increased left padding */
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all .2s;
    text-decoration: none;
    min-width: 200px;
    position: relative;
    overflow: hidden;
}

.joined-room-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent);
    opacity: 0.8;
}

/* 8 Color Variations for Joined Room Items */
.joined-rooms-list .joined-room-item:nth-child(8n+1)::before { background: linear-gradient(to bottom, #0ea5e9, #10b981); }
.joined-rooms-list .joined-room-item:nth-child(8n+2)::before { background: linear-gradient(to bottom, #f59e0b, #fbbf24); }
.joined-rooms-list .joined-room-item:nth-child(8n+3)::before { background: linear-gradient(to bottom, #8b5cf6, #ec4899); }
.joined-rooms-list .joined-room-item:nth-child(8n+4)::before { background: linear-gradient(to bottom, #06b6d4, #3b82f6); }
.joined-rooms-list .joined-room-item:nth-child(8n+5)::before { background: linear-gradient(to bottom, #f43f5e, #fb923c); }
.joined-rooms-list .joined-room-item:nth-child(8n+6)::before { background: linear-gradient(to bottom, #10b981, #14b8a6); }
.joined-rooms-list .joined-room-item:nth-child(8n+7)::before { background: linear-gradient(to bottom, #6366f1, #a855f7); }
.joined-rooms-list .joined-room-item:nth-child(8n+8)::before { background: linear-gradient(to bottom, #ef4444, #f59e0b); }


.joined-room-item:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.joined-room-info {
    flex: 1;
}

.joined-room-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.joined-room-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.joined-room-arrow {
    color: var(--text-muted);
    font-weight: 700;
}

/* Input Area */
.chat-input-area {
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    transition: border-color .2s, box-shadow .2s;
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.msg-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

.msg-textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.send-btn {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-text, #fff);
    flex-shrink: 0;
    transition: all .2s;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(108, 99, 255, 0.5);
}

.send-btn:disabled {
    opacity: 0.4;
}

.input-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    padding: 0 4px;
}

/* Connection indicator */
.conn-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background .3s;
    margin-left: auto;
}

.conn-status.connected {
    background: var(--success);
}

.conn-status.error {
    background: var(--accent2);
}

/* Whisper UI */
.whisper-status {
    background: rgba(var(--accent-rgb), 0.1);
    border-top: 1px solid var(--border);
    padding: 8px 24px;
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
}

.btn-clear-whisper {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}

.msg-bubble.whisper {
    background: rgba(var(--accent-rgb), 0.15) !important;
    border: 1px dashed var(--accent) !important;
}

.whisper-label {
    font-size: 10px;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 2px;
    display: block;
}

/* Participant List */
.sidebar-section {
    padding-top: 16px;
}

.sidebar-participants {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    border-top: 1px solid var(--border);
}

.participant-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-secondary);
    transition: all .15s;
    cursor: pointer;
}

.participant-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.participant-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
}

.participant-status {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    margin-left: auto;
}

/* Profile Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 28px;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}


/* Profile Modal container specific layout */
.modal-content .profile-card {
    margin: 0;
    width: 100%;
}

.modal-content .profile-modal-close {
    display: flex;
}

/* --- Chat Index Specific Styles --- */

/* Page Header & Grid */
/* Page Header & Grid */
/* Page header styles moved to global okatomo.css for consistency */


.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
    /*max-width: 900px;*/
    /* Optional: limit overall width for better readability on large screens */
}

@media (min-width: 768px) {
    .rooms-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.room-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all .2s;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.room-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    opacity: 0.8;
    transition: opacity .2s, height .2s;
}

.room-card:hover::before {
    opacity: 1;
    height: 4px;
}

/* 8 Color Variations for Room Cards */
.rooms-grid .room-card:nth-child(8n+1)::before { background: linear-gradient(135deg, #0ea5e9, #10b981); }
.rooms-grid .room-card:nth-child(8n+2)::before { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.rooms-grid .room-card:nth-child(8n+3)::before { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.rooms-grid .room-card:nth-child(8n+4)::before { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.rooms-grid .room-card:nth-child(8n+5)::before { background: linear-gradient(135deg, #f43f5e, #fb923c); }
.rooms-grid .room-card:nth-child(8n+6)::before { background: linear-gradient(135deg, #10b981, #14b8a6); }
.rooms-grid .room-card:nth-child(8n+7)::before { background: linear-gradient(135deg, #6366f1, #a855f7); }
.rooms-grid .room-card:nth-child(8n+8)::before { background: linear-gradient(135deg, #ef4444, #f59e0b); }

.room-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}


.room-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.room-hash {
    color: var(--text-muted);
    font-size: 18px;
}

.room-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 14px;
    min-height: 36px;
}

.room-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: auto;
}

.room-members {
    display: flex;
    align-items: center;
    gap: 4px;
}

.badge-joined {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(108, 99, 255, 0.15);
    color: var(--text-primary);
    border: 1px solid rgba(108, 99, 255, 0.3);
}

.btn-join {
    padding: 6px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    transition: all .2s;
}

.btn-join:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text, #fff);
}

.btn-open {
    display: block;
    text-align: center;
    margin-top: 12px;
    padding: 9px 0;
    background: var(--accent);
    color: var(--accent-text, #fff);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all .2s;
    box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-open:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(108, 99, 255, 0.4);
}

.participant-names {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 32px 0;
}

/* Modal - Custom Styles */
.okatomo-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.okatomo-modal-backdrop.open {
    display: flex;
}

.okatomo-modal-window {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    padding: 32px;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.okatomo-modal-window h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.okatomo-modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn-cancel {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    transition: all .2s;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancel:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

/* AI Bot Styles */
.badge-ai {
    display: inline-block;
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    color: #fff !important;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 800;
    margin-left: 4px;
    vertical-align: middle;
    text-transform: uppercase;
    box-shadow: 0 0 8px rgba(0, 210, 255, 0.4);
}

.message-group.other.bot .msg-bubble {
    background: rgba(0, 210, 255, 0.05);
    border-color: rgba(0, 210, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.1);
}

.message-group.other.bot .msg-avatar {
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}

.message-group.other.bot .msg-username {
    color: #00d2ff !important;
}

/* --- Mobile Responsive Fixes --- */
@media (max-width: 768px) {
    .chat-wrapper {
        position: relative;
    }

    .sidebar {
        position: fixed;
        top: 56px; /* Below topbar */
        left: -260px; /* Hide by default */
        bottom: 0;
        z-index: 1000;
        width: 260px;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
        background: var(--bg-secondary);
    }

    .sidebar.open {
        left: 0;
    }

    .chat-main {
        width: 100%;
        flex: none;
    }

    .chat-header {
        padding: 8px 12px;
        min-height: 48px;
    }

    .chat-header-icon {
        display: none; /* Hide icon on mobile to save space */
    }

    .chat-header-info h2 {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 150px;
    }

    .chat-header-info p {
        display: none; /* Hide description on mobile to save space */
    }

    .btn-leave {
        padding: 4px 8px;
        margin-left: 8px;
    }

    .btn-leave span {
        display: none; /* Hide "退室" text, show icon only */
    }

    .chat-header-members {
        font-size: 11px;
        gap: 4px;
    }

    .messages-container {
        padding: 16px;
    }

    .chat-input-area {
        padding: 12px 16px;
    }

    /* Toggle Button for Mobile */
    .sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: var(--bg-input);
        border: 1px solid var(--border);
        border-radius: 6px;
        color: var(--text-secondary);
        cursor: pointer;
        margin-right: 8px;
    }

    /* Overlay when sidebar is open */
    .chat-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
        backdrop-filter: blur(2px);
    }

    .chat-overlay.active {
        display: block;
    }
}

/* Ensure toggle is hidden on desktop */
.sidebar-toggle {
    display: none;
}


/* --- Fix for .content padding on chat page --- */
@media (max-width: 768px) {
    .chat-wrapper {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: auto;
        margin: 0 !important;
        padding: 0 !important;
        z-index: 50;
        background: var(--bg-primary);
    }

    .sidebar {
        position: fixed;
        top: 56px;
        left: -280px;
        bottom: 0;
        z-index: 101; /* Above overlay */
        width: 280px;
        border-right: 1px solid var(--border-light);
        backdrop-filter: blur(15px);
        background: rgba(var(--bg-secondary-rgb, 20, 20, 20), 0.85); /* Glassmorphism */
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), left 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
    }

    .sidebar.open {
        left: 0;
        transform: none;
    }

    .chat-main {
        height: 100%;
        width: 100%;
        flex: none;
        display: flex;
        flex-direction: column;
    }

    .chat-header {
        padding: 0 16px;
        height: 50px;
        min-height: 50px;
        display: flex;
        align-items: center;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
    }

    .chat-header-info {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
    }

    .chat-header-info h2 {
        font-size: 15px;
        font-weight: 700;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chat-header-icon, .chat-header-info p {
        display: none !important;
    }

    .sidebar-toggle {
        display: flex !important;
        background: transparent;
        border: none;
        color: var(--text-primary);
        padding: 8px;
        margin-left: -8px;
        margin-right: 4px;
        opacity: 0.8;
    }

    .btn-leave {
        background: rgba(255, 101, 132, 0.1);
        width: 34px;
        height: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        border-radius: 50%;
        margin-left: 8px;
    }

    .btn-leave span {
        display: none;
    }

    .chat-header-members {
        font-size: 12px;
        font-weight: 600;
        color: var(--text-muted);
        background: var(--bg-card);
        padding: 2px 8px;
        border-radius: 12px;
        margin-left: 8px;
    }

    .messages-container {
        padding: 12px 16px;
        gap: 12px;
    }

    .msg-body {
        max-width: 85%; /* Wider on mobile */
    }

    .chat-input-area {
        padding: 10px 16px env(safe-area-inset-bottom, 16px);
        background: var(--bg-secondary);
        border-top: 1px solid var(--border);
    }

    .chat-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(2px);
        z-index: 100;
        display: none;
        animation: fadeIn 0.3s ease;
    }

    .chat-overlay.active {
        display: block;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Join Announcement (Splash) - Centered & Large */
.join-announcement-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1500;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.join-announcement {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border: 2px solid var(--accent);
    padding: 40px 60px;
    border-radius: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    box-shadow: 0 30px 100px rgba(0,0,0,0.8), 0 0 60px var(--accent-glow);
    animation: join-splash 4.5s forwards cubic-bezier(0.19, 1, 0.22, 1);
    border-bottom: 4px solid var(--accent2);
}

@keyframes join-splash {
    0% { opacity: 0; transform: scale(0.5) translateY(100px); filter: brightness(4) blur(10px); }
    10% { opacity: 1; transform: scale(1.1) translateY(0); filter: brightness(1.5) blur(0); }
    15% { transform: scale(1); filter: brightness(1); }
    85% { opacity: 1; transform: translateY(0); filter: brightness(1) blur(0); }
    100% { opacity: 0; transform: translateY(-120px) scale(0.85); filter: blur(20px); }
}

.join-ann-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid #fff;
    object-fit: cover;
    box-shadow: 0 0 40px var(--accent-glow);
    background: var(--bg-card);
}

.join-ann-text {
    font-size: 28px;
    font-weight: 900;
    color: #fff;
    white-space: nowrap;
    letter-spacing: -0.01em;
    text-shadow: 0 4px 20px rgba(0,0,0,0.8);
    text-align: center;
}

.join-ann-text span {
    color: var(--accent-light);
    background: linear-gradient(to right, var(--accent-light), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: block;
    font-size: 36px;
    margin-bottom: 8px;
}
