:root {
    /* Sleek Deep Neutral Dark Mode */
    --bg-primary: #121212; 
    --bg-secondary: #1a1a1a; 
    --bg-tertiary: #0a0a0a; 
    --text-normal: #e0e0e0;
    --text-muted: #888888;
    --text-bright: #ffffff;
    --interactive-normal: #a0a0a0;
    --interactive-hover: #e0e0e0;
    --interactive-active: #ffffff;
    --background-modifier-hover: rgba(255, 255, 255, 0.05);
    --background-modifier-active: rgba(255, 255, 255, 0.1);
    
    --accent-1: #0059b3; /* Ekmand Deep Blue */
    --accent-2: #1e60cc; /* Ekmand True Blue */
    --accent-3: #21d28c; /* Ekmand Mint Green */
    --accent-4: #d1382b; /* Ekmand Red */
    --accent-hover: #004b99;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(18, 18, 18, 0.7);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    
    --font-primary: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f4f7fa; 
    --bg-tertiary: #e8eef3; 
    --text-normal: #334155;
    --text-muted: #4e637a;
    --text-bright: #0e1828;
    --interactive-normal: #4e637a;
    --interactive-hover: #0e1828;
    --interactive-active: #000000;
    --background-modifier-hover: rgba(0, 0, 0, 0.04);
    --background-modifier-active: rgba(0, 0, 0, 0.08);
    --accent-1: #0059b3;
    --accent-2: #1e60cc;
    --accent-3: #21d28c;
    --accent-4: #d1382b;
    --accent-hover: #004b99;
    
    --border-color: rgba(0, 0, 0, 0.06);
    --glass-bg: rgba(244, 247, 250, 0.7);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-normal);
    height: 100vh;
    overflow: hidden;
    display: flex;
    transition: background-color 0.3s ease, color 0.3s ease;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Buttons & Icons */
.primary-btn {
    background: var(--accent-1);
    color: white; border: none; padding: 10px 24px; border-radius: 8px;
    font-size: 1rem; font-weight: 500; cursor: pointer;
    box-shadow: 0 4px 14px 0 rgba(0, 89, 179, 0.4);
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    font-family: var(--font-primary);
}
.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 89, 179, 0.6);
}
.icon-btn {
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; padding: 6px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.icon-btn:hover { background: var(--background-modifier-hover); color: var(--text-bright); }

.hidden { display: none !important; }

/* Upload Overlay */
.upload-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.upload-overlay.active { opacity: 1; pointer-events: all; }
.upload-overlay.drag-over .upload-card {
    border-color: var(--accent-1); transform: scale(1.02);
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.2);
}
.upload-card {
    background-color: var(--bg-primary); padding: 3rem; border-radius: 20px;
    text-align: center; border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md); transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 480px; position: relative; overflow: hidden;
}
.upload-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 6px;
    background: linear-gradient(90deg, var(--accent-4) 0%, var(--accent-4) 33.33%, var(--accent-3) 33.33%, var(--accent-3) 66.66%, var(--accent-2) 66.66%, var(--accent-2) 100%);
}
.upload-logo-img {
    height: 48px; max-width: 100%; margin-bottom: 24px; object-fit: contain;
    animation: fadeInDown 0.6s ease;
}
[data-theme="light"] .upload-logo-img {
    content: url('https://cdn.serverse.org/images/black-logo.png');
}
.upload-card h1 { color: var(--text-bright); font-size: 1.75rem; margin-bottom: 0.5rem; font-weight: 700; letter-spacing: -0.02em; }
.upload-card p { color: var(--text-muted); margin-bottom: 2rem; font-size: 1rem; }

.site-footer {
    position: absolute; bottom: 32px; left: 0; right: 0;
    text-align: center; font-size: 0.85rem; color: var(--text-muted); line-height: 1.6;
}
.site-footer strong { color: var(--text-normal); font-weight: 600; }

/* App Layout */
.app-container { display: flex; width: 100%; height: 100%; }

/* Left Sidebar */
.sidebar {
    width: 260px; background-color: var(--bg-secondary);
    display: flex; flex-direction: column; flex-shrink: 0;
    border-right: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}
.server-header {
    height: 72px; padding: 0 16px; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.brand-logo {
    height: 40px; max-width: 100%; object-fit: contain; cursor: pointer; transition: all 0.2s;
}
[data-theme="light"] .brand-logo {
    content: url('https://cdn.serverse.org/images/black-logo.png');
}

.channel-list { flex: 1; overflow-y: auto; padding: 20px 12px; }
.channel-group { font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 0 12px; margin-bottom: 8px; margin-top: 20px; letter-spacing: 0.5px; text-transform: uppercase; }
.channel-list .channel-group:first-child { margin-top: 0; }
.channel {
    display: flex; align-items: center; padding: 8px 12px; margin-bottom: 4px;
    border-radius: 8px; color: var(--text-muted); cursor: pointer; font-size: 14px; font-weight: 500;
    transition: all 0.15s;
}
.channel:hover { background-color: var(--background-modifier-hover); color: var(--interactive-hover); }
.channel.active { background-color: var(--background-modifier-active); color: var(--interactive-active); }
.channel svg { margin-right: 12px; width: 18px; height: 18px; opacity: 0.8; }
.channel span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-controls {
    height: 64px; background-color: var(--bg-tertiary); padding: 0 16px;
    display: flex; align-items: center; flex-shrink: 0; border-top: 1px solid var(--border-color);
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 10px; margin-right: 12px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 14px; font-weight: 600; color: var(--text-bright); line-height: 1.3; }
.user-status { font-size: 12px; color: var(--text-muted); line-height: 1.3; }

/* Chat Area */
.chat-area { flex: 1; display: flex; flex-direction: column; min-width: 0; background-color: var(--bg-primary); position: relative; }
.chat-header {
    height: 56px; padding: 0 20px; display: flex; align-items: center;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--glass-bg); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    position: absolute; top:0; left:0; right:0; z-index: 10;
}
.chat-header svg { margin-right: 12px; color: var(--text-muted); }
.chat-header h3 { font-size: 16px; font-weight: 600; color: var(--text-bright); }

.messages-container {
    flex: 1; overflow-y: auto; padding: 76px 0 20px 0; display: flex; flex-direction: column; scroll-behavior: smooth;
}
.message-welcome { margin: 40px 24px 30px 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border-color); }
.welcome-icon {
    width: 72px; height: 72px; border-radius: 20px; background: linear-gradient(135deg, var(--bg-secondary), var(--bg-tertiary));
    display: flex; align-items: center; justify-content: center; font-size: 32px; margin-bottom: 20px;
    border: 1px solid var(--border-color); box-shadow: var(--shadow-md);
}
.message-welcome h1 { font-size: 36px; font-weight: 800; color: var(--text-bright); margin-bottom: 8px; letter-spacing: -0.03em; }
.message-welcome p { color: var(--text-muted); font-size: 16px; line-height: 1.5; }

.message { padding: 6px 24px 6px 72px; position: relative; margin-top: 20px; transition: background-color 0.2s; }
.message:hover { background-color: var(--background-modifier-hover); }
.message-avatar {
    position: absolute; left: 20px; top: 6px; width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 14px;
    cursor: pointer; box-shadow: 0 2px 4px rgba(0,0,0,0.1); transition: transform 0.2s;
}
.message-avatar:hover { transform: scale(1.05); }
.message-header { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 6px; }
.message-author { font-size: 15px; font-weight: 600; color: var(--text-bright); margin-bottom: 2px; cursor: pointer; }
.message-author:hover { text-decoration: underline; }
.message-timestamp { font-size: 10.5px; color: var(--text-muted); font-weight: 500; opacity: 0.65; }
.message-content { font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; color: var(--text-normal); }

.message.consecutive { margin-top: 0; padding-top: 4px; padding-bottom: 4px; }
.message.consecutive .message-avatar, .message.consecutive .message-header { display: none; }
.message.consecutive:hover .consecutive-timestamp { display: block; }
.consecutive-timestamp {
    display: none; position: absolute; left: 16px; width: 44px; font-size: 11px; font-weight: 500;
    color: var(--text-muted); text-align: right; line-height: 24px; user-select: none;
}

.message-content blockquote {
    border-left: 3px solid var(--accent-1);
    background-color: var(--background-modifier-hover);
    padding: 8px 12px; margin: 8px 0; border-radius: 0 8px 8px 0; color: var(--text-muted);
}

.chat-input-area { padding: 0 24px 24px 24px; background-color: var(--bg-primary); }
.chat-input-wrapper { background-color: var(--bg-secondary); border-radius: 12px; padding: 14px 20px; display: flex; align-items: center; border: 1px solid var(--border-color); box-shadow: 0 2px 10px rgba(0,0,0,0.02); }
.chat-input-wrapper input { width: 100%; background: transparent; border: none; color: var(--text-normal); font-size: 15px; font-family: var(--font-primary); outline: none; }
.chat-input-wrapper input::placeholder { color: var(--text-muted); }

/* Right Sidebar: Members */
.members-sidebar { width: 280px; background-color: var(--bg-secondary); display: flex; flex-direction: column; flex-shrink: 0; padding: 24px 16px; border-left: 1px solid var(--border-color); transition: background-color 0.3s ease; }
.members-group { font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 0 12px; margin-bottom: 12px; letter-spacing: 0.5px; text-transform: uppercase; }
.member-item { display: flex; align-items: center; padding: 8px 12px; border-radius: 8px; cursor: pointer; margin-bottom: 4px; transition: all 0.2s; }
.member-item:hover { background-color: var(--background-modifier-hover); }
.member-avatar { width: 34px; height: 34px; border-radius: 10px; margin-right: 14px; display: flex; align-items: center; justify-content: center; color: white; font-size: 12px; font-weight: 700; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.member-name { font-size: 15px; font-weight: 500; color: var(--text-normal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
#members-list { flex: 1; overflow-y: auto; padding-right: 4px; }
#members-list::-webkit-scrollbar { width: 4px; }

/* Settings Modal */
.modal-overlay {
    position: fixed; top:0; left:0; right:0; bottom:0;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000; opacity: 0; pointer-events: none; transition: all 0.2s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-card {
    background: var(--bg-primary); width: 440px; border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4); border: 1px solid var(--border-color);
    overflow: hidden; transform: scale(0.95) translateY(10px); transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-overlay.active .modal-card { transform: scale(1) translateY(0); }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 24px; border-bottom: 1px solid var(--border-color); background: var(--bg-secondary);
}
.modal-header h2 { font-size: 1.25rem; font-weight: 700; color: var(--text-bright); letter-spacing: -0.01em; }
.modal-body { padding: 24px; }
.setting-item { display: flex; justify-content: space-between; align-items: center; }
.setting-info h3 { font-size: 1.05rem; font-weight: 600; color: var(--text-bright); margin-bottom: 4px; }
.setting-info p { font-size: 0.9rem; color: var(--text-muted); }

.theme-toggle {
    display: flex; background: var(--bg-tertiary); border-radius: 10px; padding: 4px; border: 1px solid var(--border-color);
}
.theme-btn {
    background: transparent; border: none; padding: 8px 16px; border-radius: 8px;
    color: var(--text-muted); cursor: pointer; font-size: 0.9rem; font-weight: 600; transition: all 0.2s;
}
.theme-btn.active { background: var(--bg-primary); color: var(--text-bright); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* User Popout */
.user-popout {
    position: absolute; width: 300px; background-color: var(--bg-primary);
    border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    border: 1px solid var(--border-color); overflow: hidden;
    z-index: 1000; opacity: 0; pointer-events: none;
    transform: translateY(10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.user-popout.active { opacity: 1; pointer-events: all; transform: translateY(0) scale(1); }
.popout-header { height: 60px; background: linear-gradient(90deg, var(--accent-4) 0%, var(--accent-4) 33.33%, var(--accent-3) 33.33%, var(--accent-3) 66.66%, var(--accent-2) 66.66%, var(--accent-2) 100%); }
.popout-body { padding: 16px; padding-top: 40px; position: relative; }
.popout-avatar {
    width: 64px; height: 64px; border-radius: 16px; position: absolute;
    top: -32px; left: 16px; display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700; color: white;
    border: 6px solid var(--bg-primary); background-color: var(--accent-1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.popout-info h3 { font-size: 1.1rem; color: var(--text-bright); margin-bottom: 4px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popout-info p { font-size: 0.85rem; color: var(--text-muted); word-break: break-all; }
