:root {
    /* Discord-inspired Dark with Glassmorphism */
    --bg-base: #1a1b1e;
    --bg-primary: rgba(30, 31, 34, 0.6);
    --bg-secondary: rgba(43, 45, 49, 0.7);
    --bg-tertiary: rgba(17, 18, 20, 0.8);
    
    --text-normal: #dbdee1;
    --text-muted: #949ba4;
    --text-header: #f2f3f5;
    
    --accent-primary: #5865F2;
    --accent-primary-hover: #4752C4;
    --accent-gradient: linear-gradient(135deg, #5865F2, #8b5cf6);
    
    --danger: #da373c;
    --danger-hover: #a12828;
    --success: #23a559;
    
    --divider: rgba(255, 255, 255, 0.06);
    --input-bg: rgba(30, 31, 34, 0.8);
    --message-hover: rgba(43, 45, 49, 0.4);
    --shadow-color: rgba(0,0,0,0.4);
    
    --glass-border: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="light"] {
    --bg-base: #e3e5e8;
    --bg-primary: rgba(255, 255, 255, 0.7);
    --bg-secondary: rgba(242, 243, 245, 0.8);
    --bg-tertiary: rgba(227, 229, 232, 0.9);
    
    --text-normal: #313338;
    --text-muted: #5c5e66;
    --text-header: #060607;
    
    --accent-primary: #5865F2;
    --accent-primary-hover: #4752C4;
    --accent-gradient: linear-gradient(135deg, #5865F2, #4facfe);
    
    --divider: rgba(0, 0, 0, 0.06);
    --input-bg: rgba(255, 255, 255, 0.9);
    --message-hover: rgba(0, 0, 0, 0.03);
    --shadow-color: rgba(0,0,0,0.1);
    
    --glass-border: 1px solid rgba(0, 0, 0, 0.05);
}

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

body, html {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-normal);
    height: 100%;
    width: 100%;
    overflow: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
    /* Optional sleek background effect */
    background-image: radial-gradient(circle at top right, rgba(88, 101, 242, 0.1), transparent 40%),
                      radial-gradient(circle at bottom left, rgba(139, 92, 246, 0.1), transparent 40%);
}

/* Glassmorphism Classes */
.glass-bg { backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); }
.glass-card {
    background: var(--bg-primary);
    backdrop-filter: blur(10px);
    border: var(--glass-border);
    box-shadow: 0 8px 32px var(--shadow-color);
}
.glass-panel {
    background: var(--bg-secondary);
    border-right: var(--glass-border);
}

/* Core Layout */
.hidden { display: none !important; }
.flex-center { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.app-container { height: 100vh; width: 100vw; display: flex; }
.screen { height: 100%; width: 100%; position: absolute; top:0; left:0; }
.relative { position: relative; }

/* Typography */
h1, h2, h3, h4 { color: var(--text-header); font-weight: 600; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin: 4px 0 20px; }
.muted { color: var(--text-muted); font-size: 0.8rem; }

/* Buttons */
.btn {
    font-family: inherit; font-weight: 600;
    border: none; border-radius: 8px;
    padding: 10px 16px; cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px; color: white;
}
.btn-primary { 
    background: var(--accent-gradient);
    box-shadow: 0 4px 15px rgba(88, 101, 242, 0.3);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(88, 101, 242, 0.4); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-secondary { background: rgba(79, 84, 92, 0.5); color: var(--text-normal); border: var(--glass-border); }
.btn-secondary:hover:not(:disabled) { background: rgba(79, 84, 92, 0.8); }
.btn-large { width: 100%; padding: 14px; font-size: 15px; }
.btn-small { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn {
    background: transparent; border: none; color: var(--text-muted);
    font-size: 18px; cursor: pointer; padding: 6px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.icon-btn:hover { color: var(--text-normal); background: rgba(255,255,255,0.1); }
.danger { color: var(--danger); }
.danger:hover { background: rgba(218, 55, 60, 0.1); }

/* Forms & Inputs */
.input-group { margin-bottom: 16px; width: 100%; display: flex; flex-direction: column; }
.input-group label {
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em;
}
.input-field {
    background: var(--input-bg); border: var(--glass-border);
    border-radius: 6px; padding: 12px; color: var(--text-normal);
    font-family: inherit; font-size: 15px; outline: none;
    transition: all 0.2s;
}
.input-field:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 2px rgba(88, 101, 242, 0.2); }

/* Cards & Modals */
.card { border-radius: 12px; padding: 32px; width: 100%; max-width: 440px; }

/* Auth Extras */
.divider { display: flex; align-items: center; margin: 20px 0; color: var(--text-muted); font-size: 12px; font-weight: 600; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--divider); margin: 0 10px; }
.auth-switch { text-align: center; margin-top: 15px; font-size: 14px; color: var(--text-muted); }
.auth-switch a { color: var(--accent-primary); text-decoration: none; font-weight: 600; margin-left: 5px; }
.auth-switch a:hover { text-decoration: underline; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; text-align: center; background: rgba(218, 55, 60, 0.1); padding: 8px; border-radius: 4px; border: 1px solid var(--danger); }

/* Dashboard Layout */
.dashboard-layout { display: flex; height: 100%; width: 100%; }
.sidebar { width: 260px; display: flex; flex-direction: column; flex-shrink: 0; z-index: 10; }
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-primary); }

.sidebar-header { height: 50px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: var(--glass-border); }
.room-list { flex: 1; overflow-y: auto; padding: 12px 8px; }
.room-item {
    display: flex; align-items: center; padding: 10px 12px;
    border-radius: 6px; cursor: pointer; color: var(--text-muted);
    font-weight: 500; transition: all 0.1s ease; margin-bottom: 2px;
}
.room-item:hover { background: rgba(255,255,255,0.05); color: var(--text-normal); }
.room-item.active { background: rgba(88, 101, 242, 0.15); color: var(--text-header); }
.room-item .hash { margin-right: 12px; font-size: 18px; color: var(--text-muted); opacity:0.7;}

/* User Panel */
.user-panel {
    background: var(--bg-tertiary); height: 56px; padding: 0 12px;
    display: flex; align-items: center; justify-content: space-between; border-top: var(--glass-border);
}
.user-info-section { display: flex; align-items: center; overflow: hidden; border-radius: 6px; padding: 4px; transition: background 0.2s;}
.user-info-section:hover { background: rgba(255,255,255,0.05); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; margin-right: 10px; flex-shrink: 0; }
.avatar.large { width: 64px; height: 64px; font-size: 24px; }
.user-details { display: flex; flex-direction: column; overflow: hidden; }
.user-details .username { font-size: 13px; font-weight: 600; color: var(--text-header); white-space: nowrap; text-overflow: ellipsis; overflow: hidden;}
.user-details .role { font-size: 11px; color: var(--text-muted); }
.user-actions { display: flex; gap: 4px; }

/* Room Area */
.room-header { height: 50px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: var(--glass-border); background: var(--bg-tertiary); backdrop-filter: blur(10px); z-index: 5; }
.room-title-group { display: flex; align-items: center; gap: 12px; padding: 4px; border-radius: 6px; transition: background 0.2s;}
.room-title-group:hover { background: rgba(255,255,255,0.05); }
.room-avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.1); display:flex; align-items:center; justify-content:center; font-weight:bold; color: var(--text-muted); }
.room-avatar.large { width: 56px; height: 56px; font-size:24px;}
.room-actions { display: flex; gap: 4px; }

/* Pinned Message Banner */
.pinned-banner { display: flex; align-items: center; padding: 10px 16px; background: rgba(88, 101, 242, 0.1); border-bottom: var(--glass-border); z-index: 4; cursor: pointer; transition: background 0.2s;}
.pinned-banner:hover { background: rgba(88, 101, 242, 0.15); }
.pin-icon { font-size: 14px; margin-right: 12px; }
.pin-content { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.pin-label { font-size: 11px; font-weight: 700; color: var(--accent-primary); letter-spacing: 0.05em; }
.pin-text { font-size: 13px; color: var(--text-normal); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }

/* Chat Messages */
.messages-container { flex: 1; overflow-y: auto; padding: 20px 0; display: flex; flex-direction: column; }
.message { padding: 4px 16px; display: flex; margin-top: 16px; position: relative; }
.message:hover { background-color: var(--message-hover); }
.message.edited .message-text { opacity: 0.9; }
.edit-tag { font-size: 10px; color: var(--text-muted); margin-left: 5px; user-select: none; }
.msg-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-gradient); margin-right: 16px; flex-shrink: 0; display:flex; align-items:center; justify-content:center; color:white; font-weight:bold; object-fit:cover; }
.message-content { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.message-header { display: flex; align-items: baseline; margin-bottom: 4px; }
.message-username { font-weight: 500; color: var(--text-header); margin-right: 8px; font-size: 15px;}
.message-timestamp { font-size: 11px; color: var(--text-muted); }
.message-text { font-size: 15px; line-height: 1.4; word-wrap: break-word; color: var(--text-normal);}
/* Message Actions Tooltip hovering */
.msg-actions-trigger { position: absolute; right: 16px; top: -10px; background: var(--bg-tertiary); border: var(--glass-border); border-radius: 4px; display:none; gap: 2px; padding: 2px; box-shadow: 0 2px 5px var(--shadow-color);}
.message:hover .msg-actions-trigger { display: flex; }
.msg-actions-trigger .icon-btn { font-size: 12px; padding: 4px 6px; }

/* Chat Input Area */
.chat-input-area { padding: 0 16px 24px; background: transparent; }
.chat-input-area .input-field { background: var(--bg-tertiary); border: var(--glass-border); border-radius: 20px; padding: 14px 20px; font-size: 15px; }

/* Context Menu */
.context-menu {
    position: absolute; z-index: 9999;
    min-width: 150px; padding: 6px; gap: 2px;
    display: flex; flex-direction: column;
}
.menu-item { background: transparent; border: none; padding: 8px 12px; text-align: left; color: var(--text-normal); font-size: 13px; font-family: inherit; cursor: pointer; border-radius: 4px; transition: background 0.1s; display: flex; align-items: center; gap: 8px;}
.menu-item:hover { background: rgba(255,255,255,0.05); }

/* Modals */
.modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { margin: 0; }
.modal-content { max-width: 440px; width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.invite-link-box { background: var(--input-bg); padding: 12px; border-radius: 6px; font-family: monospace; font-size: 12px; color: var(--accent-primary); word-break: break-all; cursor: pointer; border: var(--glass-border); transition: all 0.2s;}
.invite-link-box:hover { background: rgba(88, 101, 242, 0.1); }

/* Utils */
.logo-placeholder { font-size: 56px; margin-bottom: 20px; text-align: center; text-shadow: 0 4px 20px rgba(0,0,0,0.3); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInMsg { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.screen:not(.hidden) > .card, .screen:not(.hidden) > .main-area > .card { animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.modal:not(.hidden) .modal-content { animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.message { animation: slideInMsg 0.3s ease-out forwards; }
.context-menu:not(.hidden) { animation: fadeIn 0.15s ease-out forwards; }
.spinner { width: 40px; height: 40px; border: 3px solid rgba(88,101,242, 0.2); border-left-color: var(--accent-primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Custom Tags / Badges */
.user-tag {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 2px 6px; border-radius: 4px;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    vertical-align: middle; margin-left: 6px; margin-right: 4px;
    box-shadow: 0 2px 4px var(--shadow-color);
}
.tag-admin { background: rgba(88, 101, 242, 0.15); color: var(--accent-primary); border: 1px solid rgba(88, 101, 242, 0.3); }
.tag-owner { background: rgba(218, 55, 60, 0.15); color: var(--danger); border: 1px solid rgba(218, 55, 60, 0.3); }
.tag-member { background: rgba(148, 155, 164, 0.15); color: var(--text-muted); border: 1px solid rgba(148, 155, 164, 0.3); }

/* Clickable Profile Elements */
.clickable-profile { cursor: pointer; transition: opacity 0.2s; }
.clickable-profile:hover { opacity: 0.7; }
