/* ═══════════════════════════════════════════════════════════
   NEXUS MESSENGER — MODERN BENTO REDESIGN (v3)
   Modern Bento Grid layout: top navigation + sidebar + content.
   Loads last to override all existing styles.
   Designed to NOT look like Discord.
═══════════════════════════════════════════════════════════ */

/* ── ROOT TOKENS ── */
:root {
  --font-primary: 'Inter', 'Noto Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ── GLOBAL TYPOGRAPHY & RENDERING ── */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

html { font-family: var(--font-primary); scroll-behavior: smooth; }
body { font-family: var(--font-primary); letter-spacing: -0.01em; }

/* ═══════════════════════════════════════════════════════════
   APP SHELL — Column layout: top-nav on top, body below
═══════════════════════════════════════════════════════════ */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-primary);
}

.app-body {
  display: flex;
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* Hide legacy server rail entirely (we use top-nav now) */
.server-rail,
.server-sidebar {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════
   TOP NAVIGATION BAR — Modern horizontal nav
═══════════════════════════════════════════════════════════ */
.top-nav {
  height: var(--topnav-height);
  min-height: var(--topnav-height);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 16px;
  z-index: 100;
  position: relative;
}

.topnav-left {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
}

/* Brand logo (square gradient mark + text) */
.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  flex-shrink: 0;
}
.brand-logo:hover { background: var(--bg-hover); }

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -1px;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
  flex-shrink: 0;
}
.brand-text {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-header);
  letter-spacing: -0.5px;
}

/* Tabs */
.topnav-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tn-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
  font-family: inherit;
  white-space: nowrap;
}
.tn-tab:hover {
  color: var(--text-normal);
  background: var(--bg-hover);
}
.tn-tab.active {
  color: var(--brand);
  background: var(--brand-light);
}
.tn-tab svg { opacity: 0.9; }

/* Center search */
.topnav-center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 420px;
  margin: 0 auto;
}
.topnav-search {
  position: relative;
  width: 100%;
  max-width: 380px;
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  padding: 0 14px;
  transition: border-color var(--transition-fast);
}
.topnav-search:focus-within { border-color: var(--brand); }
.topnav-search svg { color: var(--text-muted); flex-shrink: 0; }
.topnav-search input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-normal);
  font-size: 13px;
  padding: 8px 10px;
  width: 100%;
  font-family: inherit;
}
.topnav-search input::placeholder { color: var(--input-placeholder); }

/* Right side */
.topnav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tn-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
  flex-shrink: 0;
}
.tn-icon-btn:hover {
  color: var(--brand);
  background: var(--bg-hover);
}

/* User pill (avatar + name + controls) */
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 8px 5px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.user-pill:hover {
  background: var(--bg-hover);
  border-color: var(--brand);
}
.avatar-stack { position: relative; flex-shrink: 0; }
.avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gradient-brand);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}
.status-ring {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--bg-tertiary);
}
.status-ring.online { background: var(--status-online); }
.user-pill .user-text { display: flex; flex-direction: column; min-width: 0; }
.user-pill .user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-header);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}
.user-pill .ua-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.user-pill .ua-btn:hover { color: var(--text-normal); background: var(--bg-active); }

/* Servers dropdown */
.servers-dropdown {
  position: absolute;
  top: calc(var(--topnav-height) - 4px);
  left: 200px;
  width: 300px;
  background: var(--bg-floating);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
  z-index: 200;
  overflow: hidden;
  animation: dropdownIn 0.2s var(--ease-out-expo);
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.sd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.sd-add {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--transition-fast);
}
.sd-add:hover { transform: rotate(90deg) scale(1.1); }
.sd-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.sd-server {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.sd-server:hover { background: var(--bg-hover); }
.sd-server.active { background: var(--brand-light); }
.sd-server-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--gradient-brand);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
  background-size: cover;
  flex-shrink: 0;
}
.sd-server-info { min-width: 0; flex: 1; }
.sd-server-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sd-server-meta {
  font-size: 11px;
  color: var(--text-muted);
}
.sd-server-settings {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: all var(--transition-fast);
}
.sd-server:hover .sd-server-settings { opacity: 1; }
.sd-server-settings:hover {
  background: var(--brand);
  color: #fff;
  transform: rotate(45deg);
}

/* ═══════════════════════════════════════════════════════════
   SIDE PANEL — Unified sidebar (DMs or server channels)
═══════════════════════════════════════════════════════════ */
.side-panel {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--glass-border);
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  flex-shrink: 0;
  background: var(--bg-secondary);
}

.panel-header input.settings-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  padding: 8px 14px;
  color: var(--text-normal);
  font-size: 13px;
  flex: 1;
  outline: none;
  transition: border-color var(--transition-fast);
}
.panel-header input.settings-input:focus { border-color: var(--brand); }
.panel-header input.settings-input::placeholder { color: var(--input-placeholder); }

.server-header-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.server-header-inner span {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-header);
}

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

.panel-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 14px 8px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-section-label button {
  color: var(--text-muted);
  font-size: 18px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  border: none;
  transition: all var(--transition-fast);
}
.panel-section-label button:hover { color: var(--brand); background: var(--bg-hover); }

/* Channel items */
.ch-item,
.channel-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition-fast);
}
.ch-item:hover,
.channel-item:hover {
  background: var(--bg-hover);
  color: var(--text-normal);
}
.ch-item.active,
.channel-item.active {
  background: var(--bg-active);
  color: var(--text-header);
  font-weight: 600;
}
.channel-icon {
  margin-right: 8px;
  font-style: normal;
  opacity: 0.7;
  font-size: 18px;
}
.channel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Category headers */
.cat-toggle,
.channel-category-header {
  padding: 6px 8px;
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.cat-name,
.category-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.cat-toggle:hover .cat-name,
.channel-category-header:hover .category-name { color: var(--text-normal); }

/* DM items */
.dm-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  transition: all var(--transition-fast);
}
.dm-item:hover {
  background: var(--bg-hover);
  color: var(--text-normal);
}
.dm-item.active {
  background: var(--bg-active);
  color: var(--text-header);
}
.dm-avatar-wrap { position: relative; margin-right: 11px; flex-shrink: 0; }
.dm-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--gradient-brand);
  background-size: cover;
  background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 13px;
}
.dm-status {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}
.dm-info { flex: 1; min-width: 0; overflow: hidden; }
.dm-name {
  font-weight: 600;
  color: inherit;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dm-preview {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-width: 0;
  min-height: 0;
}

/* Chat view must fill main-content and constrain its children */
#view-chat,
#view-voice,
#view-friends,
#view-rooms {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* Top bar */
.top-bar,
.topbar {
  height: 56px;
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  border-bottom: 1px solid var(--glass-border);
  background: var(--bg-primary);
  flex-shrink: 0;
  z-index: 10;
}
.top-icon {
  font-size: 22px;
  color: var(--text-muted);
  font-weight: 700;
}
.top-channel-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-header);
}
.top-sep {
  width: 1px;
  height: 22px;
  background: var(--glass-border);
  margin: 0 4px;
}
.top-topic {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.top-btn,
.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
}
.top-btn:hover,
.topbar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-normal);
}

/* ═══════════════════════════════════════════════════════════
   WELCOME STATE
═══════════════════════════════════════════════════════════ */
.welcome-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 40px;
}
.ws-icon {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -2px;
  box-shadow: 0 12px 40px rgba(14, 165, 233, 0.35);
  animation: floatIcon 4s ease-in-out infinite;
}
@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.welcome-state h2 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-header);
  letter-spacing: -0.5px;
}
.welcome-state p {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 420px;
}

/* ═══════════════════════════════════════════════════════════
   FRIENDS PAGE — Card grid
═══════════════════════════════════════════════════════════ */
.friends-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.friends-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 56px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.friends-header-icon {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-header);
}
.friends-header-title { font-size: 16px; font-weight: 700; }
.fh-divider {
  width: 1px;
  height: 22px;
  background: var(--glass-border);
}
.friends-nav { display: flex; gap: 4px; }
.fnav-btn {
  padding: 7px 12px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
}
.fnav-btn:hover { background: var(--bg-hover); color: var(--text-normal); }
.fnav-btn.active { background: var(--brand); color: #fff; }
.fnav-btn.green { color: var(--green); }
.fnav-btn.green:hover { background: var(--green); color: #fff; }

/* Friend cards grid */
#friends-content { padding: 20px; }
.friend-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: all var(--transition-fast);
}
.friend-card:hover {
  background: var(--bg-hover);
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* ═══════════════════════════════════════════════════════════
   CHAT AREA — Messages & input
═══════════════════════════════════════════════════════════ */
.chat-wrapper {
  flex: 1;
  display: flex;
  min-height: 0;
  min-width: 0;
  position: relative;
}
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.messages-container {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.messages-list {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100%;
  padding: 16px 0 4px;
}

/* Message group */
.msg-group {
  display: flex;
  padding: 4px 20px 4px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  position: relative;
  transition: background var(--transition-fast);
}
.msg-group:hover { background: var(--msg-hover-bg); }
.msg-group.first { padding-top: 16px; margin-top: 8px; }
.msg-group.mentioned { background: rgba(251, 191, 36, 0.06); }
.msg-group.mentioned:hover { background: rgba(251, 191, 36, 0.10); }
.msg-group:hover .msg-timestamp-small { opacity: 1; }
.msg-group:hover .msg-actions { opacity: 1; pointer-events: all; }

.msg-avatar-col {
  position: static !important;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  padding-top: 2px;
  margin-right: 12px;
  left: auto !important;
  top: auto !important;
}
.msg-avatar,
.msg-group img.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-brand);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}
.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.msg-group:not(.first) .msg-avatar-col { visibility: hidden; }

.msg-body { flex: 1; min-width: 0; padding-left: 0; }
.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.msg-author {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-header);
}
.msg-timestamp-small {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.msg-content {
  font-size: 15px;
  color: var(--text-normal);
  line-height: 1.4;
  word-wrap: break-word;
}

/* Message timestamp */
.msg-time {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Message text + edited tag */
.msg-text {
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.msg-text.deleted {
  color: var(--text-muted);
  font-style: italic;
}
.msg-edited-tag {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* Nitro badge next to author name */
.nitro-badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  margin-left: 4px;
  vertical-align: middle;
}

/* Reply bar above message */
.msg-reply-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
  cursor: pointer;
  position: relative;
  padding-left: 4px;
  padding-right: 16px;
  overflow: hidden;
}
.msg-reply-bar:hover { color: var(--text-normal); }
.msg-reply-bar .reply-line {
  width: 2px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 1px;
  flex-shrink: 0;
  margin-left: -6px;
}
.reply-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reply-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.reply-author {
  font-weight: 700;
  flex-shrink: 0;
}
.reply-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.7;
}

/* Message hover actions toolbar */
.msg-actions {
  position: absolute;
  top: -16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--msg-actions-bg);
  border: 1px solid var(--msg-actions-border);
  border-radius: var(--radius-sm);
  padding: 2px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 5;
}
.msg-quick-reactions {
  display: flex;
  gap: 1px;
  padding-right: 4px;
  border-right: 1px solid var(--msg-actions-border);
}
.msg-quick-reaction {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.msg-quick-reaction:hover { background: var(--bg-hover); transform: scale(1.2); }
.msg-action {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  transition: all var(--transition-fast);
}
.msg-action:hover { background: var(--bg-hover); color: var(--text-normal); }
.msg-action.danger:hover { background: rgba(248, 113, 113, 0.2); color: var(--red); }

/* Reactions row */
.msg-reactions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.reaction-add-btn {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--reaction-bg);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  transition: all var(--transition-fast);
}
.reaction-add-btn:hover { background: var(--reaction-hover); color: var(--text-normal); }
.r-count { font-size: 12px; font-weight: 700; }

/* Attachments */
.msg-attachments { margin-top: 6px; }
.att-gallery { display: flex; flex-wrap: wrap; gap: 4px; }
.att-image-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  max-width: 320px;
  cursor: pointer;
}
.att-image {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  display: block;
  border-radius: var(--radius-sm);
}
.att-video-wrap, .att-audio-wrap { margin-top: 4px; max-width: 400px; }
.att-video { max-width: 100%; max-height: 320px; border-radius: var(--radius-sm); }
.att-file-icon { font-size: 24px; }

/* Thread indicator */
.thread-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--brand);
  font-weight: 600;
  margin-top: 4px;
  cursor: pointer;
}
.thread-indicator:hover { text-decoration: underline; }

/* Input area — rounded pill style */
.input-area {
  padding: 0 20px 20px;
  flex-shrink: 0;
}
.reply-strip {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.input-box {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-end;
  padding: 4px 8px;
  transition: border-color var(--transition-fast);
}
.input-box:focus-within { border-color: var(--brand); }
.reply-strip + .input-box { border-radius: 0 0 var(--radius-md) var(--radius-md); }
.msg-input,
.thread-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-normal);
  font-size: 15px;
  padding: 12px 8px;
  font-family: inherit;
  min-height: 24px;
  max-height: 200px;
  overflow-y: auto;
}
.msg-input::placeholder,
.thread-input::placeholder { color: var(--input-placeholder); }
.input-attach-btn,
.input-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  border: none;
  font-family: inherit;
}
.input-attach-btn:hover,
.input-icon-btn:hover { color: var(--brand); background: var(--bg-hover); }

/* ═══════════════════════════════════════════════════════════
   MEMBER LIST
═══════════════════════════════════════════════════════════ */
.member-list,
.member-panel {
  width: var(--members-width);
  min-width: var(--members-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--glass-border);
  overflow-y: auto;
  padding: 16px 8px;
  flex-shrink: 0;
}
.member-section-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 16px 8px 4px;
}
.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.member-item:hover { background: var(--bg-hover); }
.member-avatar-wrap { position: relative; flex-shrink: 0; }
.member-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--gradient-brand);
  background-size: cover;
  background-position: center;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 13px;
}
.member-status-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--bg-secondary);
}
.member-name { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.member-item:hover .member-name { color: var(--text-normal); }

/* ═══════════════════════════════════════════════════════════
   THREAD PANEL
═══════════════════════════════════════════════════════════ */
.thread-panel {
  width: 420px;
  min-width: 420px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.thread-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  border-bottom: 1px solid var(--glass-border);
  font-weight: 700;
  color: var(--text-header);
}
.thread-header button {
  width: 32px; height: 32px;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  border: none;
}
.thread-header button:hover { background: var(--bg-hover); color: var(--text-normal); }
.thread-body { flex: 1; overflow-y: auto; padding: 12px; }
.thread-input-area { padding: 12px; border-top: 1px solid var(--glass-border); }
.thread-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-normal);
}

/* ═══════════════════════════════════════════════════════════
   VOICE VIEW — Modern call interface
═══════════════════════════════════════════════════════════ */
.voice-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
  gap: 20px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at top, rgba(14, 165, 233, 0.06), transparent 60%),
    var(--bg-primary);
}
.vc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-header);
  font-size: 19px;
  font-weight: 800;
  flex-shrink: 0;
}
.vc-header svg { color: var(--brand); }

/* Participant grid */
.vc-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  align-content: center;
  overflow-y: auto;
  padding: 4px;
}

/* Single participant tile */
.vc-tile {
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-xl);
  aspect-ratio: 16/10;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
/* Connecting shimmer */
.vc-tile--connecting {
  background: linear-gradient(110deg, var(--bg-secondary) 30%, var(--bg-tertiary) 50%, var(--bg-secondary) 70%);
  background-size: 200% 100%;
  animation: vcShimmer 1.4s linear infinite;
}
@keyframes vcShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
/* Speaking state — soft glow ring */
.vc-tile.speaking {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.25), 0 0 40px rgba(14, 165, 233, 0.25);
}
.vc-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-xl);
}

/* Tile overlay (avatar + name + status) */
.vc-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* Big centered avatar when no video */
.vc-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 36px;
  font-weight: 800;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  flex-shrink: 0;
}
.vc-tile.speaking .vc-avatar {
  animation: vcAvatarPulse 1.5s ease-in-out infinite;
}
@keyframes vcAvatarPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.5), 0 8px 28px rgba(0,0,0,0.35); }
  50% { box-shadow: 0 0 0 12px rgba(14, 165, 233, 0), 0 8px 28px rgba(0,0,0,0.35); }
}

/* Name label at bottom */
.vc-name {
  position: absolute;
  bottom: 14px;
  left: 14px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 2;
}

/* Status badges row */
.vc-status-row {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  gap: 5px;
  z-index: 2;
}
.vc-status-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.vc-status-badge.muted { background: rgba(248, 113, 113, 0.8); }

/* Floating controls bar */
.vc-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  align-self: center;
  box-shadow: var(--shadow-high);
  flex-shrink: 0;
  max-width: 100%;
  overflow-x: auto;
}
.vc-controls::-webkit-scrollbar { display: none; }

.vc-ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-normal);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast), color var(--transition-fast);
  border: none;
  font-family: inherit;
  min-width: 76px;
  flex-shrink: 0;
}
.vc-ctrl-btn svg { width: 24px; height: 24px; transition: transform var(--transition-fast); }
.vc-ctrl-btn span { font-size: 11px; font-weight: 700; letter-spacing: 0.2px; }
.vc-ctrl-btn:hover {
  background: var(--bg-hover);
}
.vc-ctrl-btn:hover svg { transform: scale(1.12); }
.vc-ctrl-btn:active { transform: scale(0.94); }
.vc-ctrl-btn.muted-state {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
}
.vc-ctrl-btn.muted-state:hover { background: rgba(248, 113, 113, 0.25); }
.vc-ctrl-btn.leave-btn {
  background: var(--red);
  color: #fff;
}
.vc-ctrl-btn.leave-btn:hover {
  background: var(--text-danger);
  transform: translateY(-1px);
}

/* Voice stage when only audio (single large participant) */
.vc-grid:has(.vc-tile:only-child) .vc-avatar {
  width: 140px;
  height: 140px;
  font-size: 52px;
}

@media (max-width: 768px) {
  .vc-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .vc-avatar { width: 72px; height: 72px; font-size: 28px; }
  .vc-ctrl-btn { padding: 10px 12px; min-width: 62px; }
  .vc-ctrl-btn span { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal,
#modal-box > div {
  background: var(--bg-floating);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalRise 0.25s var(--ease-out-expo);
}
@keyframes modalRise {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header,
.modal-title-wrap {
  padding: 20px 24px 8px;
}
.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-header);
  letter-spacing: -0.3px;
}
.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.modal-body { padding: 12px 24px 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--glass-border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-field { margin-bottom: 16px; }
.modal-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.modal-input,
.modal-textarea,
.modal-select {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-normal);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition-fast);
}
.modal-input:focus,
.modal-textarea:focus,
.modal-select:focus { border-color: var(--brand); }
.modal-input::placeholder,
.modal-textarea::placeholder { color: var(--input-placeholder); }

/* Buttons */
.btn,
button.btn,
.auth-btn,
.btn-auth,
.btn-modern {
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary,
.btn-auth,
.auth-btn {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.3);
}
.btn-primary:hover,
.btn-auth:hover,
.auth-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
}
.btn-ghost,
.btn-modern {
  background: var(--bg-hover);
  color: var(--text-normal);
}
.btn-ghost:hover,
.btn-modern:hover { background: var(--bg-active); }
.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.1); }

/* ═══════════════════════════════════════════════════════════
   CONTEXT MENU
═══════════════════════════════════════════════════════════ */
.ctx-menu {
  position: fixed;
  background: var(--bg-floating);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
  padding: 6px;
  min-width: 200px;
  z-index: 1500;
  animation: ctxIn 0.12s var(--ease-out-expo);
}
@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-normal);
  font-size: 14px;
  transition: background var(--transition-fast);
}
.ctx-item:hover { background: var(--brand); color: #fff; }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: var(--red); }
.ctx-sep { height: 1px; background: var(--ctx-sep); margin: 4px 0; }

/* ═══════════════════════════════════════════════════════════
   TOASTS
═══════════════════════════════════════════════════════════ */
.toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}
.toast {
  background: var(--bg-floating);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-high);
  color: var(--text-normal);
  font-size: 14px;
  font-weight: 500;
  min-width: 280px;
  max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.3s var(--ease-spring);
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--brand); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ═══════════════════════════════════════════════════════════
   SETTINGS PAGE — Left sidebar + content (classic, works everywhere)
═══════════════════════════════════════════════════════════ */
.settings-page {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 500;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* Left sidebar */
.settings-sidebar {
  width: 260px;
  min-width: 260px;
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: flex !important;
  flex-direction: column;
  padding-top: 60px;
  flex-shrink: 0;
  overflow: hidden;
}
.settings-sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 80px;
  scrollbar-width: thin;
}
.settings-sidebar-inner::-webkit-scrollbar { width: 6px; }
.settings-sidebar-inner::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 3px;
}

.settings-category {
  display: block !important;
  padding: 18px 8px 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
}
.settings-sep {
  display: block !important;
  height: 1px;
  background: var(--glass-border);
  margin: 8px 4px;
}

.settings-nav-item,
.ss-item {
  display: block;
  padding: 9px 12px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
}
.settings-nav-item:hover,
.ss-item:hover {
  color: var(--text-normal);
  background: var(--bg-hover);
}
.settings-nav-item.active,
.ss-item.active {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}
.settings-nav-item.danger,
.ss-item.danger { color: var(--red); }
.settings-nav-item.danger:hover,
.ss-item.danger:hover { background: rgba(248, 113, 113, 0.1); color: var(--red); }

/* Content area */
.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 60px 48px 48px;
  max-width: 860px;
  width: 100%;
}

.settings-close {
  position: fixed;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
  transition: all var(--transition-fast);
}
.settings-close:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  transform: rotate(90deg);
}

.settings-title,
.settings-content h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-header);
  margin-bottom: 24px;
  letter-spacing: -0.5px;
}
.settings-content h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 24px;
}

/* Mobile: sidebar becomes a top scrollable bar */
@media (max-width: 768px) {
  .settings-page { flex-direction: column; }
  .settings-sidebar {
    width: 100%;
    min-width: 0;
    max-height: 120px;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--glass-border);
    padding-top: 56px;
  }
  .settings-sidebar-inner {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .settings-category, .settings-sep { display: none !important; }
  .settings-nav-item, .ss-item {
    flex-shrink: 0;
    padding: 8px 14px;
  }
  .settings-content { padding: 24px 18px; }
}

/* Settings cards */
.settings-card {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 12px;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--glass-border);
}
.toggle-row:last-child { border-bottom: none; }

/* Pill toggle switch */
.toggle-switch,
.toggle {
  position: relative;
  width: 44px;
  height: 26px;
  background: var(--bg-accent);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}
.toggle-switch.on,
.toggle.on,
.toggle-switch[aria-checked="true"] {
  background: var(--brand);
}
.toggle-switch::after,
.toggle::after,
.toggle-switch .knob,
.toggle .knob {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch.on::after,
.toggle.on::after,
.toggle-switch[aria-checked="true"]::after { transform: translateX(18px); }

/* Settings inputs */
.settings-input,
.settings-textarea,
.settings-select {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-normal);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition-fast);
}
.settings-input:focus,
.settings-textarea:focus,
.settings-select:focus { border-color: var(--brand); }

/* Range sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-accent);
  border-radius: var(--radius-full);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--brand);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(14, 165, 233, 0.4);
  transition: transform var(--transition-fast);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--brand);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

/* ── Settings slider rows (volume, sensitivity, font size) ── */
.slider-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 4px;
}
.slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}
.slider-label > span:first-child,
.slider-label > span:last-child {
  opacity: 0.6;
}
.slider-value {
  color: var(--brand) !important;
  font-weight: 700;
  font-size: 14px;
  opacity: 1 !important;
}

/* Settings-specific slider — bigger track for better grip */
.settings-slider,
input[type="range"].settings-slider {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 3px solid var(--brand);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.settings-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.5);
}
.settings-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.15);
}
.settings-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: #fff;
  border: 3px solid var(--brand);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform var(--transition-fast);
}
.settings-slider::-moz-range-thumb:hover { transform: scale(1.2); }

/* Firefox track */
.settings-slider::-moz-range-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: transparent;
}

/* Theme grid (Appearance) */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.theme-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
}
.theme-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.theme-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand);
}

/* ═══════════════════════════════════════════════════════════
   EMOJI PICKER
═══════════════════════════════════════════════════════════ */
.emoji-picker {
  position: absolute;
  bottom: 56px;
  right: 8px;
  width: 360px;
  max-height: 400px;
  background: var(--bg-floating);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

/* ═══════════════════════════════════════════════════════════
   PROFILE POPOUT
═══════════════════════════════════════════════════════════ */
.profile-popout {
  position: fixed;
  background: var(--bg-floating);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-overlay);
  width: 320px;
  z-index: 1400;
  overflow: hidden;
  animation: profileIn 0.2s var(--ease-out-expo);
}
@keyframes profileIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ═══════════════════════════════════════════════════════════
   DATE DIVIDER
═══════════════════════════════════════════════════════════ */
.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.date-divider::before,
.date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}

/* ═══════════════════════════════════════════════════════════
   REACTIONS
═══════════════════════════════════════════════════════════ */
.reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--reaction-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.reaction:hover { background: var(--reaction-hover); transform: scale(1.05); }
.reaction.own {
  background: var(--brand-light);
  border-color: var(--brand);
}

/* ═══════════════════════════════════════════════════════════
   MOBILE
═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .topnav-tabs { display: none; }
  .topnav-search { max-width: 200px; }
  .user-pill .user-text { display: none; }
  .side-panel {
    position: fixed;
    left: 0;
    top: var(--topnav-height);
    bottom: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  .side-panel.mobile-open { transform: translateX(0); }
  .member-list,
  .member-panel { display: none; }
  .thread-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 200;
  }
  .settings-content { padding: 20px 16px; }
  .vc-grid { grid-template-columns: 1fr; }
  .vc-ctrl-btn { padding: 8px 10px; min-width: 56px; }
}

/* ═══════════════════════════════════════════════════════════
   REDUCED MOTION
═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .ws-icon { animation: none; }
}

/* ═══════════════════════════════════════════════════════════
   SCROLLBARS
═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--bg-accent); }

/* ═══════════════════════════════════════════════════════════
   UNIVERSAL FORM INPUT OVERRIDES (theme vars)
═══════════════════════════════════════════════════════════ */
.settings-input, .modal-input, .modal-textarea, .modal-select,
.settings-textarea, .settings-select,
input[type="text"], input[type="email"], input[type="password"],
textarea, select {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-normal);
}
.settings-input:focus, .modal-input:focus, .settings-textarea:focus,
.settings-select:focus, .modal-textarea:focus {
  border-color: var(--input-border-focus);
}
.input-box { background: var(--bg-secondary); }
.reaction { background: var(--reaction-bg); }
.reaction:hover { background: var(--reaction-hover); }
.reaction.own { background: var(--brand-light); border-color: var(--brand); }
code { background: var(--code-bg); color: var(--code-color); }
.mention { color: var(--mention-color); background: var(--mention-bg); }
.mention:hover { background: var(--mention-hover-bg); }
.ctx-sep { background: var(--ctx-sep); }
.msg-group:hover { background: var(--msg-hover-bg); }
.msg-actions {
  background: var(--msg-actions-bg) !important;
  border-color: var(--msg-actions-border) !important;
}

/* ═══════════════════════════════════════════════════════════
   LINK / MENTION / CODE BASE
═══════════════════════════════════════════════════════════ */
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
pre {
  background: var(--code-bg);
  color: var(--code-color);
  padding: 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════
   ATTACHMENTS
═══════════════════════════════════════════════════════════ */
.att-file,
.attachment {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 6px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color var(--transition-fast);
}
.att-file:hover { border-color: var(--brand); }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 8px; }
.file-chip {
  background: var(--brand-light);
  border: 1px solid var(--brand);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-normal);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ═══════════════════════════════════════════════════════════
   TOTP QR (2FA) — ensure canvas displays
═══════════════════════════════════════════════════════════ */
#totp-qr {
  background: #fff !important;
  border-radius: var(--radius-sm);
  display: block;
  margin: 0 auto;
  max-width: 100%;
}

/* ═══════════════════════════════════════════════════════════
   SEARCH RESULTS
═══════════════════════════════════════════════════════════ */
#topnav-search-results,
#dm-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-floating);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-high);
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
  padding: 6px;
}

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-accent) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Typing indicator */
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots span {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.typing-bar {
  padding: 0 20px 4px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ═══════════════════════════════════════════════════════════
   ADMIN PANEL — Full screen management interface
═══════════════════════════════════════════════════════════ */
.admin-panel {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  background: var(--bg-primary);
  animation: fadeIn 0.2s ease-out;
}

.admin-sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--glass-border);
}

.admin-logo {
  padding: 22px 18px;
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--glass-border);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.10), rgba(99, 102, 241, 0.10));
  color: var(--text-header);
}

.admin-tabs {
  padding: 10px 8px;
  flex: 1;
  overflow-y: auto;
}

.admin-tab {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-tab:hover {
  background: var(--bg-hover);
  color: var(--text-normal);
}

.admin-tab.active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.admin-sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--glass-border);
}

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-header {
  padding: 22px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--glass-border);
}

.admin-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
  color: var(--text-header);
  letter-spacing: -0.5px;
}

.admin-close-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all var(--transition-fast);
  border: 1px solid var(--glass-border);
}

.admin-close-btn:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  transform: rotate(90deg);
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.admin-stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  border: 1px solid var(--glass-border);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.admin-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand);
}

.admin-stat-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.admin-stat-value {
  font-size: 32px;
  font-weight: 900;
  color: var(--text-header);
}

.admin-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.admin-stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.admin-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--glass-border);
}

.admin-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text-header);
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th {
  text-align: left;
  padding: 11px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--glass-border);
}

.admin-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--glass-border);
  vertical-align: middle;
  color: var(--text-normal);
}

.admin-table tr:hover td {
  background: var(--bg-hover);
}

.admin-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.admin-badge-red {
  background: rgba(248, 113, 113, 0.18);
  color: var(--red);
}

.admin-badge-blue {
  background: rgba(14, 165, 233, 0.18);
  color: var(--brand);
}

.admin-badge-purple {
  background: rgba(155, 89, 182, 0.18);
  color: #a78bfa;
}

.admin-badge-green {
  background: rgba(52, 211, 153, 0.18);
  color: var(--green);
}

.admin-info-cell {
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.admin-info-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.admin-info-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-header);
}

.admin-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  font-size: 16px;
}

@media (max-width: 900px) {
  .admin-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-sidebar { width: 200px; min-width: 200px; }
  .admin-content { padding: 16px; }
}

/* ═══════════════════════════════════════════════════════════
   VISUAL FIXES — Contrast, light theme, Nitro theme polish
═══════════════════════════════════════════════════════════ */

/* Light theme — fix glass backgrounds that vanish on white */
[data-theme="light"] .top-nav {
  background: rgba(255, 255, 255, 0.75) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
[data-theme="light"] .topnav-search {
  background: var(--bg-tertiary) !important;
}
[data-theme="light"] .user-pill {
  background: var(--bg-tertiary) !important;
}
[data-theme="light"] .vc-controls {
  background: rgba(255, 255, 255, 0.7) !important;
}
[data-theme="light"] .topnav-search svg { color: var(--text-muted) !important; }

/* Ensure main content areas always have the theme background */
.main-content,
.welcome-state,
.friends-page,
.view-friends {
  background: var(--bg-primary) !important;
}

/* Welcome state — ensure visibility on all themes */
.welcome-state h2 { color: var(--text-header) !important; }
.welcome-state p { color: var(--text-muted) !important; }

/* Friends content fallback background */
#friends-content {
  background: var(--bg-primary);
}

/* Nitro themes — ensure glass bg is visible (dark base) */
[data-theme="sunset"] .top-nav,
[data-theme="ocean"] .top-nav,
[data-theme="forest"] .top-nav,
[data-theme="neon"] .top-nav,
[data-theme="rose"] .top-nav,
[data-theme="aurora"] .top-nav {
  background: rgba(0, 0, 0, 0.3) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Nitro themes — inputs visibility */
[data-theme="sunset"] .topnav-search,
[data-theme="ocean"] .topnav-search,
[data-theme="forest"] .topnav-search,
[data-theme="neon"] .topnav-search,
[data-theme="rose"] .topnav-search,
[data-theme="aurora"] .topnav-search {
  background: var(--bg-tertiary) !important;
}

/* Mobile bottom nav */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: none;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  height: 56px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--glass-border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.mobile-bottom-nav.mobile-only { display: none; }
.mobile-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  border: none;
  font-size: 10px;
  font-weight: 600;
  transition: color var(--transition-fast);
}
.mobile-nav-btn svg { width: 22px; height: 22px; }
.mobile-nav-btn.active { color: var(--brand); }

@media (max-width: 768px) {
  .mobile-only { display: flex !important; }
  .mobile-bottom-nav.mobile-only { display: flex !important; }
}

/* Profile popout text contrast on all themes */
.profile-popout { color: var(--text-normal); }

/* Context menu visibility */
.ctx-menu { color: var(--text-normal); }

/* Channel welcome message */
.channel-welcome {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.channel-welcome .cw-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--brand-light);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  color: var(--brand);
  margin-bottom: 16px;
}
.channel-welcome .cw-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-header);
  margin-bottom: 8px;
}
.channel-welcome .cw-desc {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 420px;
  margin: 0 auto;
}
.channel-welcome strong { color: var(--text-normal); }

/* Pins panel */
.pins-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.pins-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--glass-border);
  font-weight: 700;
  color: var(--text-header);
}
.pins-header button {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}
.pins-header button:hover { background: var(--bg-hover); color: var(--text-normal); }
.pins-list { flex: 1; overflow-y: auto; padding: 8px; }
.pin-item {
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.pin-item:hover { background: var(--bg-hover); }
.pin-author { font-weight: 700; font-size: 13px; color: var(--text-header); margin-bottom: 4px; }
.pin-text { font-size: 13px; color: var(--text-muted); }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease;
}
.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Server header button + dropdown (legacy server panel header) */
.server-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-floating);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-overlay);
  z-index: 50;
  overflow: hidden;
}

/* Mobile header */
.mobile-header {
  display: none;
}
@media (max-width: 768px) {
  .mobile-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: 50px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--glass-border);
  }
  .mobile-hamburger {
    width: 34px; height: 34px;
    display: flex; flex-direction: column;
    justify-content: center; gap: 4px;
    cursor: pointer;
  }
  .mobile-hamburger span {
    display: block; width: 20px; height: 2px;
    background: var(--text-normal); border-radius: 1px;
  }
  .mobile-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 80;
    opacity: 0; pointer-events: none;
    transition: opacity var(--transition);
  }
  .mobile-overlay.active { opacity: 1; pointer-events: all; }
}

/* Mobile-only utility */
.mobile-only { display: none; }
@media (max-width: 768px) {
  .mobile-only:not(.mobile-bottom-nav) { display: flex; }
}

/* Status dots */
.status-dot { border-radius: 50%; }
.status-online { background: var(--status-online); }
.status-idle { background: var(--status-idle); }
.status-dnd { background: var(--status-dnd); }
.status-offline { background: var(--status-offline); }

/* DM list close button */
.dm-close {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast);
}
.dm-item:hover .dm-close { opacity: 0.6; }
.dm-close:hover { opacity: 1 !important; background: var(--bg-active); color: var(--text-normal); }

/* DM sub text */
.dm-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Scrollbar fix for settings content */
.settings-content { scrollbar-width: thin; }

/* Divider */
.settings-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 20px 0;
}

/* ═══════════════════════════════════════════════════════════
   TOUCH SCROLL — Enable smooth scrolling everywhere
   Works on mobile, tablet, desktop trackpads
═══════════════════════════════════════════════════════════ */

/* Universal: allow touch panning on all scrollable areas */
.messages-container,
.panel-body,
.settings-content,
.admin-content,
.thread-body,
.vc-grid,
.messages-list,
.side-panel,
#topnav-search-results,
#dm-search-results,
.servers-dropdown .sd-list,
.settings-sidebar-inner,
.profile-popout {
  -webkit-overflow-scrolling: touch;  /* iOS momentum scroll */
  touch-action: pan-y;                /* allow vertical pan */
  overscroll-behavior: contain;       /* don't propagate bounce */
}

/* Horizontal scroll areas (tabs, server dropdowns) */
.settings-tabs,
.topnav-tabs,
.vc-controls,
.mobile-bottom-nav {
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}

/* Both directions (rare cases like chat-wrapper) */
.chat-wrapper {
  touch-action: pan-x pan-y;
}

/* Prevent the WHOLE body from scrolling (only inner areas scroll) */
html, body {
  overscroll-behavior: none;   /* disable pull-to-refresh / rubber-band */
  touch-action: manipulation;  /* remove 300ms tap delay */
}

/* Smooth scroll behavior for message jumps */
.messages-container {
  scroll-behavior: smooth;
}

/* Custom thin scrollbars on touch (so they don't take space) */
@media (pointer: coarse) {
  .messages-container::-webkit-scrollbar,
  .panel-body::-webkit-scrollbar,
  .settings-content::-webkit-scrollbar,
  .admin-content::-webkit-scrollbar,
  .thread-body::-webkit-scrollbar,
  .vc-grid::-webkit-scrollbar,
  .settings-sidebar-inner::-webkit-scrollbar {
    width: 3px;
    height: 3px;
  }
  .messages-container::-webkit-scrollbar-thumb,
  .panel-body::-webkit-scrollbar-thumb,
  .settings-content::-webkit-scrollbar-thumb,
  .admin-content::-webkit-scrollbar-thumb,
  .thread-body::-webkit-scrollbar-thumb,
  .vc-grid::-webkit-scrollbar-thumb,
  .settings-sidebar-inner::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.3);
    border-radius: 3px;
  }
}

/* Ensure scroll containers have proper height constraints */
.panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.thread-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.admin-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.settings-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Mobile: allow message list to fill remaining height */
@media (max-width: 768px) {
  #view-chat {
    height: calc(100vh - var(--topnav-height) - 56px); /* topnav + mobile bottom nav */
  }
  .chat-main {
    min-height: 0;
  }
}

/* Pull-to-refresh prevention on the app shell */
#app {
  overscroll-behavior: contain;
}
