.app-shell {
    display: grid;
    grid-template-columns: 270px 1fr 250px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-main);
}

/* Linke & Rechte Spalten */
.sidebar-left, .sidebar-right {
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 40;
}
.sidebar-left { border-right: 1px solid var(--border-color); }
.sidebar-right { border-left: 1px solid var(--border-color); }

.my-profile-card {
    padding: 14px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.02);
}
.my-profile-info { min-width: 0; flex: 1; }
.my-profile-name {
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.my-profile-status {
    font-size: 11.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
    flex-shrink: 0;
}
.status-dot.offline { background: var(--text-dim); }

.nav-section {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 13.5px;
    transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text-main); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 20%, transparent); color: #fff; font-weight: 600; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; }

.section-header {
    padding: 12px 14px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dm-list, .online-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dm-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 9px;
    width: 100%;
    text-align: left;
    transition: background 0.12s ease;
}
.dm-item:hover { background: var(--bg-elevated); }
.dm-item.active { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.dm-item-body { min-width: 0; flex: 1; }
.dm-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.dm-item-name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dm-item-preview {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.unread-badge {
    background: var(--danger);
    color: #fff;
    font-size: 10.5px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 99px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Rechte Online-Liste */
.online-search-wrap {
    padding: 10px 10px 6px;
}
.online-search-wrap .input {
    padding: 6px 10px;
    font-size: 12.5px;
}
.online-user-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    width: 100%;
    text-align: left;
    transition: background 0.12s ease;
}
.online-user-row:hover { background: var(--bg-elevated); }
.online-user-label {
    min-width: 0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    font-weight: 500;
}
.user-age { font-size: 11.5px; color: var(--text-muted); }

/* Mitte: Chat-Bereich */
.chat-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    background: var(--bg-main);
}
.chat-header {
    height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(17, 24, 39, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}
.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.chat-title {
    font-size: 15.5px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}
.mobile-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--bg-elevated);
    color: var(--text-main);
    font-size: 17px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.media-notice-bar {
    padding: 7px 16px;
    background: rgba(99, 102, 241, 0.1);
    border-bottom: 1px solid rgba(99, 102, 241, 0.25);
    font-size: 12px;
    color: #c7d2fe;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.system-banner {
    background: rgba(30, 41, 59, 0.55);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.msg-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 10px;
    position: relative;
    transition: background 0.1s ease;
}
.msg-row:hover { background: rgba(255, 255, 255, 0.03); }
.msg-body { min-width: 0; flex: 1; }
.msg-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}
.msg-author {
    font-weight: 700;
    cursor: pointer;
}
.msg-author:hover { text-decoration: underline; }
.msg-time { font-size: 11px; color: var(--text-dim); }
.msg-text {
    word-break: break-word;
    white-space: pre-wrap;
    color: var(--text-main);
    font-size: 13.8px;
}
.msg-actions {
    opacity: 0;
    transition: opacity 0.12s ease;
    display: flex;
    gap: 4px;
}
.msg-row:hover .msg-actions { opacity: 1; }
.msg-action-btn {
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-elevated);
}
.msg-action-btn:hover { color: #fca5a5; }

/* Medien in Nachrichten */
.msg-media-wrap {
    margin-top: 6px;
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    max-width: 380px;
}
.msg-media-img {
    max-width: 100%;
    max-height: 290px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    cursor: zoom-in;
    object-fit: contain;
    background: #050811;
}
.msg-media-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: #000;
}
.msg-media-caption {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.ephemeral-tag {
    background: rgba(245, 158, 11, 0.14);
    color: #fcd34d;
    border: 1px solid rgba(245, 158, 11, 0.35);
    padding: 1px 6px;
    border-radius: 99px;
    font-size: 10.5px;
}
.media-deleted-placeholder {
    margin-top: 6px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-dim);
    font-size: 12px;
    font-style: italic;
}

/* Composer */
.composer-area {
    border-top: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    padding: 10px 14px;
    flex-shrink: 0;
    position: relative;
}
.pending-upload {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 11px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    font-size: 12px;
}
.composer-form {
    display: flex;
    align-items: center;
    gap: 8px;
}
.composer-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}
.composer-icon-btn:hover { background: var(--bg-hover); }
.composer-input {
    flex: 1;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 9px 13px;
    color: var(--text-main);
    outline: none;
}
.composer-input:focus { border-color: var(--accent); }
.composer-hint {
    margin-top: 5px;
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.emoji-popover {
    position: absolute;
    bottom: 68px;
    right: 60px;
    width: 260px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
    z-index: 60;
}
.emoji-btn {
    font-size: 19px;
    padding: 5px;
    border-radius: 6px;
}
.emoji-btn:hover { background: var(--bg-hover); }

/* Mobile Bottom Bar & Backdrop */
.mobile-bottom-bar {
    display: none;
    height: 52px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    grid-template-columns: repeat(4, 1fr);
    flex-shrink: 0;
}
.mobile-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10.5px;
    color: var(--text-muted);
    position: relative;
}
.mobile-tab-btn.active { color: var(--accent); font-weight: 700; }
.mobile-tab-btn span.ico { font-size: 16px; }

.drawer-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 35;
}
.drawer-backdrop.open { display: block; }

/* Responsive Off-Canvas fuer Tablet & Smartphone */
@media (max-width: 960px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .mobile-toggle {
        display: inline-flex;
    }
    .mobile-bottom-bar {
        display: grid;
    }
    .sidebar-left, .sidebar-right {
        position: fixed;
        top: 0;
        bottom: 0;
        width: 82vw;
        max-width: 310px;
        transition: transform 0.22s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.65);
    }
    .sidebar-left {
        left: 0;
        transform: translateX(-105%);
    }
    .sidebar-left.open {
        transform: translateX(0);
    }
    .sidebar-right {
        right: 0;
        transform: translateX(105%);
    }
    .sidebar-right.open {
        transform: translateX(0);
    }
    .msg-actions { opacity: 1; }
    .composer-hint { display: none; }
}


/* Multi-Room Liste & Wasserzeichen */
.rooms-list {
    padding: 4px 8px 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 180px;
    overflow-y: auto;
}
.room-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
}
.room-btn:hover { background: var(--bg-elevated); color: var(--text-main); }
.room-btn.active {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    color: #fff;
    font-weight: 700;
}
.room-count-pill {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-muted);
    flex-shrink: 0;
}

.chat-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-watermark {
    position: absolute;
    inset: 0;
    pointer-events: none;
    user-select: none;
    z-index: 1;
    display: flex;
    flex-direction: column;
    padding: 24px 28px;
    overflow: hidden;
}
.chat-watermark.pos-bottom-right {
    align-items: flex-end;
    justify-content: flex-end;
    text-align: right;
}
.chat-watermark.pos-center {
    align-items: center;
    justify-content: center;
    text-align: center;
}
.chat-watermark-title {
    font-size: clamp(26px, 4.2vw, 52px);
    font-weight: 900;
    letter-spacing: 0.04em;
    color: #94a3b8;
    line-height: 1.05;
}
.chat-watermark-sub {
    font-size: clamp(11px, 1.3vw, 15px);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-top: 4px;
}
.chat-watermark-img {
    max-width: min(320px, 55%);
    max-height: 220px;
    object-fit: contain;
}
.messages-container {
    position: relative;
    z-index: 2;
}

.online-filter-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 0 10px 6px;
}
.online-filter-btn {
    padding: 5px 6px;
    border-radius: 7px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-main);
    border: 1px solid var(--border-color);
}
.online-filter-btn.active {
    background: var(--bg-elevated);
    color: var(--text-main);
    border-color: var(--accent);
}
