/* ================================================================
   ZITORD — Design System & Styles
   Color Palette from readme.md:
     Background: #0B0E11 (Zitord Dark)
     Sidebar:    #15191C
     Accent:     #00D1B2 (Zitord Turkuazı)
     Text:       #E1E1E1
   ================================================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #14232B;
  --bg-secondary: #102128;
  --bg-tertiary: #0B1419;
  --bg-sidebar: #102128;
  --bg-rail: #102128;
  --bg-accent: #1B3039;
  --bg-floating: #1B3039;
  --bg-modifier-hover: rgba(98, 216, 198, 0.10);
  --bg-modifier-active: #285653;
  --bg-modifier-selected: #285653;
  --accent: #62D8C6;
  --accent-hover: #7DE5D5;
  --accent-soft: rgba(98, 216, 198, 0.12);
  --accent-dim: rgba(98, 216, 198, 0.16);
  --text-primary: #EAF2F2;
  --text-normal: #EAF2F2;
  --text-secondary: #A5B8BE;
  --text-muted: #A5B8BE;
  --text-link: #62D8C6;
  --header-primary: #EAF2F2;
  --header-secondary: #A5B8BE;
  --border: #304750;
  --success: #43B581;
  --status-online: #43B581;
  --status-idle: #FAA61A;
  --status-dnd: #F04747;
  --status-offline: #71868E;
  --danger: #F04747;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-full: 50%;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-speed: 0.3s;
}

/* --- THEME DEFINITIONS --- */

[data-theme="amoled"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #000000;
  --bg-sidebar: #050505;
  --bg-rail: #000000;
  --bg-accent: #111111;
  --bg-floating: #111111;
  --border: #252525;
  --header-secondary: #888;
  --text-muted: #666;
  --bg-modifier-hover: rgba(255, 255, 255, 0.02);
  --bg-modifier-active: rgba(255, 255, 255, 0.04);
}

[data-theme="ocean"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #020617;
  --bg-sidebar: #1e293b;
  --bg-rail: #020617;
  --bg-accent: #334155;
  --bg-floating: #1e293b;
  --border: #334155;
  --accent: #38bdf8;
  --accent-hover: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.1);
}

[data-theme="sakura"] {
  --bg-primary: #2d1b2d;
  --bg-secondary: #3d243d;
  --bg-tertiary: #1a101a;
  --bg-sidebar: #3d243d;
  --bg-rail: #1a101a;
  --bg-accent: #4d2e4d;
  --bg-floating: #4d2e4d;
  --border: #624062;
  --accent: #f472b6;
  --accent-hover: #ec4899;
  --accent-soft: rgba(244, 114, 182, 0.1);
  --text-normal: #fce7f3;
}

[data-theme="forest"] {
  --bg-primary: #141e14;
  --bg-secondary: #1c2a1c;
  --bg-tertiary: #0d140d;
  --bg-sidebar: #1c2a1c;
  --bg-rail: #0d140d;
  --bg-accent: #2d422d;
  --bg-floating: #2d422d;
  --border: #3a563a;
  --accent: #4ade80;
  --accent-hover: #22c55e;
  --accent-soft: rgba(74, 222, 128, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  /* Smooth theme transitions */
  transition: background-color var(--transition-speed), border-color var(--transition-speed), color var(--transition-speed);
}

body {
  background-color: var(--bg-tertiary);
  color: var(--text-normal);
  overflow: hidden;
  height: 100vh;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ================================================================
   TITLEBAR
   ================================================================ */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  background: #080A0D;
  -webkit-app-region: drag;
  padding: 0 8px;
  position: relative;
  z-index: 100;
}

.titlebar-drag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
}

.titlebar-logo {
  -webkit-app-region: no-drag;
}

.titlebar-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.titlebar-controls {
  display: flex;
  -webkit-app-region: no-drag;
}

.titlebar-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 46px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.titlebar-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.titlebar-btn-close:hover {
  background: var(--danger);
  color: white;
}

/* ================================================================
   MAIN APP LAYOUT — 4 Panel
   ================================================================ */
.app-container {
  display: flex;
  height: calc(100vh - 32px);
  overflow: hidden;
}

/* ================================================================
   1. SERVER RAIL
   ================================================================ */
.server-rail {
  width: 72px;
  background-color: var(--bg-rail);
  transition: color 0.2s, background 0.2s;
  min-width: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  user-select: none;
}

.server-rail::-webkit-scrollbar { display: none; }

.server-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-radius 0.3s ease, background 0.2s ease, transform 0.1s ease;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 18px;
  position: relative;
  flex-shrink: 0;
}

.server-icon:hover {
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: white;
  transform: scale(1.05);
}

.server-icon.active {
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: white;
}

/* Delete button for servers */
.server-delete-btn {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
  border: 2px solid var(--bg-primary);
}

.server-icon:hover .server-delete-btn {
  opacity: 1;
}

/* Active indicator pill */
.server-icon::before {
  content: '';
  position: absolute;
  left: -16px;
  width: 4px;
  height: 0;
  background: var(--text-primary);
  border-radius: 0 4px 4px 0;
  transition: height 0.2s ease;
}

.server-icon:hover::before {
  height: 20px;
}

.server-icon.active::before {
  height: 36px;
}

.home-icon {
  background: var(--bg-tertiary);
}

.home-icon:hover, .home-icon.active {
  background: var(--accent);
}

.server-separator {
  width: 32px;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  margin: 4px 0;
  flex-shrink: 0;
}

.add-server {
  background: transparent;
  border: 2px dashed var(--text-muted);
}

.add-server:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Server icon tooltip */
.server-icon[title] {
  position: relative;
}

/* ================================================================
   2. SIDEBAR
   ================================================================ */
.sidebar-wrapper {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

.sidebar {
  width: 240px;
  background-color: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.sidebar-header {
  padding: 0 16px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0,0,0,0.2);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  position: relative; /* CRITICAL: Keeps dropdown inside */
  cursor: pointer;
  transition: background 0.2s;
  user-select: none;
  flex-shrink: 0;
}

.sidebar-header:hover {
  background: var(--bg-modifier-hover);
}

.sidebar-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-dropdown-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
}

/* Channel List */
.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.channel-category {
  padding: 16px 8px 4px 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.channel-category-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.channel-category-arrow {
  color: var(--text-muted);
  font-size: 10px;
  transition: transform 0.2s;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}

.channel-item:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-secondary);
}

.channel-item.active {
  background: var(--bg-modifier-active);
  color: var(--text-primary);
}

.unread-badge {
  background-color: #f04747;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 0 5px;
  border-radius: 10px;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.channel-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.6;
}

.channel-item.active .channel-icon {
  opacity: 1;
}

.channel-name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Delete button for channels */
.channel-delete-btn {
  opacity: 0;
  color: var(--text-muted);
  transition: opacity 0.2s, color 0.2s;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.channel-item:hover .channel-delete-btn {
  opacity: 1;
}

.channel-delete-btn:hover {
  color: var(--danger);
}

/* Voice channel connected bar */
.voice-connected-bar {
  background: linear-gradient(135deg, #43B581 0%, #3ca374 100%);
  color: white;
  padding: 8px 12px;
  margin: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.3s ease;
}

.voice-connected-dot {
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

/* Voice channel connected users (nested under voice channel) */
.voice-channel-users {
  padding: 2px 0 4px 28px;
}

.voice-channel-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.voice-channel-user:hover {
  background: var(--bg-modifier-hover);
}

.voice-channel-user:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.participant-audio-menu {
  position: fixed;
  z-index: 20010;
  box-sizing: border-box;
  width: 252px;
  max-width: calc(100vw - 16px);
  padding: 12px;
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  background: var(--bg-floating);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  color: var(--text-primary);
}

.participant-audio-heading {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 700;
}

.participant-audio-scope {
  margin: 3px 0 15px;
  color: var(--text-secondary);
  font-size: 11px;
}

.participant-audio-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}

.participant-audio-label output { color: var(--accent); font-variant-numeric: tabular-nums; }

.participant-audio-menu input[type="range"] {
  display: block;
  width: 100%;
  margin: 11px 0 16px;
  accent-color: var(--accent);
}

.participant-audio-mute {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-align: left;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.participant-audio-mute:hover,
.participant-audio-mute:focus-visible { background: var(--bg-modifier-active); }
.participant-audio-mute[aria-pressed="true"] { color: #ffb4b4; }

.voice-channel-user .avatar {
  width: 24px;
  height: 24px;
  font-size: 10px;
}

.voice-channel-user .avatar::after {
  display: none;
}

.voice-channel-user-name {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.bot-badge {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--text-primary);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .04em;
}

.voice-channel-user-speaking,
.voice-channel-user.speaking .avatar {
  box-shadow: 0 0 0 2px var(--status-online);
  animation: speakingPulse 1.5s infinite;
}

@keyframes speakingPulse {
  0% { box-shadow: 0 0 0 2px var(--status-online); }
  50% { box-shadow: 0 0 0 3px rgba(67, 181, 129, 0.4); }
  100% { box-shadow: 0 0 0 2px var(--status-online); }
}

/* ---- Voice Status Panel (above user panel) ---- */
.voice-join-progress {
  display: none;
  flex-shrink: 0;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  color: #faa61a;
  background: var(--bg-secondary);
  font-size: 12px;
  font-weight: 600;
}

.voice-join-progress.visible {
  display: block;
}

.voice-status-panel {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 12px 8px 8px;
  flex-shrink: 0;
  display: none;
  animation: slideUp 0.3s ease;
}

.voice-status-panel.visible {
  display: block;
}

.voice-status-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.voice-status-state {
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-signal-icon {
  flex-shrink: 0;
  animation: signalPulse 2s ease-in-out infinite;
}

.voice-status-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--status-online);
}

.voice-status-channel {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 24px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.voice-status-channel:hover {
  color: var(--text-secondary);
  text-decoration: underline;
}

.voice-status-controls {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.voice-control-btn {
  background: var(--bg-tertiary);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

.voice-control-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-primary);
}

.voice-control-btn.active,
.voice-control-btn.streaming {
  background: rgba(88, 101, 242, 0.2);
  color: #5865f2;
}

.voice-disconnect-btn:hover {
  background: rgba(240, 71, 71, 0.15) !important;
  color: var(--danger) !important;
}

/* Voice channel item active state */
.channel-item.voice-active {
  color: var(--status-online);
}

.channel-item.voice-active .channel-icon {
  opacity: 1;
}

@keyframes signalPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* User Panel (bottom of sidebar) */
.user-panel {
  height: 52px;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 8px;
  flex-shrink: 0;
}

.user-panel-info {
  flex: 1;
  min-width: 0;
}

.user-panel-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}

.user-panel-status {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.user-panel-actions {
  display: flex;
  gap: 2px;
}

/* ================================================================
   3. CHAT AREA
   ================================================================ */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-width: 0;
}

.chat-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
}

.chat-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.channel-hash {
  flex-shrink: 0;
}

.chat-header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 8px;
}

.chat-header-topic {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 0;
  position: relative !important; /* Forces absolute children to stay within this area */
  z-index: 1;
}

.messages-list {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  justify-content: flex-end;
  padding: 0 16px;
}

.message-group {
  display: flex;
  gap: 16px;
  padding: 4px 0;
  margin-top: 16px;
  position: relative;
}

.message-group:hover {
  background: var(--bg-modifier-hover);
  border-radius: var(--radius-sm);
}

.message-group .avatar {
  flex-shrink: 0;
  margin-top: 2px;
}

.message-content {
  flex: 1;
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.message-author {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.message-author:hover {
  text-decoration: underline;
}

.message-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.message-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  word-wrap: break-word;
  font-weight: 400;
  user-select: text;
}

/* Consecutive message (same user, no avatar) */
.message-consecutive {
  padding: 2px 0 2px 64px;
  position: relative;
}

.message-consecutive:hover {
  background: var(--bg-modifier-hover);
  border-radius: var(--radius-sm);
}

.message-consecutive:hover .message-consecutive-time {
  opacity: 1;
}

.message-consecutive .message-consecutive-time:focus-visible {
  opacity: 1;
}

.message-consecutive-time {
  position: absolute;
  left: 8px;
  top: 4px;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.15s;
  width: 48px;
  text-align: right;
}

.message-consecutive .message-text {
  font-size: 14px;
}

/* Welcome message */
.welcome-message {
  text-align: center;
  padding: 40px 20px;
  margin-bottom: 16px;
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.welcome-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.welcome-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.5;
}

/* Typing indicator */
.typing-indicator {
  height: 24px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.typing-indicator.visible {
  opacity: 1;
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Message Input */
.message-input-container {
  margin: 0 16px 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 2px 4px;
  transition: box-shadow 0.2s;
  position: relative;
  z-index: 10;
}

.message-input-container:focus-within {
  box-shadow: 0 0 0 2px var(--accent-dim);
}

#messageInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 4px;
  caret-color: var(--accent);
  resize: none;
  min-height: 40px;
  max-height: 120px;
  line-height: 20px;
}

.message-send-error {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 0;
  right: 0;
  padding: 6px 10px;
  border-radius: 5px;
  color: #fff;
  background: #a83238;
  font-size: 12px;
}

.message-send-error[hidden] { display: none; }

#messageInput::placeholder {
  color: var(--text-muted);
}

.input-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color var(--transition);
}

.input-action-btn:hover {
  color: var(--text-secondary);
}

.input-actions-right {
  display: flex;
}

/* ================================================================
   HOME VIEW STYLES
   ================================================================ */

.search-bar-btn {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  width: 100%;
  text-align: left;
  font-size: 13px;
  font: inherit;
  cursor: text;
  box-shadow: inset 0 0 0 1px transparent;
  transition: background 0.2s;
}

.search-bar-btn:hover {
  background: rgba(255,255,255,0.05);
}

.home-top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: 8px;
}

.home-top-item {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
}

.home-top-item:hover {
  background: var(--bg-modifier-hover);
  color: var(--text-secondary);
}

.home-top-item.active {
  background: var(--bg-modifier-active);
  color: var(--text-primary);
}

.add-friend-btn {
  background: var(--success) !important;
  color: white !important;
  font-size: 13px;
  padding: 4px 8px;
}

.add-friend-btn:hover {
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transform: translateY(-1px);
}

.home-content-wrapper {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.home-main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-width: 0;
}

.empty-state-home {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: min(100%, 420px);
  max-width: 420px;
  align-self: center;
  margin: auto;
  padding: 24px;
}

.empty-state-icon {
  margin-bottom: 24px;
  opacity: 0.8;
  color: var(--text-secondary);
}

.empty-state-home h3 {
  font-size: 20px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state-home p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  max-width: 36ch;
}

.home-active-col {
  flex-direction: column;
  width: 240px;
  min-width: 240px;
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.active-now-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
}

.active-now-empty {
  text-align: center;
  padding: 32px 16px;
  width: 100%;
}

.home-main-col .btn-primary {
  background: var(--accent);
  color: var(--bg-tertiary);
}

.home-main-col .btn-primary:hover {
  background: var(--accent-hover);
}

@media (max-width: 899px) {
  .home-top-nav {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
  }
  .home-top-item { flex-shrink: 0; }
  #dmChatSection { min-width: 0; }
  #dmProfilePanel { display: none; }
}

@media (max-width: 699px) {
  .home-active-col { display: none !important; }
  .home-top-nav {
    gap: 4px;
    margin-left: 0;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
  }
  .home-top-item { flex-shrink: 0; }
  .add-friend-input-row {
    flex-direction: column;
    align-items: stretch;
  }
  #addFriendInput {
    width: 100%;
    min-width: 0;
    min-height: 36px;
  }
  .add-friend-input-row .btn-primary { width: 100%; }
}

/* Friend List Item */
.friend-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
  border-top: 1px solid transparent;
}

.friend-item:hover {
  background: var(--bg-modifier-hover);
}

.friend-item .friend-info {
  flex: 1;
  margin-left: 12px;
  display: flex;
  flex-direction: column;
}

.friend-item .friend-name {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
}

.friend-item .friend-status {
  color: var(--text-muted);
  font-size: 12px;
}

.friend-actions {
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}


/* --- Message Reactions & Actions --- */
.message-group, .message-consecutive {
  position: relative;
}

.message-group:hover .message-actions, 
.message-consecutive:hover .message-actions {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.message-actions {
  position: absolute;
  top: -16px;
  right: 16px;
  background: #313338;
  border: 1px solid #1e1f22;
  border-radius: 4px;
  display: flex;
  padding: 2px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.1s ease;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transform: translateY(4px);
  gap: 2px;
}

.reaction-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 16px;
  transition: background 0.1s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reaction-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--header-primary);
  transform: scale(1.1);
}

.reactions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-badge {
  background: var(--bg-secondary);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 1px 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.1s;
  user-select: none;
}

.reaction-badge:hover {
  border-color: var(--accent);
}

.reaction-badge.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.reaction-count {
  color: var(--text-secondary);
  font-weight: 700;
}

.reaction-badge.active .reaction-count {
  color: var(--accent);
}

.friend-item:hover .friend-actions {
  opacity: 1;
}

.friend-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
  flex: 0 0 36px;
}

.friend-action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-modifier-active);
}

.friend-action-btn.invite:hover {
  color: var(--success);
}

/* Add Friend Message */
#addFriendMessage {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

#addFriendMessage.success {
  background: rgba(67, 181, 129, 0.1);
  color: var(--success);
  border: 1px solid var(--success);
}

#addFriendMessage.error {
  background: rgba(240, 71, 71, 0.1);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* ================================================================
   4. USER BAR (Members Panel)
   ================================================================ */
.user-bar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  overflow-y: auto;
  padding: 16px 8px;
  transition: width 0.3s ease, min-width 0.3s ease, padding 0.3s ease;
}

.user-bar.hidden {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

.user-bar-heading {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 8px 4px;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.member-item:hover {
  background: var(--bg-modifier-hover);
}

.member-info {
  flex: 1;
  min-width: 0;
}

.member-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-item:hover .member-name {
  color: var(--text-primary);
}

.member-activity {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 4px;
}

.member-activity-icon {
  width: 14px;
  height: 14px;
}

.member-offline .avatar {
  opacity: 0.4;
}

.member-offline .member-name {
  color: var(--text-muted);
}

/* ================================================================
   AVATARS
   ================================================================ */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: white;
  position: relative;
  flex-shrink: 0;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  font-size: 13px;
}

/* Status dot on avatar */
.avatar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 3px solid var(--bg-secondary);
  background: var(--status-offline);
}

.avatar[data-status="online"]::after { background: var(--status-online); }
.avatar[data-status="idle"]::after { background: var(--status-idle); }
.avatar[data-status="dnd"]::after { background: var(--status-dnd); }
.avatar[data-status="offline"]::after { background: var(--status-offline); }

.avatar-sm::after {
  width: 10px;
  height: 10px;
  border-width: 2px;
}

/* Avatar colors based on first letter */
.avatar-color-0 { background: linear-gradient(135deg, #00D1B2, #00A389); }
.avatar-color-1 { background: linear-gradient(135deg, #7289DA, #5B6EAE); }
.avatar-color-2 { background: linear-gradient(135deg, #E74C3C, #C0392B); }
.avatar-color-3 { background: linear-gradient(135deg, #F39C12, #D68910); }
.avatar-color-4 { background: linear-gradient(135deg, #9B59B6, #8844A0); }

/* ================================================================
   ICON BUTTON
   ================================================================ */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), background var(--transition);
}

.icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-modifier-hover);
}

/* ================================================================
   MOBILE RESPONSIVE
   ================================================================ */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}

.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 50;
}

@media (max-width: 768px) {
  .server-rail {
    position: fixed;
    left: -72px;
    top: 32px;
    height: calc(100vh - 32px);
    z-index: 60;
    transition: left 0.3s ease;
  }

  .sidebar {
    position: fixed;
    left: -240px;
    top: 32px;
    height: calc(100vh - 32px);
    z-index: 55;
    transition: left 0.3s ease;
  }

  .user-bar {
    display: none;
  }

  .mobile-menu-btn {
    display: flex;
  }

  body.mobile-menu-open .server-rail {
    left: 0;
  }

  body.mobile-menu-open .sidebar {
    left: 72px;
  }

  body.mobile-menu-open .mobile-overlay {
    display: block;
  }
}

/* ================================================================
   MARKDOWN & MESSAGE CONTENT
   ================================================================ */
.message-text b, .message-text strong { color: #fff; font-weight: 700; }
.message-text i, .message-text em { font-style: italic; color: #dbdee1; }
.message-text u { text-decoration: underline; }
.message-text s, .message-text strike { text-decoration: line-through; opacity: 0.6; }

.message-text code {
    background: #1e1f22;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 85%;
    color: #e3e5e8;
}

.message-text pre {
    background: #1e1f22;
    padding: 12px;
    border-radius: 8px;
    margin: 8px 0;
    border: 1px solid rgba(255,255,255,0.05);
    overflow-x: auto;
}

.message-text pre code {
    background: none;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}

/* Edit Mode */
.edit-mode-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 4px 0;
    width: 100%;
}

.edit-input {
    background: #383a40;
    border: none;
    border-radius: 8px;
    padding: 10px;
    color: #dbdee1;
    font-size: 14px;
    outline: none;
    width: 100%;
    resize: none;
}

.edit-actions {
    display: flex;
    gap: 8px;
    font-size: 12px;
}

.edit-cancel { color: #5865f2; cursor: pointer; }
.edit-cancel:hover { text-decoration: underline; }

.edited-tag {
    font-size: 10px;
    color: #949ba4;
    margin-left: 4px;
    cursor: help;
    user-select: none;
}

.edited-tag:hover { color: #dbdee1; text-decoration: underline; }

/* Edit History Tooltip/Modal */
.edit-history-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.edit-history-modal.active { display: flex; }

.edit-history-card {
    background: #313338;
    width: 100%;
    max-width: 450px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 24px 48px rgba(0,0,0,0.4);
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.edit-history-header {
    padding: 16px;
    background: #2b2d31;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-history-header h3 { margin: 0; font-size: 16px; color: #fff; }

.edit-history-content {
    padding: 20px;
}

.history-item {
    margin-bottom: 16px;
}

.history-label {
    font-size: 11px;
    font-weight: 700;
    color: #949ba4;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.history-text {
    background: #2b2d31;
    padding: 12px;
    border-radius: 8px;
    color: #dbdee1;
    font-size: 14px;
    line-height: 1.5;
    border-left: 3px solid #5865f2;
}

/* ================================================================
   THEME STORE UI
   ================================================================ */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.theme-card {
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
}

.theme-card:hover {
    background: var(--bg-accent);
    transform: translateY(-2px);
}

.theme-card.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.theme-preview {
    width: 100%;
    height: 60px;
    border-radius: 8px;
    display: flex;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.preview-sidebar { width: 30%; }
.preview-content { width: 70%; position: relative; }
.preview-accent { 
    position: absolute; 
    bottom: 8px; right: 8px; 
    width: 12px; height: 12px; 
    border-radius: 50%; 
}

.theme-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--header-primary);
}

/* Specific Preview Colors */
.preview-midnight .preview-sidebar { background: #2b2d31; }
.preview-midnight .preview-content { background: #313338; }
.preview-midnight .preview-accent  { background: #14b8a6; }

.preview-amoled .preview-sidebar { background: #050505; }
.preview-amoled .preview-content { background: #000000; }
.preview-amoled .preview-accent  { background: #14b8a6; }

.preview-ocean .preview-sidebar { background: #1e293b; }
.preview-ocean .preview-content { background: #0f172a; }
.preview-ocean .preview-accent  { background: #38bdf8; }

.preview-sakura .preview-sidebar { background: #3d243d; }
.preview-sakura .preview-content { background: #2d1b2d; }
.preview-sakura .preview-accent  { background: #f472b6; }

.preview-forest .preview-sidebar { background: #1c2a1c; }
.preview-forest .preview-content { background: #141e14; }
.preview-forest .preview-accent  { background: #4ade80; }

/* ================================================================
   CHANNEL VIBES SYSTEM
   ================================================================ */
.chat-vibe-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0; /* Changed from -1 to ensure visibility */
    pointer-events: none;
    overflow: hidden;
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.messages-list {
    position: relative;
    z-index: 1;
    background: transparent !important;
}

/* Glassmorphism for messages when a vibe is active */
[data-vibe] .message-group,
[data-vibe] .message-consecutive {
    background: rgba(var(--vibe-msg-bg), 0.25) !important; /* More transparent for better glass effect */
    backdrop-filter: blur(16px) saturate(180%);
    margin: 4px 16px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

[data-vibe] .message-consecutive {
    padding-left: 64px;
}

/* --- 🌧️ Rainy Night Vibe --- */
.vibe-rainy #chatVibeContainer {
    background: linear-gradient(180deg, #080b14 0%, #111133 100%);
}
.vibe-rainy {
    --vibe-msg-bg: 10, 15, 30;
}
.vibe-rainy #chatVibeContainer::after {
    content: "";
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 300%;
    background-image: url('https://www.transparenttextures.com/patterns/stardust.png');
    animation: rainMove 15s linear infinite;
    opacity: 0.6; /* More visible stardust */
    filter: brightness(1.5);
}

@keyframes rainMove {
    from { transform: translateY(0); }
    to { transform: translateY(50%); }
}

/* --- 🌌 Cyberpunk Vibe --- */
.vibe-cyberpunk #chatVibeContainer {
    background: #020617;
}
.vibe-cyberpunk {
    --vibe-msg-bg: 2, 6, 23;
}
.vibe-cyberpunk [data-vibe] .message-group,
.vibe-cyberpunk [data-vibe] .message-consecutive {
    box-shadow: 0 0 15px rgba(244, 114, 182, 0.1), 0 0 5px rgba(56, 189, 248, 0.1);
    border-color: rgba(244, 114, 182, 0.2);
}
.vibe-cyberpunk #chatVibeContainer::before {
    content: "";
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background-image: 
        linear-gradient(rgba(244, 114, 182, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
    transform: perspective(500px) rotateX(60deg);
    animation: gridMove 10s linear infinite;
}
.vibe-cyberpunk #chatVibeContainer::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 50% 50%, transparent 0%, rgba(244, 114, 182, 0.1) 100%);
}

@keyframes gridMove {
    from { background-position: 0 0; }
    to { background-position: 0 40px; }
}

/* --- 🍃 Zen Garden Vibe --- */
.vibe-zen #chatVibeContainer {
    background: linear-gradient(135deg, #141e14 0%, #2d422d 100%);
}
.vibe-zen {
    --vibe-msg-bg: 10, 25, 10;
}
.vibe-zen [data-vibe] .message-group,
.vibe-zen [data-vibe] .message-consecutive {
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(20px);
    border-color: rgba(100, 200, 100, 0.1);
}
.vibe-zen .leaf {
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(74, 222, 128, 0.2);
    border-radius: 20% 80% 20% 80%;
    animation: leafFall 15s linear infinite;
}

@keyframes leafFall {
    0% { transform: translateY(-100px) rotate(0deg); left: var(--start-x); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(100vh) rotate(360deg); left: var(--end-x); opacity: 0; }
}

/* --- Vibe Selector UI --- */
.vibe-selector-btn {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-accent);
    margin-right: 8px;
}
.vibe-selector-btn:hover {
    color: var(--header-primary);
    background: var(--bg-modifier-hover);
}

/* ================================================================
   ANIMATIONS
   ================================================================ */
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes slideUp {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Message Pop Animation --- */
@keyframes messagePop {
  0% { opacity: 0; transform: scale(0.96) translateY(8px); }
  60% { opacity: 1; transform: scale(1.01) translateY(-1px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.message-group, .message-consecutive {
  animation: fadeIn 0.15s ease;
}

.message-group.msg-new, .message-consecutive.msg-new {
  animation: messagePop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* --- Channel Transition Animation --- */
@keyframes channelFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.messages-container.channel-transitioning .messages-list {
  animation: channelFadeIn 0.3s ease forwards;
}

/* --- Reply Bar --- */
.reply-bar {
  display: none;
  background: linear-gradient(135deg, rgba(0,209,178,0.08), rgba(43,45,49,0.95));
  padding: 10px 16px;
  margin: 0 16px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  border-left: 3px solid var(--accent);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: slideUp 0.2s ease;
}

.reply-bar.active {
  display: flex;
}

.reply-bar-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.reply-bar-label {
  font-size: 12px;
  color: var(--text-muted);
}

.reply-bar-label strong {
  color: var(--accent);
  font-weight: 600;
}

.reply-bar-content {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 500px;
  margin-top: 2px;
}

.reply-bar-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.reply-bar-close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

/* --- Reply Preview (inside messages) --- */
.reply-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 4px;
  background: rgba(255,255,255,0.03);
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  transition: background 0.15s;
}

.reply-preview:hover {
  background: rgba(255,255,255,0.06);
}

.reply-preview-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.reply-preview-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

/* --- Read Receipts --- */
.message-receipt-time {
  display: inline-block;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
}

.message-receipt-time:hover,
.message-receipt-time:focus-visible {
  color: var(--text-secondary);
}

.message-receipt-time:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.message-receipt-slot:empty {
  display: none;
}

.message-receipt-slot {
  margin-top: 2px;
}

.read-receipt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.2;
}

.read-receipt svg {
  width: 14px;
  height: 14px;
}

.read-receipt.sent svg {
  color: var(--text-muted);
}

.read-receipt.read svg {
  color: var(--accent);
}

/* --- Reply Button in message-actions --- */
.reply-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  transition: background 0.1s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reply-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  transform: scale(1.1);
}

/* ================================================================
   GLOBAL SEARCH MODAL (Ctrl+K)
   ================================================================ */
.search-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 15000;
  padding-top: 15vh;
}

.search-modal.active {
  display: flex;
}

.search-card {
  width: 560px;
  max-width: 90vw;
  background: #1E2023;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04);
  overflow: hidden;
  animation: modalIn 0.2s ease;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.search-input-wrapper svg {
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-input-global {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 16px;
  font-family: var(--font);
  caret-color: var(--accent);
}

.search-input-global::placeholder {
  color: var(--text-muted);
}

.search-shortcut-badge {
  font-size: 11px;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
  flex-shrink: 0;
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.search-results-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

.search-results-empty svg {
  margin-bottom: 12px;
  opacity: 0.4;
}

.search-category-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px 4px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
}

.search-result-item:hover {
  background: rgba(255,255,255,0.05);
}

.search-result-item.focused {
  background: rgba(0,209,178,0.1);
}

.search-result-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
}

.search-result-icon.channel {
  background: rgba(142,146,151,0.2);
  color: var(--text-secondary);
  font-size: 16px;
}

.search-result-icon.message {
  background: rgba(0,209,178,0.15);
  color: var(--accent);
  font-size: 16px;
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.search-result-badge {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-footer {
  padding: 10px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted);
}

.search-footer kbd {
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-family: var(--font);
}


/* ================================================================
   SETTINGS MODAL
   ================================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.visible {
  display: flex;
}

.modal-card {
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  width: 440px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.25s ease;
  overflow: hidden;
}

@keyframes modalIn {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  transition: color var(--transition);
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 12px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.audio-processing-settings {
  margin: 20px 0 4px;
  padding: 18px 20px;
  border: 1px solid rgba(20, 184, 166, 0.2);
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, rgba(20, 184, 166, 0.08), rgba(0, 0, 0, 0.12));
}
.audio-processing-settings h4 { margin: 0 0 10px; color: #14b8a6; font-size: 11px; letter-spacing: .6px; }
.audio-toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 10px 0; cursor: pointer; }
.audio-toggle-row + .audio-toggle-row { border-top: 1px solid rgba(255,255,255,.06); }
.audio-toggle-row strong { display: block; color: var(--text-primary); font-size: 13px; }
.audio-toggle-row small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 11px; line-height: 1.4; }
.audio-toggle-row input { width: 18px; height: 18px; flex: 0 0 auto; accent-color: #14b8a6; cursor: pointer; }
.audio-processing-status { min-height: 16px; margin: 8px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.voice-quality-label { margin-top: 12px; }
.mic-test-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.mic-test-btn { border: 1px solid rgba(20,184,166,.5); border-radius: var(--radius-sm); padding: 9px 13px; background: rgba(20,184,166,.12); color: var(--text-primary); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.mic-test-btn:hover:not(:disabled) { background: rgba(20,184,166,.22); }
.mic-test-btn:disabled { opacity: .55; cursor: not-allowed; }
.mic-test-caution { margin: 7px 0 0; color: var(--text-muted); font-size: 11px; }
.mic-level-meters { display: grid; gap: 8px; margin-top: 10px; }
.mic-level-meters[hidden] { display: none; }
.mic-level-row { display: grid; grid-template-columns: 112px minmax(50px, 1fr) 62px; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); }
.mic-level-row output { text-align: right; font-variant-numeric: tabular-nums; }
.mic-level-track { height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.mic-level-fill { width: 0; height: 100%; background: #14b8a6; transition: width 100ms linear; }

.settings-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

select.settings-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%238E9297' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.settings-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.settings-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.settings-select option {
  background: var(--bg-primary);
  color: var(--text-primary);
  padding: 8px;
}

/* ================================================================
   VOICE SPEAKING INDICATOR
   ================================================================ */
.voice-channel-user.speaking .avatar {
  box-shadow: 0 0 0 2px var(--status-online), 0 0 8px rgba(67, 181, 129, 0.4);
  transition: box-shadow 0.15s ease;
}

/* ================================================================
   MUTE / DEAFEN VISUAL STATES
   ================================================================ */
.voice-control-btn.muted,
.icon-btn.muted {
  color: var(--danger);
  position: relative;
}

.voice-control-btn.muted::after,
.icon-btn.muted::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 2px;
  background: var(--danger);
  border-radius: 1px;
  transform: translate(-50%, -50%) rotate(-45deg);
  pointer-events: none;
}

.voice-disconnect-btn {
  background: rgba(240, 71, 71, 0.1) !important;
}

.voice-disconnect-btn:hover {
  background: rgba(240, 71, 71, 0.25) !important;
}

/* ================================================================
   AUTH SCREEN
   ================================================================ */

.auth-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0e17 0%, #1a1f36 30%, #0d1526 60%, #141b2d 100%);
  z-index: 9999;
  overflow: hidden;
}

.auth-screen::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 209, 178, 0.12) 0%, transparent 70%);
  top: -150px;
  right: -150px;
  animation: authGlow 8s ease-in-out infinite alternate;
}

.auth-screen::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(114, 137, 218, 0.1) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  animation: authGlow 6s ease-in-out infinite alternate-reverse;
}

@keyframes authGlow {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.3); opacity: 1; }
}

.auth-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.auth-brand {
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  margin: 0;
}

.auth-tagline {
  font-size: 14px;
  color: #8e9297;
  margin: 0;
}

.auth-card {
  width: 100%;
  background: rgba(30, 33, 44, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 3px;
}

.auth-tab {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: #8e9297;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.25s ease;
  font-family: 'Inter', sans-serif;
}

.auth-tab.active {
  background: rgba(0, 209, 178, 0.15);
  color: #00D1B2;
}

.auth-tab:hover:not(.active) {
  color: #dcddde;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-field {
  margin-bottom: 18px;
}

.auth-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #b9bbbe;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.auth-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

.auth-input:focus {
  border-color: rgba(0, 209, 178, 0.5);
  box-shadow: 0 0 0 3px rgba(0, 209, 178, 0.1);
}

.auth-input::placeholder {
  color: #4f5157;
}

.auth-error {
  display: none;
  background: rgba(240, 71, 71, 0.15);
  border: 1px solid rgba(240, 71, 71, 0.3);
  color: #f04747;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.auth-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.25s ease;
  font-family: 'Inter', sans-serif;
}

.auth-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-btn.loading {
  opacity: 0.7;
  pointer-events: none;
}

.auth-btn-primary {
  background: linear-gradient(135deg, #00D1B2, #00b89c);
  color: #fff;
}

.auth-btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #00e2c1, #00c9a8);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 209, 178, 0.3);
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.auth-divider span {
  color: #8e9297;
  font-size: 12px;
  padding: 0 12px;
  text-transform: uppercase;
  font-weight: 600;
}

.auth-btn-google {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #dcddde;
}

.auth-btn-google:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.auth-footer {
  color: #4f5157;
  font-size: 12px;
  margin: 0;
}

/* ================================================================
   MODALS & CONTEXT MENUS
   ================================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-overlay.active {
  display: flex;
}

.modal-card, .modal-box {
  background: var(--bg-secondary);
  width: 440px;
  max-width: 100%;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card,
.modal-overlay.active .modal-box {
  transform: scale(1);
}

.modal-header {
  padding: 24px;
  background: var(--bg-tertiary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title, .modal-header h3 {
  color: #fff;
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
  display: flex;
}

.modal-close-btn:hover {
  color: #fff;
}

.settings-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
  position: relative;
}

/* Custom Scrollbar for Settings */
.settings-body::-webkit-scrollbar {
  width: 6px;
}
.settings-body::-webkit-scrollbar-track {
  background: transparent;
}
.settings-body::-webkit-scrollbar-thumb {
  background: var(--bg-accent);
  border-radius: 10px;
}

.settings-view {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.settings-view.hidden {
    display: none;
}

.settings-nav-btn {
    width: 100%;
    background: var(--bg-accent);
    color: var(--header-primary);
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
    margin-bottom: 12px;
}

.settings-nav-btn:hover {
    background: var(--bg-modifier-hover);
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
    padding: 0;
}

.back-btn:hover {
    text-decoration: underline;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  background: var(--bg-tertiary);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Modal Buttons */
.btn {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--bg-modifier-hover);
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #c0392b;
  transform: translateY(-1px);
}

/* Context Menu */
.context-menu {
  position: fixed;
  background: #111214;
  border-radius: var(--radius-sm);
  min-width: 188px;
  padding: 6px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border);
  z-index: 3000;
  display: none;
  animation: contextFadeIn 0.1s ease-out;
}

.context-menu.active {
  display: block;
}

.context-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.1s, color 0.1s;
}

.context-item:hover {
  background: var(--danger);
  color: white;
}

/* --- Server Dropdown Menu --- */
.server-dropdown-menu {
  position: absolute;
  top: 52px;
  left: 8px;
  width: 224px; /* Fixed width matching sidebar content */
  background: #111214;
  border-radius: 4px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.6);
  padding: 6px;
  display: none;
  flex-direction: column;
  z-index: 9999;
  animation: dropdownFade 0.15s ease-out;
}

.server-dropdown-menu.active {
  display: flex;
}

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #B5BAC1;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.dropdown-item:hover {
  background: #4752C4;
  color: #fff;
}

.dropdown-item.invite {
  color: #5865F2;
}

.dropdown-item.invite:hover {
  background: #4752C4;
  color: #fff;
}

.dropdown-item svg {
  flex-shrink: 0;
  margin-left: 8px;
}

.dropdown-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 4px 6px;
}


@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes contextFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ============================================================ */
/*  STREAMING & VIDEO UI                                        */
/* ============================================================ */

.stream-container {
  background: #000;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  min-height: 300px;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
  transition: all 0.3s ease;
}

.stream-container:fullscreen {
  max-height: 100vh;
  width: 100vw;
  border-bottom: none;
}

.stream-container:fullscreen .stream-grid {
  padding: 60px 0 0 0;
  height: 100vh;
}

.stream-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.5);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  color: #fff;
  z-index: 110;
  backdrop-filter: blur(4px);
}

.stream-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 12px;
  padding: 56px 12px 12px;
  overflow-y: auto;
}

.stream-item {
  background: #1e1f22;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  aspect-ratio: 16/9;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.stream-item video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.stream-item video[hidden], .stream-pending[hidden],
.stop-broadcast-btn[hidden], .stream-join-card[hidden] { display: none; }

.stream-pending {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 14px;
}

.stream-join-card {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.62);
}

.stream-join-panel {
  position: relative;
  width: min(340px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.stream-join-panel h3 { margin: 14px 0 8px; }
.stream-join-panel p { color: var(--text-muted); margin: 0 0 20px; }
.stream-join-panel .close-stream-btn { width: 100%; padding: 10px; }
.stream-join-panel .close-stream-btn:disabled { opacity: .5; cursor: not-allowed; }
.stream-join-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 24px;
  cursor: pointer;
}

.stop-broadcast-btn { background: #d94b50; }

.stream-user-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0,0,0,0.7);
  padding: 4px 10px;
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-badge {
  background: #f04747; /* Default red */
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 800;
  animation: livePulse 2s infinite;
  box-shadow: 0 0 0 rgba(240, 71, 71, 0.4);
  margin-left: 6px;
  flex-shrink: 0;
}

.live-badge.green {
  background: #43B581; /* Discord Green */
  box-shadow: 0 0 0 rgba(67, 181, 129, 0.4);
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(67, 181, 129, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(67, 181, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(67, 181, 129, 0); }
}



/* Avatar Colors */
.avatar-color-0 { background-color: #5865f2 !important; }
.avatar-color-1 { background-color: #43b581 !important; }
/* --- iOS Style Toggle Switch --- */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #3e3f44;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: #30D158; /* iPhone Green */
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.custom-toggle-container {
  transition: background 0.2s;
}

.custom-toggle-container:hover {
  background: rgba(255,255,255,0.08) !important;
}
.avatar-color-2 { background-color: #faa61a !important; }
.avatar-color-3 { background-color: #f04747 !important; }
.avatar-color-4 { background-color: #7289da !important; }

.close-stream-btn {
  background: #43B581;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: filter 0.2s;
}

.close-stream-btn:hover {
  filter: brightness(1.1);
}

/* ======== SOURCE PICKER MODAL (Electron) ======== */
#sourcePickerModal {
    z-index: 20000;
}

.source-picker-card {
    background: #1E1F22;
    border-radius: 8px;
    width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: modalScale 0.2s ease-out;
}

.source-picker-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.source-picker-header h2 {
    color: #F2F3F5;
    font-size: 1.25rem;
    font-weight: 700;
}

.source-picker-close {
    background: none;
    border: none;
    color: #B5BAC1;
    font-size: 28px;
    cursor: pointer;
}

.source-picker-tabs {
    padding: 0 20px;
    border-bottom: 1px solid #2B2D31;
    display: flex;
    gap: 20px;
}

.source-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #B5BAC1;
    padding: 12px 4px;
    cursor: pointer;
    font-weight: 500;
}

.source-tab.active {
    color: #F2F3F5;
    border-bottom-color: #00D1B2;
}

.source-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    overflow-y: auto;
    flex: 1;
}

.source-grid-busy { pointer-events: none; opacity: .6; }
.source-audio-option { display: flex; align-items: flex-start; gap: 10px; padding: 8px 20px 14px; color: #F2F3F5; cursor: pointer; }
.source-audio-option input { margin-top: 3px; accent-color: #00D1B2; }
.source-audio-option small { display: block; color: #B5BAC1; font-size: 12px; margin-top: 3px; }
.source-picker-error { color: #F04747; padding: 0 20px 12px; margin: 0; font-size: 13px; }

.source-item {
    background: #2B2D31;
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    transition: background 0.1s;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.source-item:hover {
    background: #35373C;
}

.source-item.selected {
    background: #404249;
    box-shadow: 0 0 0 2px #00D1B2;
}

.source-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 2px;
    object-fit: cover;
}

.source-name {
    color: #F2F3F5;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.source-picker-footer {
    padding: 20px;
    background: #2B2D31;
    display: flex;
    justify-content: flex-end;
}

@keyframes modalScale {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-overlay.visible {
    display: flex;
}

.btn-danger {
  background: #f04747;
  color: white;
}

.btn-green {
  background: #43B581;
  color: white;
}

.btn-green:hover {
  background: #3ca374;
}

.context-menu {
  position: fixed;
  background: #111214;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  padding: 6px 0;
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  display: none;
  z-index: 20000;
}

.context-menu.active {
  display: block;
}

.context-item {
  padding: 8px 12px;
  font-size: 14px;
  color: #B5BAC1;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.context-item:hover {
  background: #4752C4;
  color: #fff;
}

.context-item svg {
  margin-right: 8px;
  opacity: 0.7;
}

.context-item:hover svg {
  opacity: 1;
}

#ctxDeleteChannel:hover {
  background: #f04747;
}


/* --- iOS Style Toggle Switch --- */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3e4147;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

input:checked + .slider {
    background-color: #34C759; /* iOS Green */
}

input:checked + .slider:before {
    transform: translateX(18px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}
/* --- DM Chat Section Styles --- */
.dm-chat-section {
    display: flex;
    flex-direction: column;
    background: #313338;
    height: 100%;
    width: 100%;
    position: relative;
}

.dm-chat-section .chat-header {
    background: #313338;
    border-bottom: 1px solid #1e1f22;
    height: 48px;
    padding: 0 16px;
    display: flex;
    align-items: center;
}

.dm-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column-reverse;
}

.dm-chat-item {
    padding: 8px 16px;
    display: flex;
    gap: 16px;
    transition: background 0.1s;
}

.dm-chat-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.dm-chat-content {
    display: flex;
    flex-direction: column;
}

.dm-chat-user {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 2px;
}

.dm-chat-text {
    font-size: 14px;
    color: #dbdee1;
    line-height: 1.3;
}

.dm-chat-section .message-input-container {
    padding: 0 16px 24px 16px;
    background: #313338;
}

.dm-chat-section .message-input-container div {
    background: #383a40;
    border-radius: 8px;
    padding: 10px 16px;
}

/* --- Muted State for Voice Controls --- */
.voice-control-btn.muted,
.icon-btn.muted {
  color: white !important;
  background-color: #00D1B2 !important;
  position: relative;
}

/* --- Voice User Status Icons (next to username in channel list) --- */
.voice-user-status-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  opacity: 0.9;
  vertical-align: middle;
}

/* Message Reactions & Actions */
.reactions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #2b2d31;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  border: 1px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}

.reaction-badge:hover {
  background: #35373c;
  border-color: #4e5058;
}

.reaction-badge.active {
  background: rgba(88,101,242,0.15);
  border-color: #5865f2;
}

.reaction-count {
  font-size: 12px;
  color: #b5bac1;
  font-weight: 600;
}

.reaction-badge.active .reaction-count {
  color: #5865f2;
}

/* --- Emoji Picker Panel --- */
.emoji-picker-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 280px;
  background: #2B2D31;
  border: 1px solid #1E1F22;
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.5);
  display: none;
  flex-direction: column;
  z-index: 2000;
  overflow: hidden;
  animation: slideUp 0.2s ease;
}

.emoji-picker-panel.active {
  display: flex;
}

.emoji-picker-header {
  padding: 10px 12px;
  background: rgba(0,0,0,0.1);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.emoji-item {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s, transform 0.1s;
}

.emoji-item:hover {
  background: rgba(255,255,255,0.08);
  transform: scale(1.15);
}

/* Spam Warning Shake Animation */
.shake-anim {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
    border-color: #f23f43 !important;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* ================================================================
   MOBILE RESPONSIVE STYLES
   ================================================================ */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 8px;
    margin-right: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.mobile-menu-btn:hover {
    background: rgba(255,255,255,0.05);
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }

    .mobile-close-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }

    .titlebar {
        display: none !important;
        height: 0 !important;
        pointer-events: none !important;
        visibility: hidden !important;
    }

    .chat-area {
        position: fixed;
        inset: 0 !important;
        height: 100dvh !important;
        display: flex;
        flex-direction: column;
        background: var(--bg-primary);
        z-index: 1;
        width: 100% !important;
    }

    .chat-header {
        height: 48px;
        z-index: 500;
        position: relative;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        display: flex;
        align-items: center;
        padding-top: env(safe-area-inset-top);
    }

    .messages-container {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .message-input-container {
        margin: 8px;
        margin-bottom: calc(12px + env(safe-area-inset-bottom));
        background: var(--bg-tertiary);
        z-index: 10;
        flex-shrink: 0;
    }

    .server-rail {
        position: fixed;
        left: -72px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--bg-rail);
        box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    }

    .sidebar-wrapper {
        position: fixed;
        left: -312px;
        top: 0;
        bottom: 0;
        z-index: 999;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    }

    /* Sidebar Active State */
    .sidebar-active .server-rail {
        left: 0;
    }
    .sidebar-active .sidebar-wrapper {
        left: 72px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.6);
        backdrop-filter: blur(2px);
        z-index: 900;
    }
    .sidebar-active .sidebar-overlay {
        display: block;
    }

    .user-bar, #userBar {
        position: fixed;
        right: -240px;
        top: 0;
        bottom: 0;
        width: 240px;
        z-index: 1001;
        background: var(--bg-secondary);
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex !important;
        box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    }

    .member-list-active .user-bar {
        right: 0;
    }
}

/* ================================================================
   Unified navigation shell. Keep these rules scoped to the app so
   authentication, modals, settings, and saved theme previews retain
   their own layouts.
   ================================================================ */
.app-container {
  background: var(--bg-tertiary);
}

.app-container .sidebar-wrapper {
  width: 272px;
  min-width: 272px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow: visible;
  position: relative;
  z-index: 20;
}

.app-container .server-rail {
  width: 100%;
  min-width: 0;
  height: 76px;
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  gap: 7px;
  align-items: center;
  overflow: visible;
  position: relative;
  padding: 10px 12px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 35px;
  height: 35px;
  flex: 0 0 35px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: var(--bg-tertiary);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -2px;
}
.brand-and-server { min-width: 0; flex: 1; }
.brand-name {
  display: block;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 800;
  line-height: 17px;
  letter-spacing: 2px;
}
.server-picker { position: static; flex: 0 0 30px; }
.server-selector {
  width: 30px;
  height: 30px;
  min-width: 30px;
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-accent);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.server-selector:hover, .server-selector:focus-visible {
  background: var(--bg-modifier-active);
  border-color: var(--accent);
  color: var(--accent);
}
.server-selector-label {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--text-secondary);
  font: 600 12px/18px var(--font);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.server-picker .selector-chevron {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: currentColor;
}
.server-picker .selector-chevron svg {
  width: 20px;
  height: 20px;
  display: block;
}
/* Source: Iconly/Light-Outline/Arrow - Down Square, https://web.iconly.pro/?is_free=1&keyword=arrow+down. See https://iconly.pro/pages/licensing-guide for usage guidance. */
.app-container .server-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  flex: 0 0 30px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-accent);
  color: var(--text-secondary);
  font-size: 21px;
  line-height: 1;
}
.app-container .server-icon:hover,
.app-container .server-icon.active {
  border-radius: 10px;
  background: var(--bg-modifier-active);
  border-color: var(--accent);
  color: var(--accent);
  transform: none;
}
.app-container .server-icon::before { display: none; }
.app-container .add-server { border-style: solid; }
.server-list {
  display: none;
  position: absolute;
  z-index: 100;
  top: calc(100% - 8px);
  left: 10px;
  right: 10px;
  width: auto;
  max-height: min(55vh, 440px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-floating);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
}
.server-picker.open .server-list { display: block; }
.server-option-empty { padding: 12px; color: var(--text-secondary); font-size: 12px; }
.server-option {
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
}
.server-option:hover, .server-option:focus-visible { background: var(--bg-modifier-hover); outline: none; }
.server-option.active { background: var(--bg-modifier-active); }
.server-option-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--bg-modifier-active);
  color: white;
  font-size: 13px;
  font-weight: 700;
}
.server-option-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.server-option .server-delete-btn {
  position: static;
  width: 25px;
  height: 25px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  opacity: 0;
}
.server-option:hover .server-delete-btn,
.server-option:focus-within .server-delete-btn { opacity: 1; }
.server-option .server-delete-btn:hover { background: var(--danger); color: white; }

.app-container .sidebar {
  width: 100%;
  min-width: 0;
  background: var(--bg-sidebar);
}
.app-container .sidebar-header {
  height: 52px;
  padding: 0 14px 0 18px;
  cursor: default;
  box-shadow: none;
  border-bottom: 1px solid var(--border);
}
.app-container .sidebar-header:hover { background: transparent; }
.app-container .sidebar-header h2 { flex: 1; min-width: 0; font-size: 14px; }
.app-container .sidebar-dropdown-btn {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  justify-content: center;
  border-radius: 8px;
}
.app-container .sidebar-dropdown-btn:hover { background: var(--bg-modifier-hover); color: var(--text-primary); }
.app-container .server-dropdown-menu {
  width: min(244px, calc(100% - 20px));
  top: 46px;
  left: 10px;
  background: var(--bg-floating);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.app-container .dropdown-item { color: var(--text-primary); border-radius: 6px; }
.app-container .dropdown-item:hover,
.app-container .dropdown-item.invite:hover { background: var(--bg-modifier-active); color: var(--text-primary); }
.app-container .dropdown-item.invite { color: var(--accent); }
.app-container .channel-list { padding: 10px 0; }
.app-container .channel-category { min-height: 37px; padding: 12px 12px 5px 18px; }
.app-container .channel-category-title { color: var(--text-secondary); letter-spacing: 1px; }
.app-container .channel-item {
  min-height: 36px;
  margin: 2px 10px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
}
.app-container .channel-item.active { background: var(--bg-modifier-active); color: var(--text-primary); }
.app-container .channel-item.active .channel-icon { color: var(--accent); }
.app-container .user-panel { border-top: 1px solid var(--border); background: var(--bg-sidebar); }
.app-container .chat-area { background: var(--bg-primary); }
.app-container .chat-header { min-height: 54px; border-bottom-color: var(--border); }
.app-container .messages-container { background: var(--bg-primary); }
.app-container .user-bar {
  width: 224px;
  min-width: 224px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
}
.app-container .user-bar.hidden { width: 0; min-width: 0; padding: 0; border: 0; }
.app-container .sidebar-overlay { display: none; }

@media (min-width: 900px) and (max-width: 1279px) {
  .app-container .sidebar-wrapper { width: 252px; min-width: 252px; }
}

@media (max-width: 1279px) {
  .app-container .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(2, 12, 16, .64);
    backdrop-filter: blur(2px);
  }
  .app-container .user-bar,
  .app-container #userBar {
    position: fixed;
    display: flex !important;
    flex-direction: column;
    top: 0;
    bottom: 0;
    right: -260px;
    z-index: 1001;
    width: 260px;
    min-width: 260px;
    box-shadow: -12px 0 30px rgba(0,0,0,.3);
    transition: right .2s ease;
  }
  body.member-list-active .app-container #userBar { right: 0; }
  body.member-list-active .app-container .sidebar-overlay { display: block; }
}

@media (max-width: 899px) {
  .app-container .sidebar-wrapper {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -280px;
    width: min(280px, 88vw);
    min-width: 0;
    z-index: 1000;
    box-shadow: 12px 0 30px rgba(0,0,0,.3);
    transition: left .2s ease;
  }
  body.sidebar-active .app-container .sidebar-wrapper { left: 0; }
  .app-container .server-rail {
    position: static;
    width: 100%;
    height: 76px;
    min-width: 0;
    box-shadow: none;
  }
  .app-container .sidebar { position: static; width: 100%; height: auto; }
  .app-container .chat-area { width: 100%; }
  .app-container .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  .app-container .mobile-close-btn { display: flex !important; align-items: center; justify-content: center; }
  body.sidebar-active .app-container .sidebar-overlay { display: block; }
}

@media (max-width: 768px) {
  .app-container .chat-area { background: var(--bg-primary); }
  .app-container .chat-header { background: var(--bg-primary); }
}

@media (max-width: 599px) {
  .app-container .chat-header {
    min-width: 0;
    gap: 7px;
    padding-inline: 10px;
    overflow: hidden;
  }
  .app-container .chat-header h3 {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }
  .app-container .chat-header-divider,
  .app-container .chat-header-topic { display: none; }
  .app-container .chat-header-actions {
    flex: 0 0 auto;
    gap: 2px;
  }
  .app-container .mobile-menu-btn {
    min-width: 40px;
    width: 40px;
    min-height: 40px;
    margin-right: 0;
    padding: 7px;
    flex-shrink: 0;
  }
  .app-container .channel-hash { width: 18px; }
  .app-container .chat-header-actions .icon-btn,
  .app-container .vibe-selector-btn {
    width: 40px;
    min-width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
  }
  .app-container .vibe-selector-btn { font-size: 0; }
  .app-container .vibe-selector-btn svg { width: 19px; height: 19px; margin-right: 0 !important; }
}

