:root {
  --bg-primary: #313338;
  --bg-secondary: #2b2d31;
  --bg-tertiary: #1e1f22;
  --bg-channel: #111214;
  --text-primary: #dbdee1;
  --text-secondary: #949ba4;
  --text-muted: #5c6066;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --green: #23a55a;
  --red: #da373c;
  --yellow: #f0b232;
  --border: #3f4147;
  --sidebar-width: 240px;
  --channel-width: 240px;
}

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

body { font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif; background: var(--bg-primary); color: var(--text-primary); height: 100vh; overflow: hidden; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-page { display: flex; justify-content: center; align-items: center; height: 100vh; background: var(--bg-tertiary); }
.auth-box { background: var(--bg-secondary); padding: 32px; border-radius: 8px; width: 420px; max-width: 90%; }
.auth-box h1 { font-size: 24px; margin-bottom: 8px; text-align: center; }
.auth-box p { color: var(--text-secondary); text-align: center; margin-bottom: 20px; font-size: 14px; }
.auth-tabs { display: flex; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.auth-tab { flex: 1; padding: 10px; text-align: center; cursor: pointer; color: var(--text-muted); font-weight: 500; transition: 0.2s; }
.auth-tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); margin-bottom: -2px; }
.auth-form { display: none; }
.auth-form.active { display: block; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input { width: 100%; padding: 10px; background: var(--bg-tertiary); border: none; border-radius: 4px; color: var(--text-primary); font-size: 15px; }
.form-group input:focus { outline: 2px solid var(--accent); }
.btn { width: 100%; padding: 12px; border: none; border-radius: 4px; font-size: 15px; font-weight: 500; cursor: pointer; transition: 0.2s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c72e32; }
.btn-small { width: auto; padding: 6px 14px; font-size: 13px; }
.error { color: var(--red); font-size: 13px; margin-top: 4px; display: none; }

.app-layout { display: flex; height: 100vh; }
.server-bar { width: 68px; background: var(--bg-tertiary); display: flex; flex-direction: column; align-items: center; padding: 10px 0; overflow-y: auto; gap: 6px; }
.server-btn { width: 48px; height: 48px; border-radius: 50%; border: none; background: var(--bg-secondary); color: var(--text-primary); font-size: 20px; font-weight: 700; cursor: pointer; transition: 0.15s; display: flex; align-items: center; justify-content: center; position: relative; }
.server-btn:hover { border-radius: 14px; background: var(--accent); }
.server-btn.active { border-radius: 14px; background: var(--accent); }
.server-btn .badge { position: absolute; top: -2px; right: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg-tertiary); }
.server-btn-img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; transition: 0.15s; cursor: pointer; }
.server-btn-img:hover { border-radius: 14px; }
.server-bar-divider { width: 32px; height: 2px; background: var(--border); border-radius: 2px; }

.channel-sidebar { width: var(--channel-width); background: var(--bg-secondary); display: flex; flex-direction: column; }
.channel-header { padding: 16px; font-weight: 600; font-size: 15px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; cursor: pointer; height: 52px; box-sizing: border-box; }
.channel-header:hover { background: var(--bg-primary); }
.channel-section { padding: 8px 8px 0; }
.channel-section-title { font-size: 11px; text-transform: uppercase; color: var(--text-muted); padding: 6px 8px; font-weight: 600; letter-spacing: 0.5px; }
.channel-item { display: flex; align-items: center; padding: 6px 8px; border-radius: 4px; cursor: pointer; color: var(--text-secondary); font-size: 14px; gap: 6px; transition: 0.1s; }
.channel-item:hover { background: var(--bg-primary); color: var(--text-primary); }
.channel-item.active { background: var(--bg-primary); color: var(--text-primary); }
.channel-item .hash { font-size: 18px; font-weight: 300; color: var(--text-muted); }

.main-content { flex: 1; display: flex; flex-direction: column; }
.chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.message { display: flex; gap: 10px; padding: 2px 0; }
.message:hover { background: rgba(255,255,255,0.03); }
.message-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff; overflow: hidden; }
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-body { flex: 1; }
.message-author { font-weight: 500; font-size: 15px; display: inline; margin-right: 8px; }
.message-time { font-size: 11px; color: var(--text-muted); }
.message-content { font-size: 14px; word-break: break-word; margin-top: 2px; }
.typing-indicator { padding: 2px 16px 8px; font-size: 13px; color: var(--text-muted); font-style: italic; min-height: 24px; }
.chat-input-area { padding: 0 16px 16px; }
.chat-input { width: 100%; padding: 10px 14px; background: var(--bg-tertiary); border: none; border-radius: 8px; color: var(--text-primary); font-size: 15px; }
.chat-input:focus { outline: none; }

.friends-panel { display: none; flex-direction: column; flex: 1; }
.friends-panel.active { display: flex; }
.friends-header { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; height: 52px; box-sizing: border-box; }
.friends-header h2 { font-size: 18px; }
.friends-tabs { display: flex; gap: 4px; }
.friends-tab { padding: 4px 12px; border-radius: 4px; font-size: 14px; cursor: pointer; color: var(--text-secondary); }
.friends-tab:hover { background: var(--bg-primary); color: var(--text-primary); }
.friends-tab.active { background: var(--bg-primary); color: #fff; }
.friends-list { flex: 1; overflow-y: auto; padding: 8px; }
.friend-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.friend-item:hover { background: var(--bg-primary); }
.friend-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: #fff; overflow: hidden; flex-shrink: 0; }
.friend-avatar img { width: 100%; height: 100%; object-fit: cover; }
.friend-info { flex: 1; }
.friend-name { font-weight: 500; font-size: 15px; }
.friend-status { font-size: 12px; color: var(--text-muted); }
.friend-status.online { color: var(--green); }
.friend-actions { display: flex; gap: 4px; }
.btn-icon { padding: 6px 10px; border: none; border-radius: 4px; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 14px; }
.btn-icon:hover { background: var(--bg-primary); color: var(--text-primary); }
.search-box { padding: 8px 16px; }
.search-box input { width: 100%; padding: 8px 12px; background: var(--bg-tertiary); border: none; border-radius: 4px; color: var(--text-primary); font-size: 14px; }

.voice-panel { display: none; padding: 12px; background: var(--bg-tertiary); border-top: 1px solid var(--border); }
.voice-panel.active { display: block; }
.voice-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; color: var(--text-secondary); }
.voice-users { display: flex; flex-wrap: wrap; gap: 4px; }
.voice-user { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 4px; background: var(--bg-secondary); font-size: 13px; }
.voice-user .speaking { color: var(--green); }
.voice-controls { display: flex; gap: 8px; margin-top: 8px; }
.voice-btn { padding: 6px 12px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; }
.voice-btn.mute { background: var(--red); color: #fff; }
.voice-btn.leave { background: var(--red); color: #fff; }
.voice-btn.join { background: var(--green); color: #fff; }

.settings-panel { display: none; flex-direction: column; flex: 1; }
.settings-panel.active { display: flex; }
.settings-header { padding: 16px; border-bottom: 1px solid var(--border); }
.settings-body { flex: 1; overflow-y: auto; padding: 16px; }

.user-bar { height: 52px; background: var(--bg-tertiary); border-top: 1px solid var(--border); display: flex; align-items: center; padding: 0 8px; gap: 8px; margin-top: auto; }
.user-bar-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; color: #fff; overflow: hidden; flex-shrink: 0; cursor: pointer; }
.user-bar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-bar-info { flex: 1; min-width: 0; }
.user-bar-name { font-size: 13px; font-weight: 600; cursor: pointer; }
.user-bar-name:hover { text-decoration: underline; }
.user-bar-status { font-size: 11px; color: var(--text-muted); }
.user-bar-actions { display: flex; gap: 2px; }
.user-icon-btn { padding: 6px; border: none; border-radius: 4px; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 16px; }
.user-icon-btn:hover { background: var(--bg-primary); color: var(--text-primary); }

.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); gap: 8px; }
.empty-state h3 { font-size: 18px; color: var(--text-secondary); }
.empty-state p { font-size: 14px; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-secondary); border-radius: 8px; padding: 24px; width: 400px; max-width: 90%; }
.modal h2 { margin-bottom: 16px; }

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

.context-menu { display: none; position: fixed; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 4px; z-index: 200; min-width: 180px; box-shadow: 0 4px 12px rgba(0,0,0,0.4); }
.context-menu.active { display: block; }
.context-menu-item { padding: 8px 12px; cursor: pointer; border-radius: 4px; font-size: 14px; }
.context-menu-item:hover { background: var(--accent); color: #fff; }

/* MOBILE */
.mobile-menu-btn { display: none; position: fixed; top: 8px; left: 8px; z-index: 50; width: 40px; height: 40px; border: none; border-radius: 8px; background: var(--accent); color: #fff; font-size: 20px; cursor: pointer; align-items: center; justify-content: center; }
.mobile-menu-btn:hover { background: var(--accent-hover); }
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 40; }

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
  .mobile-overlay.active { display: block; }
  .server-bar { position: fixed; left: -68px; top: 0; bottom: 0; z-index: 45; transition: left 0.2s; }
  .server-bar.open { left: 0; }
  .channel-sidebar { position: fixed; left: -240px; top: 0; bottom: 0; z-index: 45; transition: left 0.2s; width: 240px; }
  .channel-sidebar.open { left: 68px; }
  .main-content { width: 100%; padding-top: 48px; }
  .channel-header, .friends-header { padding-left: 48px; }
  .auth-box { width: 95%; padding: 20px; }
  .chat-messages { padding: 8px; }
  .message { gap: 6px; }
  .message-avatar { width: 28px; height: 28px; font-size: 11px; }
  .message-content { font-size: 13px; }
  .chat-input { font-size: 16px !important; }
  .chat-input-area { position: sticky; bottom: 0; background: var(--bg-primary); padding: 4px 8px 8px !important; }
  .friends-header { flex-wrap: wrap; gap: 6px; height: auto; min-height: 52px; }
  .friends-header h2 { font-size: 16px; }
  .friends-tabs { flex-wrap: wrap; }
  .friends-tab { font-size: 12px; padding: 3px 8px; }
  .modal { width: 95%; padding: 16px; }
  .settings-body { padding: 8px; }
  .user-bar { padding: 0 4px; }
  .user-bar-name { font-size: 12px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .channel-sidebar { width: 200px; }
  .server-bar { width: 56px; }
  .server-btn, .server-btn-img { width: 40px; height: 40px; font-size: 16px; }
}
