:root, [data-theme="dark"] {
    --bg-primary: #313338;
    --bg-secondary: #2b2d31;
    --bg-secondary-alt: #232428;
    --bg-tertiary: #1e1f22;
    --bg-modifier-hover: rgba(78, 80, 88, 0.3);
    --bg-modifier-selected: rgba(78, 80, 88, 0.6);
    --channeltextarea-bg: #383a40;
    --text-normal: #dbdee1;
    --text-muted: #949ba4;
    --header-primary: #f2f3f5;
    --header-secondary: #b5bac1;
    --brand: #5865f2;
    --brand-hover: #4752c4;
    --green: #23a55a;
    --yellow: #f0b232;
    --red: #f23f43;
    --border-subtle: rgba(255, 255, 255, 0.06);
    --scrollbar-thumb: #1a1b1e;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f2f3f5;
    --bg-secondary-alt: #ebedef;
    --bg-tertiary: #e3e5e8;
    --bg-modifier-hover: rgba(116, 127, 141, 0.12);
    --bg-modifier-selected: rgba(116, 127, 141, 0.24);
    --channeltextarea-bg: #ebedef;
    --text-normal: #313338;
    --text-muted: #5c5e66;
    --header-primary: #060607;
    --header-secondary: #4e5058;
    --brand: #5865f2;
    --brand-hover: #4752c4;
    --green: #23a55a;
    --yellow: #d99b18;
    --red: #da373c;
    --border-subtle: rgba(0, 0, 0, 0.08);
    --scrollbar-thumb: #c4c9ce;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'gg sans', 'Noto Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

body {
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--text-normal);
    user-select: none;
}

.hidden { display: none !important; }

/* ================= AUTH ================= */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, #404eed 0%, #23272a 70%);
}
.auth-card {
    background: #313338;
    padding: 32px;
    border-radius: 8px;
    width: 440px;
    max-width: 92vw;
    box-shadow: 0 8px 24px rgba(0,0,0,0.45);
    color: #dbdee1;
}
.auth-logo { text-align: center; margin-bottom: 12px; }
.auth-card h1 {
    font-size: 1.5rem;
    color: #f2f3f5;
    text-align: center;
    margin-bottom: 6px;
}
.auth-sub {
    text-align: center;
    color: #b5bac1;
    font-size: 0.95rem;
    margin-bottom: 20px;
}
.auth-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #b5bac1;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}
.auth-label span { color: #f23f43; }
.auth-card input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 18px;
    border-radius: 4px;
    border: none;
    background: #1e1f22;
    color: #f2f3f5;
    font-size: 1rem;
    outline: none;
}
.auth-card input:focus { box-shadow: 0 0 0 2px #5865f2; }
.auth-card button {
    width: 100%;
    padding: 11px;
    border-radius: 4px;
    border: none;
    background: #5865f2;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.auth-card button:hover { background: #4752c4; }
.auth-footer { margin-top: 14px; font-size: 0.85rem; color: #949ba4; }
.auth-footer a { color: #00a8fc; text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }
.error {
    background: rgba(242, 63, 67, 0.15);
    border: 1px solid #f23f43;
    color: #ff8a8c;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    margin-bottom: 14px;
}

/* ================= MAIN GRID ================= */
.app {
    display: grid;
    grid-template-columns: 72px var(--sidebar-w, 240px) 1fr 240px;
    height: 100vh;
    width: 100vw;
}
.app.no-members {
    grid-template-columns: 72px var(--sidebar-w, 240px) 1fr 0px;
}
.app.no-members .members { display: none; }

/* ================= 1. SERVER RAIL ================= */
.servers {
    background: var(--bg-tertiary);
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    overflow-y: auto;
}
.server-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.server-pill-wrap {
    position: relative;
    width: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pill {
    position: absolute;
    left: 0;
    width: 4px;
    height: 0;
    background: var(--header-primary);
    border-radius: 0 4px 4px 0;
    transition: height 0.18s ease;
}
.server-pill-wrap:hover .pill { height: 20px; }
.server-pill-wrap.active .pill { height: 40px; }

.server-icon, .add-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-primary);
    color: var(--text-normal);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.05rem;
    overflow: hidden;
    transition: border-radius 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}
.server-icon:hover, .server-icon.active, .server-pill-wrap.active .server-icon {
    border-radius: 16px;
    background: var(--brand);
    color: #fff;
}
.add-btn { color: var(--green); }
.add-btn:hover {
    border-radius: 16px;
    background: var(--green);
    color: #fff;
}
.rail-separator {
    width: 32px;
    height: 2px;
    background: var(--border-subtle);
    border-radius: 1px;
}

/* ================= 2. SIDEBAR ================= */
.sidebar {
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    position: relative;
    min-width: 0;
}
.sidebar-header {
    height: 48px;
    padding: 0 16px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--header-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--bg-tertiary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    cursor: pointer;
    flex-shrink: 0;
}
.sidebar-header:hover { background: var(--bg-modifier-hover); }

.dropdown-menu {
    position: absolute;
    top: 54px;
    left: 10px;
    right: 10px;
    background: #111214;
    border-radius: 6px;
    padding: 6px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.4);
    z-index: 50;
}
.dd-item {
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 4px;
    color: #b5bac1;
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.dd-item:hover { background: var(--brand); color: #fff; }
.dd-item.danger { color: #f23f43; }
.dd-item.danger:hover { background: #f23f43; color: #fff; }
.dd-sep { height: 1px; background: rgba(255,255,255,0.08); margin: 4px 0; }

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

.nav-row {
    width: 100%;
    padding: 10px 12px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin-bottom: 8px;
}
.nav-row:hover { background: var(--bg-modifier-hover); color: var(--text-normal); }
.nav-row.active { background: var(--bg-modifier-selected); color: var(--header-primary); }

.badge {
    margin-left: auto;
    background: var(--red);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px 4px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.section-add {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}
.section-add:hover { color: var(--header-primary); }

.channel-item, .dm-item {
    padding: 7px 10px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 500;
    position: relative;
}
.channel-item:hover, .dm-item:hover {
    background: var(--bg-modifier-hover);
    color: var(--text-normal);
}
.channel-item.active, .dm-item.active {
    background: var(--bg-modifier-selected);
    color: var(--header-primary);
}
.ch-symbol {
    font-size: 1.1rem;
    color: var(--text-muted);
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.ch-del-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0;
    padding: 2px 4px;
}
.channel-item:hover .ch-del-btn { opacity: 1; }
.ch-del-btn:hover { color: var(--red); }

.voice-sub-users {
    padding-left: 28px;
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.voice-sub-user {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: 4px;
}

.add-btn-sm {
    width: 100%;
    padding: 8px;
    margin-top: 12px;
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border-subtle);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
}
.add-btn-sm:hover {
    background: var(--bg-modifier-hover);
    color: var(--header-primary);
}

/* Voice Dock */
.voice-dock {
    background: var(--bg-secondary-alt);
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 10px;
}
.voice-dock-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.voice-status-ok {
    color: var(--green);
    font-size: 0.8rem;
    font-weight: 700;
}
.voice-channel-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.voice-peers-list {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.voice-peer-pill {
    font-size: 0.74rem;
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
    color: var(--text-normal);
}

/* User Bar */
.user-bar {
    height: 52px;
    padding: 0 8px;
    background: var(--bg-secondary-alt);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    flex-shrink: 0;
}
.user-profile-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    min-width: 0;
    flex: 1;
}
.user-profile-trigger:hover { background: var(--bg-modifier-hover); }

.avatar-wrap {
    position: relative;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}
.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.avatar-fallback-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.status-indicator {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary-alt);
}
.status-online { background: var(--green); }
.status-idle { background: var(--yellow); }
.status-dnd { background: var(--red); }
.status-offline { background: #80848e; }

.user-meta { min-width: 0; }
.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--header-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
}
.user-controls { display: flex; align-items: center; gap: 2px; }

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--header-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.icon-btn:hover { background: var(--bg-modifier-hover); color: var(--header-primary); }
.icon-btn.danger { color: var(--red); }
.icon-btn.active-toggle { color: var(--header-primary); background: var(--bg-modifier-selected); }

/* Status Popover */
.status-popover {
    position: absolute;
    bottom: 58px;
    left: 10px;
    width: 210px;
    background: #111214;
    border-radius: 6px;
    padding: 6px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.45);
    z-index: 60;
}
.status-opt {
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: none;
    color: #dbdee1;
    font-size: 0.86rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.status-opt:hover { background: var(--brand); color: #fff; }
.dot-inline { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-inline.online { background: var(--green); }
.dot-inline.idle { background: var(--yellow); }
.dot-inline.dnd { background: var(--red); }
.dot-inline.offline { background: #80848e; }

/* ================= 3. CHAT & FRIENDS MAIN ================= */
.chat {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    min-width: 0;
}
.chat-header {
    height: 48px;
    padding: 0 16px;
    border-bottom: 1px solid var(--bg-tertiary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.chat-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--header-primary);
    min-width: 0;
}
.header-hash { font-size: 1.25rem; color: var(--text-muted); }
.chat-topic {
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--text-muted);
    border-left: 1px solid var(--border-subtle);
    padding-left: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friends-top-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    border-left: 1px solid var(--border-subtle);
    padding-left: 12px;
}
.ftab {
    padding: 4px 10px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
}
.ftab:hover { background: var(--bg-modifier-hover); color: var(--text-normal); }
.ftab.active { background: var(--bg-modifier-selected); color: var(--header-primary); }
.ftab.add-friend-pill {
    background: var(--green);
    color: #fff;
    font-weight: 600;
}
.ftab.add-friend-pill.active {
    background: transparent;
    color: var(--green);
}

.chat-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding: 0 8px;
    height: 26px;
}
.search-box input {
    background: transparent;
    border: none;
    color: var(--text-normal);
    font-size: 0.82rem;
    width: 130px;
    outline: none;
}

/* Friends View */
.friends-view {
    flex: 1;
    overflow-y: auto;
    padding: 20px 28px;
}
.friends-add-panel {
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 20px;
    margin-bottom: 20px;
}
.friends-add-panel h3 {
    font-size: 0.95rem;
    color: var(--header-primary);
    margin-bottom: 6px;
}
.friends-add-panel p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.add-friend-input-row {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 6px 10px 6px 14px;
    max-width: 640px;
}
.add-friend-input-row:focus-within { border-color: #00a8fc; }
.add-friend-input-row input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--header-primary);
    font-size: 0.95rem;
    outline: none;
}
.add-friend-input-row button {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.add-friend-input-row button:hover { background: var(--brand-hover); }
.feedback-msg { font-size: 0.82rem; margin-top: 8px; color: var(--green); }
.feedback-msg.err { color: var(--red); }

.friends-section-label {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 12px;
    letter-spacing: 0.03em;
}
.friend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-top: 1px solid var(--border-subtle);
    border-radius: 8px;
    cursor: pointer;
}
.friend-row:hover { background: var(--bg-modifier-hover); }
.friend-row-info { display: flex; align-items: center; gap: 12px; }
.friend-row-actions { display: flex; gap: 8px; }
.circle-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--header-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
}
.circle-action-btn:hover { color: var(--header-primary); background: var(--bg-tertiary); }
.circle-action-btn.accept:hover { color: var(--green); }
.circle-action-btn.danger:hover { color: var(--red); }

/* Chat View */
.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    user-select: text;
}
.channel-welcome {
    padding: 16px 16px 20px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}
.welcome-badge {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-modifier-selected);
    color: var(--header-primary);
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.channel-welcome h1 {
    font-size: 1.75rem;
    color: var(--header-primary);
    margin-bottom: 6px;
}
.channel-welcome p { color: var(--text-muted); font-size: 0.92rem; }

.message {
    display: flex;
    gap: 16px;
    padding: 6px 16px;
    margin-top: 8px;
    position: relative;
}
.message:hover { background: rgba(4, 4, 5, 0.07); }
.msg-avatar-wrap { width: 40px; height: 40px; flex-shrink: 0; margin-top: 2px; }
.msg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}
.msg-body { flex: 1; min-width: 0; }
.reply-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    padding-left: 8px;
    border-left: 2px solid var(--text-muted);
}
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-user {
    color: var(--header-primary);
    font-weight: 600;
    font-size: 0.98rem;
}
.msg-time {
    color: var(--text-muted);
    font-size: 0.72rem;
}
.msg-edited {
    color: var(--text-muted);
    font-size: 0.68rem;
}
.msg-content {
    margin-top: 3px;
    line-height: 1.375;
    word-wrap: break-word;
    white-space: pre-wrap;
    color: var(--text-normal);
    font-size: 0.96rem;
}
.msg-attachment img {
    max-width: 360px;
    max-height: 280px;
    border-radius: 8px;
    margin-top: 6px;
    display: block;
}
.msg-attachment a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    color: #00a8fc;
    text-decoration: none;
    font-size: 0.88rem;
}

.msg-actions {
    position: absolute;
    top: -14px;
    right: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 2px;
    display: none;
    gap: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.message:hover .msg-actions { display: flex; }
.msg-actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--header-secondary);
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 0.9rem;
}
.msg-actions button:hover {
    background: var(--bg-modifier-hover);
    color: var(--header-primary);
}

.reactions { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.reaction {
    background: var(--bg-secondary);
    border: 1px solid transparent;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-normal);
}
.reaction:hover { border-color: var(--text-muted); }
.reaction.mine {
    background: rgba(88, 101, 242, 0.2);
    border-color: var(--brand);
    color: var(--header-primary);
}

.typing-bar {
    height: 20px;
    padding: 0 18px;
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 500;
}

.message-form {
    padding: 0 16px 18px;
    position: relative;
}
.reply-banner, .attachment-preview {
    background: var(--bg-secondary);
    padding: 6px 12px;
    border-radius: 8px 8px 0 0;
    font-size: 0.82rem;
    color: var(--header-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}
.reply-banner button, .attachment-preview button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
}
.message-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--channeltextarea-bg);
    border-radius: 8px;
    padding: 4px 10px;
}
.attach-circle-btn, .input-icon-btn {
    background: none;
    border: none;
    color: var(--header-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 50%;
    font-size: 1.2rem;
}
.attach-circle-btn:hover, .input-icon-btn:hover { color: var(--header-primary); }
#message-input {
    flex: 1;
    padding: 8px 4px;
    background: transparent;
    border: none;
    color: var(--text-normal);
    font-size: 0.96rem;
    outline: none;
}
.send-btn {
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.send-btn:hover { background: var(--brand-hover); }

.emoji-picker {
    position: absolute;
    bottom: 72px;
    right: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 40;
}
.emoji-picker span {
    font-size: 1.35rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    text-align: center;
}
.emoji-picker span:hover { background: var(--bg-modifier-hover); }

/* ================= 4. MEMBERS SIDEBAR ================= */
.members {
    background: var(--bg-secondary);
    padding: 16px 8px;
    overflow-y: auto;
}
.members-group-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 8px 8px 4px;
    letter-spacing: 0.03em;
}
.member-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
}
.member-row:hover { background: var(--bg-modifier-hover); }
.member-row.offline { opacity: 0.48; }
.member-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--header-secondary);
}
.member-bio {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ================= MODALS ================= */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.discord-modal {
    background: var(--bg-primary);
    width: 440px;
    max-width: 92vw;
    border-radius: 8px;
    padding: 24px 24px 0;
    box-shadow: 0 12px 32px rgba(0,0,0,0.5);
    overflow: hidden;
}
.discord-modal h2 {
    color: var(--header-primary);
    font-size: 1.35rem;
    text-align: center;
    margin-bottom: 8px;
}
.modal-sub {
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
    margin-bottom: 18px;
}
.discord-modal label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--header-secondary);
    margin: 12px 0 6px;
}
.discord-modal input[type="text"],
.discord-modal input:not([type]) {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 4px;
    color: var(--header-primary);
    font-size: 0.95rem;
    outline: none;
}
.channel-type-grid { display: flex; flex-direction: column; gap: 8px; }
.channel-type-card {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    cursor: pointer;
    margin: 0 !important;
}
.channel-type-card.active { background: var(--bg-modifier-selected); }
.ct-icon { font-size: 1.3rem; color: var(--text-muted); width: 24px; text-align: center; }
.ct-title { font-size: 0.95rem; font-weight: 600; color: var(--header-primary); }
.ct-desc { font-size: 0.78rem; color: var(--text-muted); }

.channel-name-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: 4px;
    padding-left: 10px;
}
.channel-name-input-wrap span { color: var(--text-muted); font-weight: 700; }

.modal-footer {
    margin: 22px -24px 0;
    padding: 14px 24px;
    background: var(--bg-secondary);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}
.btn-link {
    background: none;
    border: none;
    color: var(--header-primary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 8px 14px;
}
.btn-link:hover { text-decoration: underline; }
.btn-primary {
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 9px 18px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary:hover { background: var(--brand-hover); }

/* Full Settings Overlay */
.settings-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    width: 100vw;
    height: 100vh;
    background: var(--bg-primary);
}
.settings-nav {
    background: var(--bg-secondary);
    padding: 48px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.settings-cat {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 6px 10px;
}
.snav-item {
    padding: 8px 10px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--header-secondary);
    text-align: left;
    font-size: 0.92rem;
    cursor: pointer;
    text-decoration: none;
}
.snav-item:hover { background: var(--bg-modifier-hover); color: var(--header-primary); }
.snav-item.active { background: var(--bg-modifier-selected); color: var(--header-primary); }
.snav-item.danger { color: var(--red); }

.settings-content {
    padding: 48px 40px;
    max-width: 680px;
    position: relative;
    overflow-y: auto;
}
.settings-content h2 { color: var(--header-primary); margin-bottom: 20px; }
.settings-content label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--header-secondary);
    margin: 16px 0 6px;
}
.settings-content input, .settings-content textarea {
    width: 100%;
    padding: 10px;
    border-radius: 4px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--header-primary);
    font-size: 0.95rem;
}
.settings-esc {
    position: fixed;
    top: 36px;
    right: 48px;
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}
.settings-esc span {
    width: 34px;
    height: 34px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.settings-esc:hover { color: var(--header-primary); }

.profile-preview-card {
    background: var(--bg-tertiary);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}
.profile-banner { height: 76px; background: var(--brand); }
.profile-card-body {
    padding: 0 16px 16px;
    display: flex;
    align-items: flex-end;
    gap: 14px;
    margin-top: -32px;
}
.profile-avatar-edit {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 5px solid var(--bg-tertiary);
    background: var(--brand);
    overflow: hidden;
}
.profile-avatar-edit img { width: 100%; height: 100%; object-fit: cover; }
.avatar-upload-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    cursor: pointer;
    margin: 0 !important;
}
.profile-avatar-edit:hover .avatar-upload-overlay { opacity: 1; }
.profile-card-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--header-primary);
    padding-bottom: 6px;
}
.theme-cards { display: flex; gap: 12px; }
.theme-choice {
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 8px;
    color: var(--header-primary);
    cursor: pointer;
    font-weight: 600;
}
.theme-choice:hover { border-color: var(--brand); }

/* ================= ANIMATIONS: MUTE/DEAFEN & TYPING ================= */
@keyframes btnPop {
    0% { transform: scale(1); }
    40% { transform: scale(0.82) rotate(-8deg); }
    75% { transform: scale(1.12) rotate(4deg); }
    100% { transform: scale(1) rotate(0deg); }
}
@keyframes slashDraw {
    0% { stroke-dashoffset: 32; opacity: 0.2; }
    100% { stroke-dashoffset: 0; opacity: 1; }
}
@keyframes typingDotBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-4px); opacity: 1; }
}
@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(35, 165, 90, 0.55); }
    50% { box-shadow: 0 0 0 5px rgba(35, 165, 90, 0); }
}

.icon-btn.animating {
    animation: btnPop 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}
.icon-btn.muted-state {
    color: var(--red) !important;
    background: rgba(242, 63, 67, 0.14);
}
.icon-btn.muted-state .mute-slash {
    stroke-dasharray: 32;
    animation: slashDraw 0.28s ease forwards;
}

.typing-bar {
    height: 22px;
    padding: 0 18px;
    font-size: 0.78rem;
    color: var(--header-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 4px;
}
.typing-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--header-primary);
    display: inline-block;
    animation: typingDotBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }

.voice-speaking-ring {
    animation: voicePulse 1.6s infinite;
    border: 2px solid var(--green);
}

/* ================= ADMIN DASHBOARD ================= */
.admin-grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.admin-stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 14px 16px;
}
.admin-stat-val {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--header-primary);
}
.admin-stat-lbl {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.admin-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 18px;
}
.admin-card h3 {
    font-size: 0.98rem;
    color: var(--header-primary);
    margin-bottom: 10px;
}
.admin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    background: rgba(88, 101, 242, 0.2);
    color: #9aa3ff;
}
.admin-badge.danger {
    background: rgba(242, 63, 67, 0.2);
    color: #ff8a8c;
}
.admin-badge.ok {
    background: rgba(35, 165, 90, 0.2);
    color: #57f287;
}

/* Voice channel full-screen layout */
.voice-stage {
    flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 14px;
    padding: 18px; background: #08090b; color: #f2f3f5;
}
.voice-stage-header { display:flex; align-items:center; justify-content:space-between; font-weight:700; font-size:1rem; }
.voice-live-pill { color:#35c46a; font-size:.72rem; letter-spacing:.04em; background:rgba(53,196,106,.12); border:1px solid rgba(53,196,106,.28); padding:5px 9px; border-radius:20px; }
.voice-stage-grid { flex:1; min-height:200px; display:grid; grid-template-columns:repeat(auto-fit,minmax(min(270px,100%),1fr)); gap:12px; align-content:center; }
.voice-tile { min-height:220px; border-radius:12px; background:linear-gradient(145deg,#242729,#1b1d1f); border:1px solid #34383b; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; position:relative; padding:16px; }
.voice-tile.speaking { border-color:#2eaa64; box-shadow:0 0 0 1px rgba(46,170,100,.22); }
.voice-tile-avatar { width:82px;height:82px;border-radius:50%;background:#5865f2;color:white;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:1.4rem;overflow:hidden; }
.voice-tile-avatar img { width:100%;height:100%;object-fit:cover; }
.voice-tile-name { font-weight:700; }
.voice-tile-flags { position:absolute;bottom:12px;right:12px;color:#ef5350; }
.voice-empty { color:#aaa; text-align:center; padding:25px; }
.voice-stage-controls { display:flex;align-items:center;justify-content:center;gap:10px;padding:10px 0 4px; }
.voice-stage-controls form { margin:0; }
.voice-control { border:0;border-radius:12px;background:#292b2f;color:#fff;width:54px;height:50px;font-size:1.15rem;cursor:pointer;transition:background .15s,transform .15s; }
.voice-control:hover { background:#3a3d42;transform:translateY(-1px); }
.voice-control.muted-state { background:#b53c43; }
.voice-control.leave-call { background:#d83d45; }
@media(max-width:700px) { .voice-stage { padding:10px; } .voice-tile { min-height:160px; } .voice-tile-avatar { width:62px;height:62px; } }

/* Live media tiles + audio/video device preferences */
.voice-tile-video { display:none; width:100%; max-height:65vh; aspect-ratio:16/9; object-fit:contain; border-radius:9px; background:#08090b; }
.voice-tile:has(.voice-tile-video[style*="block"]) { justify-content:flex-start; }
.device-settings { position:absolute; z-index:20; bottom:90px; left:50%; transform:translateX(-50%); width:min(420px,calc(100vw - 24px)); padding:16px; border:1px solid #3d4146; border-radius:14px; background:#202226; box-shadow:0 14px 40px #0009; color:#eee; display:flex; flex-direction:column; gap:12px; }
.device-settings.hidden { display:none; }
.device-settings-head { display:flex; justify-content:space-between; align-items:center; }
.device-settings-head button { border:0;background:#34363b;color:#fff;border-radius:7px;padding:6px 10px;cursor:pointer; }
.device-settings label { display:flex; flex-direction:column; gap:6px; color:#bbb; font-size:.88rem; }
.device-settings select { width:100%; padding:9px; border-radius:7px; background:#2b2d31; color:#fff; border:1px solid #444; }
.device-settings-actions { display:flex; gap:8px; justify-content:flex-end; }
.device-settings-actions button { border:0; border-radius:7px; padding:8px 12px; background:#5865f2; color:#fff; cursor:pointer; }

/* AaroniaCord Developer workspace */
.developer-page{padding:24px;display:grid;grid-template-columns:minmax(0,1fr) 300px;gap:18px;overflow:auto;align-items:start}
.developer-card{background:var(--panel,#202226);border:1px solid #36393f;border-radius:14px;padding:18px;color:var(--text,#eee)}
.developer-card h2,.developer-card h3{margin:0 0 12px}.developer-card p{color:var(--text-muted,#aaa);font-size:.9rem;line-height:1.5}
.developer-warning{border:1px solid #986d2e;background:#4a351a55;padding:12px;border-radius:9px;margin:14px 0;color:#e7d0a6;font-size:.84rem;line-height:1.45}
.developer-editor{width:100%;min-height:420px;resize:vertical;box-sizing:border-box;background:#101216;color:#d7e5ff;border:1px solid #454953;border-radius:10px;padding:14px;font:14px/1.55 Consolas,Monaco,monospace;tab-size:4;outline:none}
.developer-editor:focus{border-color:#6478ff;box-shadow:0 0 0 2px #6478ff33}
.developer-actions{display:flex;flex-wrap:wrap;gap:9px;margin:12px 0}.developer-actions button,.developer-download,.developer-tips button{border:0;border-radius:8px;background:#5865f2;color:#fff;padding:10px 13px;font:inherit;text-decoration:none;cursor:pointer}.developer-actions button:hover,.developer-download:hover,.developer-tips button:hover{filter:brightness(1.12)}
.developer-output{white-space:pre-wrap;min-height:90px;background:#111318;border:1px solid #36393f;border-radius:9px;padding:12px;color:#c4c9d4;font:13px/1.5 Consolas,monospace;overflow:auto}
@media(max-width:950px){.developer-page{grid-template-columns:1fr;padding:14px}.developer-editor{min-height:300px}}

.voice-audio-warning{font-size:.8rem;color:var(--text-muted);min-height:1.1em;margin:4px 12px}
