:root {
    --bg-tertiary: #202225;
    --bg-secondary: #2f3136;
    --bg-primary: #36393f;
    --bg-modifier-selected: rgba(79,84,92,0.32);
    --header-secondary: #b9bbbe;
    --channel-textarea: #40444b;
    --header-primary: #fff;
    --text-normal: #dcddde;
    --text-muted: #72767d;
    --interactive-normal: #b9bbbe;
    --interactive-hover: #dcddde;
    --brand: #5865F2;
    --danger: #ed4245;
    --green: #3ba55c;
    --offline: #747f8d;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Whitney', 'Helvetica Neue', Helvetica, Arial, sans-serif; }
body { background-color: var(--bg-primary); color: var(--text-normal); height: 100vh; overflow: hidden; display: flex; }
img { object-fit: cover; }
::-webkit-scrollbar { width: 8px; height: 8px; background-color: #2e3338; }
::-webkit-scrollbar-thumb { background-color: #202225; border-radius: 4px; }

#alert-container {
    position: fixed;
    top: 20px;
    right: 20px;
    left: auto;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-alert {
    background: var(--brand);
    color: #fff;
    padding: 12px 20px;
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    font-weight: 500;
    min-width: 250px;

    animation: slideInRight 0.3s ease-out forwards;
    opacity: 1;
    transform: translateX(20px);
}

.custom-alert.error {
    background: var(--danger);
}

.custom-alert.fade-out {
    opacity: 0;
    transform: translateX(40px);
    transition: all 0.5s ease-out;
}

@keyframes slideInRight {
    to {
        transform: translateX(0);
    }
}

to { opacity: 1; transform: translateX(0); } 
#auth-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    background: #36393f;
    justify-content: center;
}

.auth-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.auth-box h2 {
    width: 100%;
    text-align: center;
}

.input-group label { display: block; color: var(--header-secondary); font-size: 11px; font-weight: bold; margin-bottom: 8px; text-transform: uppercase; }
.input-group input { width: 100%; background: var(--bg-tertiary); border: 1px solid rgba(0,0,0,0.3); padding: 10px; color: var(--text-normal); border-radius: 3px; outline: none; margin-bottom: 20px; }
.btn-brand { width: 100%; background-color: var(--brand); color: #fff; border: none; padding: 10px; border-radius: 3px; font-weight: bold; cursor: pointer; transition: background-color .2s; }
.btn-brand:hover { background-color: #4752c4; }

#app-screen { display: none; width: 100%; height: 100%; }
.servers-nav { width: 72px; background-color: var(--bg-tertiary); display: flex; flex-direction: column; align-items: center; padding-top: 12px; }
.server-icon { width: 48px; height: 48px; border-radius: 50%; background-color: var(--bg-primary); margin-bottom: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; color: var(--text-normal); }
.server-icon:hover, .server-icon.active { border-radius: 16px; background-color: var(--brand); color: #fff; }
.separator { width: 32px; height: 2px; background-color: var(--bg-primary); margin-bottom: 8px; }

.sidebar { width: 240px; background-color: var(--bg-secondary); display: flex; flex-direction: column; }
.sidebar-header { padding: 0 16px; height: 48px; display: flex; align-items: center; box-shadow: 0 1px 0 rgba(4,4,5,0.2); }
.search-bar { width: 100%; background: var(--bg-tertiary); border: none; padding: 6px; border-radius: 4px; color: var(--text-normal); font-size: 13px; text-align: center;}
.dm-list { flex: 1; overflow-y: auto; padding: 8px; }
.category-header { font-size: 11px; color: var(--interactive-normal); font-weight: bold; text-transform: uppercase; padding: 8px 8px 4px 18px; margin-top: 8px; display: flex; justify-content: space-between; align-items: center; }
.add-group-btn { cursor: pointer; font-size: 16px; color: var(--text-muted); }
.add-group-btn:hover { color: var(--text-normal); }

.nav-item { display: flex; align-items: center; padding: 10px; border-radius: 4px; cursor: pointer; color: var(--interactive-normal); position: relative; margin-bottom: 2px; }
.nav-item:hover { background-color: rgba(79,84,92,0.16); color: var(--interactive-hover); }
.nav-item.active { background-color: var(--bg-modifier-selected); color: #fff; }

.avatar-small { width: 32px; height: 32px; border-radius: 50%; background-color: var(--brand); margin-right: 12px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 500; font-size: 14px; flex-shrink: 0; overflow: hidden; }
.avatar-small img { width: 100%; height: 100%; }
.unread-badge { background-color: var(--danger); color: white; border-radius: 50%; font-size: 12px; font-weight: bold; padding: 0 6px; min-width: 16px; text-align: center; margin-left: auto; }
.badge-count { background-color: var(--danger); color: white; border-radius: 10px; font-size: 10px; font-weight: bold; padding: 2px 6px; margin-left: 5px; }

.user-area { background-color: #292b2f; padding: 10px; display: flex; align-items: center; }
.avatar-wrapper { position: relative; width: 32px; height: 32px; margin-right: 10px; }
.avatar-wrapper .avatar-small { margin-right: 0; width: 32px; height: 32px; }
.user-info { flex: 1; overflow: hidden; }
.user-status-text { font-size: 12px; color: var(--header-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--interactive-normal); border-radius: 4px; }
.settings-btn:hover { background-color: var(--bg-modifier-selected); color: var(--interactive-hover); }

.status-indicator { position: absolute; bottom: -2px; right: -2px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #292b2f; z-index: 10; }
.status-indicator.online { background-color: var(--green); }
.status-indicator.offline { background-color: var(--offline); }
.status-indicator-header { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-left: 8px; flex-shrink: 0;}
.status-indicator-header.online { background-color: var(--green); }
.status-indicator-header.offline { background-color: var(--offline); }

.main-area { flex: 1; background-color: var(--bg-primary); display: flex; flex-direction: column; }
.top-header { height: 48px; padding: 0 16px; box-shadow: 0 1px 0 rgba(4,4,5,0.2); display: flex; align-items: center; flex-shrink: 0; background-color: var(--bg-primary); }
.header-icon { color: var(--text-muted); margin-right: 8px; font-size: 24px; }
.header-title { font-weight: bold; color: var(--header-primary); margin-right: 8px;}
.divider { width: 1px; height: 24px; background: var(--channel-textarea); margin: 0 8px; }
.tab-btn { background: transparent; border: none; color: var(--interactive-normal); padding: 4px 8px; margin: 0 8px; font-weight: 500; cursor: pointer; border-radius: 4px; }
.tab-btn:hover { background-color: rgba(79,84,92,0.16); color: var(--interactive-hover); }
.tab-btn.active { background-color: rgba(79,84,92,0.32); color: #fff; }
.tab-btn.green { color: #fff; background-color: var(--green); }
.tab-btn.green.active { background-color: transparent; color: var(--green); }
.content-view { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.hidden { display: none !important; }
.news-frame { width: 100%; height: 100%; border: none; }

.friends-container { padding: 16px 20px; overflow-y: auto; flex: 1; }
.friend-row { display: flex; align-items: center; padding: 10px 10px; border-top: 1px solid var(--bg-modifier-selected); cursor: pointer; }
.friend-row:hover { background-color: rgba(79,84,92,0.1); border-radius: 8px; }
.action-icon { width: 36px; height: 36px; border-radius: 50%; background-color: var(--bg-secondary); display: flex; align-items: center; justify-content: center; margin-left: 10px; cursor: pointer; color: var(--interactive-normal); }
.action-icon:hover { color: #fff; }
.action-icon.accept:hover { color: var(--green); }
.action-icon.reject:hover { color: var(--danger); }

.add-friend-wrapper { padding: 20px 30px; border-bottom: 1px solid var(--bg-modifier-selected); }
.add-friend-title { color: var(--header-primary); font-weight: bold; margin-bottom: 8px; text-transform: uppercase; font-size: 16px;}
.add-friend-input-box { background-color: rgba(0,0,0,0.1); border: 1px solid #00000030; border-radius: 8px; padding: 0 12px; display: flex; align-items: center; margin-top: 16px; }
.add-friend-input { flex: 1; padding: 14px 0; background: transparent; border: none; color: var(--text-normal); outline: none; }
.btn-send-req { padding: 10px 16px; background: var(--brand); color: white; border: none; border-radius: 3px; font-size: 14px; cursor: pointer; margin-left: 10px; }

.messages-wrapper { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; }
.message-group { margin-bottom: 16px; display: flex; padding: 4px 8px; border-radius: 4px; }
.message-group:hover { background-color: rgba(4,4,5,0.02); }
.message-avatar { width: 40px; height: 40px; border-radius: 50%; background-color: var(--brand); margin-right: 16px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; cursor: pointer; overflow: hidden; }
.message-avatar img { width: 100%; height: 100%; }
.msg-header { display: flex; align-items: baseline; margin-bottom: 4px; }
.msg-username { color: #fff; font-weight: 500; margin-right: 8px; cursor: pointer; }
.msg-timestamp { font-size: 0.75rem; color: var(--text-muted); }
.msg-text { color: var(--text-normal); white-space: pre-wrap; word-break: break-word; line-height: 1.375rem; }
.msg-text:empty { display: none; }
.edited-label { font-size: 0.625rem; color: var(--text-muted); margin-left: 4px; }
.msg-system { display: flex; justify-content: center; align-items: center; margin: 10px 0; color: var(--text-muted); font-size: 14px; font-weight: 500; }
.msg-system-arrow { margin-right: 10px; color: var(--green); }
.msg-system-text { text-align: center; }

.chat-input-area { padding: 0 16px 24px; }
.chat-input-wrapper { background-color: var(--channel-textarea); border-radius: 0 0 8px 8px; padding: 0 16px; display: flex; align-items: center; border: none; }
.chat-input { width: 100%; background: transparent; border: none; color: var(--text-normal); outline: none; font-size: 1rem; padding: 12px 0; resize: none; height: 44px; line-height: 1.3; overflow-x: hidden; box-shadow: none; }
.chat-attach-btn { width: 24px; height: 24px; color: var(--interactive-normal); cursor: pointer; margin-right: 16px; display: flex; align-items: center; justify-content: center; }
.chat-attach-btn:hover { color: var(--text-normal); }
.msg-attachment { margin-top: 5px; max-width: 400px; border-radius: 4px; overflow: hidden; }
.msg-attachment img { max-width: 100%; max-height: 300px; display: block; border-radius: 4px; cursor: pointer; }
.msg-file-link { display: flex; align-items: center; background: #2f3136; padding: 10px; border-radius: 4px; color: var(--brand); text-decoration: none; width: fit-content; margin-top: 5px; border: 1px solid #202225; }

.context-menu { position: fixed; background: #18191c; border-radius: 4px; padding: 6px 8px; width: 180px; z-index: 9999; box-shadow: 0 8px 16px rgba(0,0,0,0.24); }
.context-item { color: var(--interactive-normal); padding: 8px; border-radius: 2px; cursor: pointer; font-size: 14px; }
.context-item:hover { background-color: var(--brand); color: #fff; }

.reply-bar { background-color: #2f3136; border-radius: 8px 8px 0 0; padding: 10px 16px; display: flex; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 14px; color: var(--text-muted); }
.reply-close-btn { cursor: pointer; color: var(--interactive-normal); }
.reply-close-btn:hover { color: var(--text-normal); }
.msg-reply-context { display: flex; align-items: center; margin-bottom: 4px; margin-left: 20px; font-size: 12px; color: var(--text-muted); opacity: 0.8; }
.reply-spine { width: 32px; height: 12px; border-left: 2px solid #4f545c; border-top: 2px solid #4f545c; border-top-left-radius: 6px; margin-right: 8px; margin-top: 14px; }
.reply-content { display: flex; align-items: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.reply-username { font-weight: bold; color: #fff; margin-right: 5px; }
.reply-text { color: var(--text-muted); }

.member-item { display: flex; align-items: center; padding: 8px; border-radius: 4px; cursor: pointer; color: var(--interactive-normal); }
.member-item:hover { background-color: var(--bg-modifier-selected); color: var(--interactive-hover); }

#settings-layer { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: var(--bg-primary); z-index: 5000; display: flex; }
.settings-sidebar { width: 218px; background: var(--bg-secondary); display: flex; flex-direction: column; padding: 60px 6px 60px 20px; align-items: flex-end; }
.settings-item { padding: 6px 10px; margin-bottom: 2px; border-radius: 4px; cursor: pointer; color: var(--interactive-normal); font-size: 14px; width: 100%; max-width: 180px; }
.settings-item:hover { background-color: rgba(79,84,92,0.16); color: var(--interactive-hover); }
.settings-item.active { background-color: rgba(79,84,92,0.32); color: #fff; }
.settings-content { flex: 1; background: var(--bg-primary); padding: 60px 40px; overflow-y: auto; max-width: 800px; position: relative; }
.close-settings-btn { position: absolute; top: 60px; right: 40px; display: flex; flex-direction: column; align-items: center; color: var(--header-secondary); cursor: pointer; border: 2px solid var(--header-secondary); border-radius: 50%; width: 36px; height: 36px; padding: 8px; box-sizing: content-box; }
.close-settings-btn:hover { color: var(--text-normal); border-color: var(--text-normal); }
.settings-card { background: #202225; border-radius: 8px; overflow: hidden; margin-top: 20px; }
.settings-card-header { height: 100px; background-color: var(--brand); }
.settings-user-preview { display: flex; align-items: center; padding: 16px; margin-top: -50px; }
.avatar-large { width: 80px; height: 80px; border-radius: 50%; border: 6px solid #202225; background-color: var(--brand); display: flex; align-items: center; justify-content: center; color: white; font-size: 30px; font-weight: bold; overflow: hidden; }
.avatar-large img { width: 100%; height: 100%; }
.settings-info-box { background: #2f3136; margin: 10px 16px 16px 16px; padding: 16px; border-radius: 8px; }
@keyframes pulse { 0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 165, 92, 0.7); } 70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(59, 165, 92, 0); } 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 165, 92, 0); } }
#video-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

#video-layer.minimized {
    width: 480px;
    height: 270px;
    top: auto;
    bottom: 140px;
    left: auto;
    right: 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    border: 1px solid var(--bg-tertiary);
}

#video-layer video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.video-controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    display: flex;
    justify-content: flex-end;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 60;
}

#video-layer:hover .video-controls-overlay {
    opacity: 1;
}

#active-call-bar {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    height: 40px;
    background: #202225;
    border-bottom: 1px solid #000;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#active-call-bar.hidden {
    display: none !important;
}

.messages-wrapper.call-active {
    padding-top: 50px !important;
}

#call-status-wrapper {
    display: flex;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-normal);
}

.call-controls {
    display: flex;
    gap: 15px;
}

.btn-call-control {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--interactive-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.btn-call-control:hover {
    color: #fff;
}

.btn-call-control.danger {
    color: var(--danger);
}
.btn-call-control.active {
    color: var(--green);
}

#remote-audio {
    display: none;
}
.btn-video-control{background:transparent;border:none;cursor:pointer;color:var(--interactive-normal);display:flex;align-items:center;gap:8px;font-size:13px;font-weight:600;padding:6px 10px;border-radius:6px;}
.btn-video-control:hover{color:#fff;background-color:rgba(79,84,92,0.16);}
