/* ===== HAUNT — Dark Theme ===== */

:root {
  --bg-tertiary: #1e1f22;
  --bg-secondary: #2b2d31;
  --bg-secondary-alt: #232428;
  --bg-primary: #313338;
  --bg-modifier-hover: rgba(79, 84, 92, 0.16);
  --bg-modifier-active: rgba(79, 84, 92, 0.24);
  --bg-modifier-selected: rgba(79, 84, 92, 0.32);
  --bg-floating: #111214;
  --bg-input: #383a40;
  --text-normal: #dbdee1;
  --text-muted: #949ba4;
  --text-faint: #6d6f78;
  --text-link: #00a8fc;
  --header-primary: #f2f3f5;
  --header-secondary: #b5bac1;
  --brand: #5865f2;
  --brand-hover: #4752c4;
  --green: #23a559;
  --red: #f23f43;
  --yellow: #fee75c;
  --channel-icon: #80848e;
  --interactive-normal: #b5bac1;
  --interactive-hover: #dbdee1;
  --interactive-active: #fff;
  --scrollbar-thin: #1a1b1e;
  --scrollbar-thumb: #1a1b1e;
  --divider: rgba(255, 255, 255, 0.06);
  --elevation-low: 0 1px 0 rgba(0,0,0,.2), 0 1.5px 0 rgba(0,0,0,.05), 0 2px 0 rgba(0,0,0,.025);
  --elevation-high: 0 8px 16px rgba(0,0,0,.24);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-full: 50%;
  --transition-fast: 150ms ease;
}

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

html, body {
  height: 100%;
  font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 16px;
  color: var(--text-normal);
  background: var(--bg-tertiary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text-link); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #242528; }
::-webkit-scrollbar-corner { background: transparent; }

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

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg-tertiary);
}

.auth-container {
  width: 100%;
  max-width: 480px;
  padding: 32px;
}

.auth-box {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 32px;
  box-shadow: var(--elevation-high);
}

.auth-box h2 {
  color: var(--header-primary);
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--text-muted);
  text-align: center;
  font-size: 14px;
  margin-bottom: 20px;
}

.auth-box label {
  display: block;
  color: var(--header-secondary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  margin-top: 16px;
}

.auth-box label .required { color: var(--red); }

.auth-box input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  font-size: 16px;
  outline: none;
  transition: box-shadow var(--transition-fast);
}

.auth-box input:focus {
  box-shadow: 0 0 0 2px var(--brand);
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 24px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--bg-tertiary);
  color: var(--text-normal);
  font-size: 15px;
  font-weight: 600;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--brand);
}

.auth-divider {
  margin: 16px 0 10px;
  color: var(--text-muted);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.oauth-btn {
  margin-bottom: 8px;
}

.auth-switch {
  margin-top: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.auth-error {
  background: rgba(242, 63, 67, 0.1);
  border-left: 4px solid var(--red);
  color: var(--red);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 8px;
  display: none;
}
.auth-error.visible { display: block; }

/* ===== MAIN APP LAYOUT ===== */

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* --- Server List (far left) --- */

#server-list {
  width: 72px;
  min-width: 72px;
  background: var(--bg-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  overflow-y: auto;
  -webkit-app-region: drag;
  padding-top: 20px;
}
#server-list > * { -webkit-app-region: no-drag; }

.server-icon {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--interactive-normal);
  background: var(--bg-primary);
  cursor: pointer;
  transition: border-radius var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
  user-select: none;
  flex-shrink: 0;
}
.server-icon:hover {
  border-radius: var(--radius-lg);
  color: #fff;
}
.server-icon.active {
  border-radius: var(--radius-lg);
}
.server-icon.home-btn:hover,
.server-icon.home-btn.active {
  background: var(--brand);
  color: #fff;
}
.ghost-home-icon {
  width: 28px;
  height: 28px;
  color: currentColor;
}
.server-icon.add-server-btn:hover {
  background: var(--green);
  border-radius: var(--radius-lg);
}
.server-icon.add-server-btn:hover svg path { stroke: #fff; }

/* Pill indicator for active server */
.server-icon::before {
  content: '';
  position: absolute;
  left: -16px;
  width: 8px;
  height: 0;
  background: var(--header-primary);
  border-radius: 0 4px 4px 0;
  transition: height var(--transition-fast);
}
.server-icon:hover::before { height: 20px; }
.server-icon.active::before { height: 40px; }

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

#server-icons {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* --- Channel Sidebar --- */

#channel-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
}

#server-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--elevation-low);
  font-weight: 600;
  font-size: 15px;
  color: var(--header-primary);
  cursor: default;
  flex-shrink: 0;
  -webkit-app-region: drag;
}
#server-header > * { -webkit-app-region: no-drag; }

.icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--channel-icon);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.icon-btn:hover { color: var(--interactive-hover); background: var(--bg-modifier-hover); }

#channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
  padding-top: 16px;
}

.home-section-label {
  padding: 14px 8px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--channel-icon);
}

.home-dm-item .dm-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.home-dm-item .dm-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-pending-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.channel-category {
  padding: 18px 0 4px 0;
}

.channel-category-name {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px 0 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--channel-icon);
  cursor: default;
  user-select: none;
}

.channel-category-name .category-label {
  flex: 1;
}

.channel-category-name .category-add-btn {
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  padding: 0 2px;
  margin-left: auto;
  color: var(--channel-icon);
  border-radius: 3px;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.channel-category-name .category-add-btn:hover {
  color: var(--text-primary);
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 12px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--channel-icon);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
}
.channel-item:hover { background: var(--bg-modifier-hover); color: var(--interactive-hover); }
.channel-item.active { background: var(--bg-modifier-selected); color: var(--interactive-active); }

.channel-item .hash-icon,
.channel-item .channel-icon-text {
  font-size: 20px;
  font-weight: 500;
  opacity: 0.6;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* Voice channel styling */
.channel-item .channel-icon-voice {
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.6;
}
.channel-item .channel-icon-voice svg { fill: currentColor; }
.channel-item.voice-active { color: var(--green); }
.channel-item.voice-active .channel-icon-voice { opacity: 1; }

#create-channel-area {
  padding: 8px 16px 8px;
}

.text-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--channel-icon);
  padding: 4px 0;
  transition: color var(--transition-fast);
}
.text-btn:hover { color: var(--interactive-hover); }

/* User Panel (bottom of channel sidebar) */

#user-panel {
  height: 52px;
  padding: 0 8px;
  background: var(--bg-secondary-alt);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

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

#user-panel-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--header-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#user-panel-status {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Chat Area --- */

#chat-area {
  flex: 1;
  min-width: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

#home-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.home-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--elevation-low);
  color: var(--header-primary);
  flex-shrink: 0;
}

.home-title {
  font-size: 16px;
  font-weight: 700;
}

.home-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
}

.friends-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.friends-tab {
  padding: 6px 10px;
  font-size: 14px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  background: transparent;
}

.friends-tab:hover {
  color: var(--interactive-hover);
  background: var(--bg-modifier-hover);
}

.friends-tab.active {
  color: var(--interactive-active);
  background: var(--bg-modifier-selected);
}

.friend-list {
  display: flex;
  flex-direction: column;
}

.friend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-top: 1px solid var(--divider);
}

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

.friend-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.friend-meta {
  min-width: 0;
  flex: 1;
}

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

.friend-subtext {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.friend-actions {
  display: flex;
  gap: 8px;
}

.friend-action-btn {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  color: var(--interactive-normal);
  background: var(--bg-secondary);
}

.friend-action-btn:hover {
  color: var(--interactive-hover);
  background: var(--bg-modifier-selected);
}

.friend-action-btn.primary {
  background: var(--brand);
  color: #fff;
}

.friend-action-btn.primary:hover {
  background: var(--brand-hover);
}

#channel-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--elevation-low);
  font-weight: 600;
  font-size: 16px;
  color: var(--header-primary);
  flex-shrink: 0;
  z-index: 1;
}

#channel-header .hash {
  color: var(--channel-icon);
  font-size: 24px;
  font-weight: 400;
  margin-right: 2px;
}

#messages-container {
  flex: 1;
  height: 0;
  overflow-y: auto;
  padding: 16px 0;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#messages-list {
  padding: 0 16px;
  min-height: 100%;
}

/* Message styles */

.message-group {
  padding: 4px 0;
  display: flex;
  gap: 16px;
  margin-top: 16px;
  position: relative;
}
.message-group:hover {
  background: var(--bg-modifier-hover);
  border-radius: var(--radius-sm);
}

.message-group .msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}

.message-group .msg-body {
  flex: 1;
  min-width: 0;
}

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

.msg-username {
  font-size: 15px;
  font-weight: 600;
  color: var(--header-primary);
  cursor: pointer;
}
.msg-username:hover { text-decoration: underline; }

.msg-owner { color: #f0b232; }
.msg-admin { color: #57f287; }

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

.msg-content {
  font-size: 15px;
  line-height: 1.375;
  color: var(--text-normal);
  word-wrap: break-word;
  white-space: pre-wrap;
}

/* Message hover actions */
.msg-actions {
  position: absolute;
  top: -16px;
  right: 4px;
  display: none;
  background: var(--bg-secondary);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  box-shadow: var(--elevation-high);
  overflow: hidden;
}
.message-group:hover .msg-actions,
.message-compact:hover .msg-actions {
  display: flex;
}
.msg-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--interactive-normal);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.msg-action-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--interactive-hover);
}
.msg-action-btn.danger:hover {
  background: rgba(242, 63, 67, 0.15);
  color: var(--red);
}

/* Edited tag */
.msg-edited {
  font-size: 11px;
  color: var(--text-muted);
  cursor: default;
  margin-left: 4px;
}

/* Inline edit form */
.msg-edit-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.msg-edit-form textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.375;
  resize: none;
  outline: none;
}
.msg-edit-form textarea:focus {
  box-shadow: 0 0 0 1px var(--brand);
}
.msg-edit-actions {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.msg-edit-actions span {
  cursor: pointer;
}
.msg-edit-actions span:hover {
  color: var(--text-link);
  text-decoration: underline;
}

/* Reply preview above message */
.msg-reply-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0 4px 0;
  margin-left: 56px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}
.msg-reply-preview:hover {
  color: var(--text-normal);
}
.msg-reply-preview .reply-icon {
  width: 16px;
  height: 16px;
  color: var(--channel-icon);
  flex-shrink: 0;
}
.msg-reply-preview .reply-author {
  font-weight: 600;
  color: var(--interactive-normal);
  margin-right: 4px;
  flex-shrink: 0;
}
.msg-reply-preview .reply-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Reply bar above message input */
#reply-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  margin: 0 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
#reply-bar.active {
  display: flex;
}
#reply-bar.active + #message-input-container #message-form {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
#reply-bar .reply-bar-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#reply-bar .reply-bar-text strong {
  color: var(--interactive-normal);
}
#reply-bar .reply-bar-close {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--channel-icon);
  cursor: pointer;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
#reply-bar .reply-bar-close:hover {
  color: var(--interactive-hover);
  background: var(--bg-modifier-hover);
}

/* @mention highlight */
.mention {
  background: rgba(88, 101, 242, 0.3);
  color: var(--brand);
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 500;
  cursor: pointer;
}
.mention:hover {
  background: rgba(88, 101, 242, 0.5);
  text-decoration: underline;
}

/* Mention autocomplete dropdown */
#mention-autocomplete {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-floating);
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-high);
  padding: 4px;
  z-index: 10;
  margin-bottom: 4px;
}
#mention-autocomplete.active {
  display: block;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-normal);
}
.mention-item:hover, .mention-item.selected {
  background: var(--bg-modifier-hover);
}
.mention-item .mention-avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

/* Channel category collapse arrow */
.channel-category-name .collapse-arrow {
  font-size: 10px;
  transition: transform var(--transition-fast);
  cursor: pointer;
}
.channel-category-name .collapse-arrow.collapsed {
  transform: rotate(-90deg);
}

/* Compact follow-up messages (same user, close in time) */
.message-compact {
  padding: 2px 0 2px 56px;
  position: relative;
}
.message-compact:hover {
  background: var(--bg-modifier-hover);
  border-radius: var(--radius-sm);
}
.message-compact .compact-time {
  display: none;
  font-size: 11px;
  color: var(--text-muted);
  position: absolute;
  left: 0;
  width: 56px;
  text-align: center;
  top: 4px;
}
.message-compact:hover .compact-time { display: block; }

/* Welcome message */
.welcome-message {
  padding: 16px;
  margin: 16px;
}
.welcome-message h3 {
  font-size: 24px;
  color: var(--header-primary);
  margin-bottom: 8px;
}
.welcome-message p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Typing indicator */
#typing-indicator {
  min-height: 24px;
  padding: 0 16px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.typing-dots {
  display: inline-flex;
  gap: 2px;
  margin-right: 4px;
}
.typing-dots span {
  width: 4px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Message Input */
#message-input-container {
  padding: 0 16px 24px;
  flex-shrink: 0;
}

#message-form {
  background: var(--bg-input);
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-end;
}

#message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-normal);
  font-size: 15px;
  font-family: inherit;
  padding: 12px 16px;
  resize: none;
  outline: none;
  max-height: 200px;
  line-height: 1.375;
}
#message-input::placeholder { color: var(--text-faint); }

/* --- Members Sidebar --- */

#members-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  padding: 16px 8px;
  overflow-y: auto;
}

.members-category {
  padding: 16px 8px 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--channel-icon);
  user-select: none;
}

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

.member-item .avatar-sm {
  position: relative;
}

.member-item .status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}
.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--text-faint); }

.member-item .member-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--channel-icon);
  transition: color var(--transition-fast);
}
.member-item:hover .member-name { color: var(--interactive-hover); }
.member-item .member-name.online-name { color: var(--interactive-normal); }

.member-item.offline-member {
  opacity: 0.5;
}

/* Role badge */
.role-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: auto;
}
.role-badge.owner { background: rgba(240, 178, 50, 0.15); color: #f0b232; }
.role-badge.admin { background: rgba(87, 242, 135, 0.15); color: #57f287; }

/* ===== MODALS ===== */

#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

#modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 24px;
  width: 440px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--elevation-high);
  animation: modal-slide 0.2s ease;
}

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

#modal-content h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--header-primary);
  text-align: center;
  margin-bottom: 8px;
}

#modal-content p {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 16px;
}

#modal-content label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--header-secondary);
  margin-bottom: 8px;
  margin-top: 12px;
}

#modal-content input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  font-size: 16px;
  outline: none;
}
#modal-content input:focus { box-shadow: 0 0 0 2px var(--brand); }
/* Override for wrapped inputs — focus ring goes on wrapper */
.channel-name-input-wrap input { box-shadow: none !important; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.btn-cancel {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-normal);
  background: none;
  border: none;
  cursor: pointer;
}
.btn-cancel:hover { text-decoration: underline; }

.btn-submit {
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--brand);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.btn-submit:hover { background: var(--brand-hover); }

/* Danger buttons */
.btn-danger {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--red);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), opacity var(--transition-fast);
}
.btn-danger:hover { opacity: 0.85; }

.btn-danger-outline {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
  background: transparent;
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.btn-danger-outline:hover {
  background: var(--red);
  color: #fff;
}

/* Invite code display */
.invite-code-display {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.invite-code-display code {
  font-size: 18px;
  font-weight: 600;
  color: var(--header-primary);
  letter-spacing: 0.05em;
  font-family: 'Consolas', 'Courier New', monospace;
}

.btn-copy {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.btn-copy:hover { background: var(--brand-hover); }

/* Discord import section */
.discord-import-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
}
.discord-import-section h4 {
  font-size: 14px;
  color: var(--header-primary);
  margin-bottom: 8px;
}
.discord-import-group {
  margin-top: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.discord-import-group h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--header-secondary);
}
.discord-import-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}
.discord-import-option {
  display: flex !important;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  font-size: 13px !important;
  color: var(--text-normal) !important;
  text-transform: none !important;
  font-weight: 500 !important;
  letter-spacing: normal !important;
}
.discord-import-option input {
  width: auto !important;
  margin: 0;
}
.discord-day-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.discord-day-label {
  margin-top: 0 !important;
}
#modal-content select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  font-size: 14px;
  outline: none;
}
#modal-content select:focus { box-shadow: 0 0 0 2px var(--brand); }
.discord-import-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.discord-import-status.error {
  color: #ffb3b8;
  border-color: rgba(237, 66, 69, 0.5);
}
.discord-import-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.discord-import-actions .btn-submit,
.discord-import-actions .btn-cancel,
.discord-import-actions .btn-danger-outline {
  width: 100%;
  padding: 8px 10px;
}

/* Modal tabs */
.modal-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--divider);
}
.modal-tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.modal-tab:hover { color: var(--interactive-hover); }
.modal-tab.active { color: var(--interactive-active); border-bottom-color: var(--brand); }

/* Channel type selector in create channel modal */
.channel-type-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.channel-type-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.channel-type-option:hover { background: var(--bg-modifier-hover); }
.channel-type-option.selected { border-color: var(--brand); }
.channel-type-option input[type="radio"] { display: none; }

/* Radio circle */
.channel-type-radio {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  border: 2px solid var(--interactive-normal);
  flex-shrink: 0;
  position: relative;
  transition: border-color var(--transition-fast);
}
.channel-type-option.selected .channel-type-radio {
  border-color: var(--brand);
}
.channel-type-option.selected .channel-type-radio::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  background: var(--brand);
}

.channel-type-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--interactive-normal);
  flex-shrink: 0;
}
.channel-type-option.selected .channel-type-icon { color: var(--interactive-active); }
.channel-type-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.channel-type-label strong {
  color: var(--header-primary);
  font-size: 15px;
  font-weight: 600;
}
.channel-type-label span {
  color: var(--text-muted);
  font-size: 13px;
}

/* Channel name input with icon prefix */
.channel-name-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.channel-name-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 10px 12px 10px 0;
  color: var(--text-normal);
  font-size: 16px;
  font-family: inherit;
}
.channel-name-input-wrap:focus-within {
  box-shadow: 0 0 0 2px var(--brand);
}
.channel-name-prefix {
  padding-left: 12px;
  color: var(--channel-icon);
  font-size: 18px;
  font-weight: 500;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.channel-name-prefix svg { fill: var(--channel-icon); }

/* ===== UTILITIES ===== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  text-align: center;
}

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

/* Tooltip */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-floating);
  color: var(--header-primary);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 999;
  box-shadow: var(--elevation-high);
}
[data-tooltip]:hover::after { opacity: 1; }

/* macOS traffic light spacing */
@media screen {
  #server-list { padding-top: 20px; }
}

/* ===== VOICE PANEL ===== */

#voice-panel {
  background: var(--bg-secondary-alt);
  padding: 0;
  border-top: 1px solid var(--divider);
  flex-shrink: 0;
}

#voice-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 4px;
}

#voice-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

#voice-signal-icon {
  flex-shrink: 0;
  color: var(--green);
  width: 20px;
  height: 20px;
}

#voice-status-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#voice-status-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  line-height: 1.2;
}

#voice-channel-name {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-disconnect-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--interactive-normal);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.voice-disconnect-btn:hover {
  background: var(--bg-modifier-hover);
  color: var(--red);
}

#voice-controls {
  display: flex;
  gap: 4px;
  padding: 4px 8px 8px;
}

.voice-ctrl-btn {
  flex: 1;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  color: var(--interactive-normal);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.voice-ctrl-btn:hover { background: var(--bg-modifier-hover); color: var(--interactive-hover); }
.voice-ctrl-btn.active { background: #fff2; color: var(--red); }
.voice-ctrl-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.voice-ctrl-btn:disabled:hover { background: var(--bg-primary); color: var(--interactive-normal); }

/* Voice user list under channel in sidebar */
.voice-user-list {
  padding: 2px 0 2px 28px;
}
.voice-user-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  font-size: 13px;
  color: var(--channel-icon);
}
.voice-user-item .voice-user-avatar {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  transition: box-shadow 0.15s ease;
}
.voice-user-item .voice-user-avatar.speaking {
  box-shadow: 0 0 0 2px var(--green);
}

/* ===== VOICE SETTINGS ===== */
.voice-settings label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.settings-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 8px 0;
}
.sensitivity-control {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sensitivity-control input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  outline: none;
}
.sensitivity-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand);
  cursor: pointer;
}
.sensitivity-control span {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
}
.mic-test-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mic-test-bar-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mic-test-bar-bg {
  position: relative;
  height: 12px;
  background: var(--bg-primary);
  border-radius: 6px;
  overflow: visible;
}
.mic-test-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--brand);
  border-radius: 6px;
  transition: width 0.05s linear;
}
.mic-test-bar-threshold {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--red);
  border-radius: 1px;
}
#mic-test-status {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== ATTACHMENTS ===== */

/* Image attachment */
.msg-attachment-img {
  margin-top: 4px;
  max-width: 400px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  display: inline-block;
}
.msg-attachment-img img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: var(--radius-md);
  transition: opacity var(--transition-fast);
}
.msg-attachment-img:hover img { opacity: 0.85; }

/* File attachment card */
.msg-attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--divider);
  text-decoration: none;
  margin-top: 4px;
  min-width: 300px;
  max-width: 420px;
  transition: background var(--transition-fast);
}
.msg-attachment-file:hover { background: var(--bg-modifier-hover); }
.msg-attachment-file-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--interactive-normal);
  flex-shrink: 0;
}
.msg-attachment-file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.msg-attachment-file-info .file-name {
  color: var(--text-link);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-attachment-file-info .file-name:hover { text-decoration: underline; }
.msg-attachment-file-info .file-size {
  color: var(--text-muted);
  font-size: 12px;
}
.msg-attachment-file-download {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--interactive-normal);
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.msg-attachment-file:hover .msg-attachment-file-download { color: var(--interactive-hover); background: var(--bg-modifier-hover); }

/* Upload button in message form */
.upload-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--interactive-normal);
  cursor: pointer;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}
.upload-btn:hover { color: var(--interactive-hover); }

/* Upload preview area */
#upload-preview {
  display: none;
  padding: 16px 16px 0;
  margin: 0 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: 1px solid var(--divider);
}
#upload-preview.active { display: block; }

#upload-preview-card {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  background: var(--bg-primary);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 280px;
}
#upload-preview-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: var(--bg-floating);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  z-index: 1;
  transition: color var(--transition-fast), background var(--transition-fast);
}
#upload-preview-close:hover { color: var(--interactive-hover); background: var(--red); }

#upload-preview-thumb {
  width: 280px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  overflow: hidden;
}
#upload-preview-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
#upload-preview-file-icon {
  color: var(--interactive-normal);
}

#upload-preview-info {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#upload-preview-info .upload-name {
  font-size: 13px;
  color: var(--text-link);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#upload-preview-info .upload-size {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== EMOJI PICKER ===== */

#emoji-picker {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  width: 352px;
  max-height: 360px;
  background: var(--bg-floating);
  border-radius: var(--radius-md);
  box-shadow: var(--elevation-high);
  z-index: 20;
  margin-bottom: 4px;
  overflow: hidden;
  flex-direction: column;
}
#emoji-picker.active { display: flex; }
#emoji-search {
  padding: 8px 12px;
  margin: 8px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  font-size: 14px;
  outline: none;
  width: calc(100% - 16px);
}
#emoji-search::placeholder { color: var(--text-faint); }
#emoji-categories {
  display: flex;
  gap: 2px;
  padding: 0 8px 4px;
  border-bottom: 1px solid var(--divider);
}
.emoji-cat-btn {
  padding: 4px 6px;
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  opacity: 0.6;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}
.emoji-cat-btn:hover, .emoji-cat-btn.active { opacity: 1; background: var(--bg-modifier-hover); }
#emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
  max-height: 260px;
}
.emoji-cell {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.emoji-cell:hover { background: var(--bg-modifier-hover); }
.emoji-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--interactive-normal);
  cursor: pointer;
  flex-shrink: 0;
  font-size: 22px;
  transition: color var(--transition-fast);
}
.emoji-btn:hover { color: var(--interactive-hover); }

/* ===== PROFILE POPOUT ===== */

.profile-popout {
  width: 340px;
}
.profile-popout .profile-banner {
  height: 60px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  position: relative;
}
.profile-popout .profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  color: #fff;
  border: 6px solid var(--bg-primary);
  position: absolute;
  bottom: -40px;
  left: 16px;
}
.profile-popout .profile-body {
  padding: 48px 16px 16px;
}
.profile-popout .profile-username {
  font-size: 20px;
  font-weight: 600;
  color: var(--header-primary);
}
.profile-popout .profile-divider {
  height: 1px;
  background: var(--divider);
  margin: 12px 0;
}
.profile-popout .profile-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--header-secondary);
  margin-bottom: 6px;
}
.profile-popout .profile-bio {
  font-size: 14px;
  color: var(--text-normal);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.profile-popout .profile-meta {
  font-size: 13px;
  color: var(--text-muted);
}
.profile-popout .profile-edit-bio {
  width: 100%;
  padding: 8px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-normal);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  margin-top: 4px;
}
.profile-popout .profile-edit-bio:focus { box-shadow: 0 0 0 1px var(--brand); }

/* ===== MOBILE HEADER (hidden on desktop) ===== */

#mobile-header {
  display: none;
  height: 48px;
  padding: 0 12px;
  background: var(--bg-primary);
  box-shadow: var(--elevation-low);
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
}

#mobile-header button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--interactive-normal);
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}
#mobile-header button:active {
  background: var(--bg-modifier-active);
}

#mobile-channel-name {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--header-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* Mobile overlay backdrop */
#mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
#mobile-overlay.visible {
  opacity: 1;
}

/* ===== RESPONSIVE ===== */

/* Tablet: hide members sidebar */
@media (max-width: 1100px) {
  #members-sidebar { display: none; }
}

/* Small tablet: narrow channel sidebar */
@media (max-width: 800px) {
  #channel-sidebar { width: 200px; min-width: 200px; }
}

/* ===== MOBILE (phones, <768px) ===== */
@media (max-width: 768px) {
  /* Show mobile header */
  #mobile-header { display: flex; }

  /* Hide desktop channel header (mobile header replaces it) */
  #channel-header { display: none; }

  /* App becomes a stacking column for mobile-header + chat */
  #app {
    flex-direction: column;
  }

  /* ── Server list: slide-in from left ── */
  #server-list {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 72px;
    z-index: 120;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding-top: 12px;
  }
  #server-list.mobile-open {
    transform: translateX(0);
  }

  /* ── Channel sidebar: slide-in from left (next to server list) ── */
  #channel-sidebar {
    position: fixed;
    top: 0;
    left: 72px;
    bottom: 0;
    width: 260px;
    min-width: 260px;
    z-index: 110;
    transform: translateX(calc(-100% - 72px));
    transition: transform 0.25s ease;
  }
  #channel-sidebar.mobile-open {
    transform: translateX(0);
  }

  /* When sidebars open, overlay becomes visible */
  #server-list.mobile-open ~ #mobile-overlay,
  #channel-sidebar.mobile-open ~ #mobile-overlay {
    display: block !important;
  }

  /* ── Members sidebar: slide-in from right ── */
  #members-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    min-width: 280px;
    z-index: 110;
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }
  #members-sidebar.mobile-open {
    transform: translateX(0);
  }

  /* ── Chat area: full width ── */
  #chat-area {
    flex: 1;
    width: 100%;
    min-height: 0;
  }

  /* ── Message input: mobile-friendly ── */
  #message-input-container {
    padding: 0 8px 12px;
  }

  #message-input {
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 10px 12px;
  }

  /* ── Messages: tighter padding on mobile ── */
  #messages-list {
    padding: 0 8px;
  }

  .message-group {
    gap: 10px;
  }

  .message-group .msg-avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .message-compact {
    padding-left: 46px;
  }
  .message-compact .compact-time {
    width: 46px;
  }

  .msg-reply-preview {
    margin-left: 46px;
  }

  /* ── Larger touch targets ── */
  .channel-item {
    padding: 10px 8px;
    font-size: 16px;
  }

  .member-item {
    padding: 10px 8px;
  }

  .server-icon {
    width: 44px;
    height: 44px;
  }

  /* ── Emoji picker: full width on mobile ── */
  #emoji-picker {
    width: calc(100vw - 16px);
    right: -8px;
    max-height: 50vh;
  }

  /* ── Upload preview: tighter ── */
  #upload-preview {
    margin: 0 8px;
    padding: 12px 12px 0;
  }

  /* ── Reply bar: tighter ── */
  #reply-bar {
    margin: 0 8px;
  }

  /* ── Attachment images: constrain to screen width ── */
  .msg-attachment-img {
    max-width: 100%;
  }
  .msg-attachment-file {
    min-width: 0;
    max-width: 100%;
  }

  /* ── Tooltips: hide on touch (they break on mobile) ── */
  [data-tooltip]::after {
    display: none;
  }

  /* ── Voice panel: touch-friendly buttons ── */
  .voice-ctrl-btn {
    height: 40px;
  }

  /* ── Modal: full-width on mobile ── */
  #modal-content {
    width: calc(100vw - 32px);
    max-height: 90vh;
    overflow-y: auto;
  }

  /* ── Auth screen: no side padding waste ── */
  .auth-container {
    padding: 16px;
  }
  .auth-box {
    padding: 24px 20px;
  }

  /* ── Typing indicator: tighter ── */
  #typing-indicator {
    padding: 0 8px;
  }

  /* ── Hover states → active states on mobile ── */
  .message-group:hover {
    background: transparent;
  }
  .message-group:active {
    background: var(--bg-modifier-hover);
  }

  /* Show message actions on tap (long-press feel) */
  .msg-actions {
    display: none !important;
  }

  /* ── Profile popout: fit mobile screen ── */
  .profile-popout {
    width: calc(100vw - 48px);
    max-width: 340px;
  }
}
